Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(atomic)!: externalize dependencies #4393

Merged
merged 43 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9e34dfa
externalize headless
fpbrault Sep 10, 2024
7f88bde
improve script
fpbrault Sep 11, 2024
def9830
revert change
fpbrault Sep 12, 2024
5400461
improve config
fpbrault Sep 12, 2024
91685f5
fix example
fpbrault Sep 12, 2024
64c2390
improve script
fpbrault Sep 12, 2024
b2d7443
Improve script to replace external dependencies with CDN links and pr…
fpbrault Sep 12, 2024
7249c13
adjust deployment pipeline
fpbrault Sep 12, 2024
8171af2
improve import replacement
fpbrault Sep 13, 2024
e5cb2c8
clean up
fpbrault Sep 13, 2024
254fa7c
fix devwatch
fpbrault Sep 13, 2024
415935c
cleanup
fpbrault Sep 13, 2024
a39092b
make bueno external for headless
fpbrault Sep 13, 2024
f31b473
use env var directly
fpbrault Sep 13, 2024
12e9018
fix deps
fpbrault Sep 13, 2024
2c06b95
revert changes to headless esbuild config
fpbrault Sep 13, 2024
14c1e12
exclude external builds for headless
fpbrault Sep 13, 2024
1f907ff
Revert "make bueno external for headless"
fpbrault Sep 16, 2024
64bd3fc
Revert "fix deps"
fpbrault Sep 16, 2024
51d394f
Revert "adjust deployment pipeline"
fpbrault Sep 16, 2024
19795d4
add package for rollup plugin
fpbrault Sep 16, 2024
492c46a
fix plugin
fpbrault Sep 16, 2024
528ed7b
fix atomic react
fpbrault Sep 16, 2024
b49de19
fix plugin
fpbrault Sep 16, 2024
473550e
fix cdn build
fpbrault Sep 16, 2024
3c6569a
Merge branch 'master' into KIT-3181
fpbrault Sep 16, 2024
883071c
remove extra files
fpbrault Sep 16, 2024
a7b3759
fix package-lock
fpbrault Sep 16, 2024
57e2651
remove extra package-lock
fpbrault Sep 16, 2024
c229d8d
fix rollup package
fpbrault Sep 17, 2024
e316fcd
cleanup
fpbrault Sep 17, 2024
62cd814
Merge branch 'master' into KIT-3181
fpbrault Sep 17, 2024
86a1702
remove tests
fpbrault Sep 17, 2024
5ea8ff7
fix deps
fpbrault Sep 17, 2024
20ba5f9
remove babel plugin
fpbrault Sep 17, 2024
fa1b203
Update packages/rollup-plugin-replace-with-ast/LICENSE
fpbrault Sep 17, 2024
7073b64
revert change to sample
fpbrault Sep 17, 2024
903cf98
Merge branch 'master' into KIT-3181
fpbrault Sep 17, 2024
adcca88
Merge branch 'master' into KIT-3181
louis-bompart Sep 17, 2024
c9ca425
Merge branch 'master' into KIT-3181
louis-bompart Sep 17, 2024
68703ce
Merge branch 'master' into KIT-3181
louis-bompart Sep 17, 2024
e1dbbe8
fix cypress tests
fpbrault Sep 17, 2024
54a1f9c
adapt stencil-sample
louis-bompart Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .deployment.config.json
fpbrault marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,99 +16,99 @@
},
"ordered_phases": [
{
"id": "deploy-headless-patch-to-s3-version",
"id": "deploy-bueno-patch-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_PATCH_VERSION]",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/bueno/v$[BUENO_PATCH_VERSION]",
"source": "packages/bueno/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-headless-minor-to-s3-version",
"id": "deploy-bueno-minor-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_MINOR_VERSION]",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/bueno/v$[BUENO_MINOR_VERSION]",
"source": "packages/bueno/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-headless-major-to-s3-version",
"id": "deploy-bueno-major-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_MAJOR_VERSION]",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/bueno/v$[BUENO_MAJOR_VERSION]",
"source": "packages/bueno/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-patch-to-s3-version",
"id": "deploy-headless-patch-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_PATCH_VERSION]",
"source": "packages/atomic/dist/atomic",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_PATCH_VERSION]",
"source": "packages/headless/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-minor-to-s3-version",
"id": "deploy-headless-minor-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MINOR_VERSION]",
"source": "packages/atomic/dist/atomic",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_MINOR_VERSION]",
"source": "packages/headless/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-major-to-s3-version",
"id": "deploy-headless-major-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MAJOR_VERSION]",
"source": "packages/atomic/dist/atomic",
"directory": "proda/StaticCDN/headless/v$[HEADLESS_MAJOR_VERSION]",
"source": "packages/headless/dist/browser",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-headless-patch-to-s3-version",
"id": "deploy-atomic-patch-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_PATCH_VERSION]/headless",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_PATCH_VERSION]",
"source": "packages/atomic/dist/atomic",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-headless-minor-to-s3-version",
"id": "deploy-atomic-minor-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MINOR_VERSION]/headless",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MINOR_VERSION]",
"source": "packages/atomic/dist/atomic",
"parameters": {
"acl": "public-read"
}
}
},
{
"id": "deploy-atomic-headless-major-to-s3-version",
"id": "deploy-atomic-major-to-s3-version",
"s3": {
"bucket": "{terraform.infra.infra.bucket_binaries}",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MAJOR_VERSION]/headless",
"source": "packages/headless/dist/browser",
"directory": "proda/StaticCDN/atomic/v$[ATOMIC_MAJOR_VERSION]",
"source": "packages/atomic/dist/atomic",
"parameters": {
"acl": "public-read"
}
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ runs:
# - if: steps.nx-cache.outputs.cache-hit != 'true'
- run: npm run build
shell: bash
- name: Run step only if DEPLOYMENT_ENVIRONMENT is CDN
fpbrault marked this conversation as resolved.
Show resolved Hide resolved
if: env.DEPLOYMENT_ENVIRONMENT == 'CDN'
run: npm run prepare-for-cdn
shell: bash
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"release:phase1": "nx run-many --targets=release:phase1 --all --parallel=false --output-style=stream",
"release:phase2": "npm run-script -w=@coveo/release reify",
"release:phase3": "npm run-script -w=@coveo/release git-publish-all",
"release:phase4": "nx run-many --targets=release:phase4 --all"
"release:phase4": "nx run-many --targets=release:phase4 --all",
"release:prepare-cdn": "node ./scripts/deploy/replace-external-deps-with-cdn.mjs"
},
"devDependencies": {
"@actions/core": "1.10.1",
Expand Down
1 change: 0 additions & 1 deletion packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"@axe-core/playwright": "4.9.1",
"@babel/core": "7.24.9",
"@coveo/atomic": "file:.",
"@coveo/headless": "2.80.0",
"@coveo/release": "1.0.0",
"@custom-elements-manifest/analyzer": "0.10.3",
"@fullhuman/postcss-purgecss": "6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/src/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Coveo Atomic</title>

<script type="module" src="/build/atomic.esm.js"></script>
<script nomodule src="/build/atomic.js"></script>
<link rel="icon" href="data:," />
Expand All @@ -20,6 +19,7 @@
organizationEndpoints: await searchInterface.getOrganizationEndpoints('searchuisamples'),
});

// Trigger a first search
// Trigger a first search
searchInterface.executeFirstSearch();

Expand Down
123 changes: 69 additions & 54 deletions packages/atomic/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,60 +183,62 @@ export const config: Config = {
],
rollupPlugins: {
before: [
isDevWatch &&
alias({
entries: [
{
find: '@coveo/headless/case-assist',
replacement: path.resolve(
__dirname,
'./src/external-builds/case-assist/headless.esm.js'
),
},
{
find: '@coveo/headless/commerce',
replacement: path.resolve(
__dirname,
'./src/external-builds/commerce/headless.esm.js'
),
},
{
find: '@coveo/headless/recommendation',
replacement: path.resolve(
__dirname,
'./src/external-builds/recommendation/headless.esm.js'
),
},
{
find: '@coveo/headless/commerce',
replacement: path.resolve(
__dirname,
'./src/external-builds/commerce/headless.esm.js'
),
},
{
find: '@coveo/headless/product-recommendation',
replacement: path.resolve(
__dirname,
'./src/external-builds/product-recommendation/headless.esm.js'
),
},
{
find: '@coveo/headless/insight',
replacement: path.resolve(
__dirname,
'./src/external-builds/insight/headless.esm.js'
),
},
{
find: '@coveo/headless',
replacement: path.resolve(
__dirname,
'./src/external-builds/headless.esm.js'
),
},
],
}),
isDevWatch
? alias({
entries: [
{
find: '@coveo/headless/case-assist',
replacement: path.resolve(
__dirname,
'./src/external-builds/case-assist/headless.esm.js'
),
},
{
find: '@coveo/headless/commerce',
replacement: path.resolve(
__dirname,
'./src/external-builds/commerce/headless.esm.js'
),
},
{
find: '@coveo/headless/recommendation',
replacement: path.resolve(
__dirname,
'./src/external-builds/recommendation/headless.esm.js'
),
},
{
find: '@coveo/headless/commerce',
replacement: path.resolve(
__dirname,
'./src/external-builds/commerce/headless.esm.js'
),
},
{
find: '@coveo/headless/product-recommendation',
replacement: path.resolve(
__dirname,
'./src/external-builds/product-recommendation/headless.esm.js'
),
},
{
find: '@coveo/headless/insight',
replacement: path.resolve(
__dirname,
'./src/external-builds/insight/headless.esm.js'
),
},
{
find: '@coveo/headless',
replacement: path.resolve(
__dirname,
'./src/external-builds/headless.esm.js'
),
},
],
})
: externalizeDependenciesPlugin(),
fpbrault marked this conversation as resolved.
Show resolved Hide resolved

html({
include: 'src/templates/**/*.html',
}),
Expand All @@ -247,3 +249,16 @@ export const config: Config = {
enableImportInjection: true,
},
};

function externalizeDependenciesPlugin() {
return {
name: 'externalize-dependencies',
resolveId(source: string) {
// TODO: add bueno once it's published on the cdn and npm
fpbrault marked this conversation as resolved.
Show resolved Hide resolved
if (/^@coveo\/(headless)/.test(source)) {
return false;
}
return null;
},
};
}
5 changes: 5 additions & 0 deletions scripts/deploy/execute-deployment-pipeline.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import atomicHostedPageJson from '../../packages/atomic-hosted-page/package.json
import atomicReactJson from '../../packages/atomic-react/package.json' assert {type: 'json'};
import atomicJson from '../../packages/atomic/package.json' assert {type: 'json'};
import headlessJson from '../../packages/headless/package.json' assert {type: 'json'};
import buenoJson from '../../packages/bueno/package.json' assert {type: 'json'};

const releaseCommit = execSync('git rev-parse HEAD').toString().trim();

Expand All @@ -16,12 +17,16 @@ function getVersionComposants(version) {
};
}

const bueno = getVersionComposants(buenoJson.version);
const headless = getVersionComposants(headlessJson.version);
const atomic = getVersionComposants(atomicJson.version);
const atomicReact = getVersionComposants(atomicReactJson.version);
const atomicHostedPage = getVersionComposants(atomicHostedPageJson.version);
console.log(execSync(`
deployment-package package create --with-deploy \
--resolve BUENO_MAJOR_VERSION=${bueno.major} \
--resolve BUENO_MINOR_VERSION=${bueno.major}.${bueno.minor} \
--resolve BUENO_PATCH_VERSION=${bueno.major}.${bueno.minor}.${bueno.patch} \
--resolve HEADLESS_MAJOR_VERSION=${headless.major} \
--resolve HEADLESS_MINOR_VERSION=${headless.major}.${headless.minor} \
--resolve HEADLESS_PATCH_VERSION=${headless.major}.${headless.minor}.${headless.patch} \
Expand Down
2 changes: 2 additions & 0 deletions scripts/deploy/invalidate-cloudfront.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async function main() {
`/atomic/v${getMajorVersion('atomic')}/*`,
'/headless/latest/*',
`/headless/v${getMajorVersion('headless')}/*`,
'/bueno/latest/*',
`/bueno/v${getMajorVersion('bueno')}/*`,
];

const invalidationRequest = cloudfront.createInvalidation({
Expand Down
Loading
Loading