Skip to content

Commit

Permalink
fix(atomic): deploy loader to the CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Oct 21, 2024
1 parent f42d055 commit 1ba3b64
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ utils/**/.storybook/**
scripts/deploy/execute-deployment-pipeline.mjs
**/staticresources/**
packages/atomic-hosted-page/loader/**/*
packages/atomic/loader/**/*
packages/atomic/docs/**/*
packages/atomic/dist-storybook/**/*
packages/atomic/src/components/search/atomic-search-interface/lang/*.json
Expand Down
1 change: 1 addition & 0 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"build": "nx build",
"clean": "rimraf -rf dist",
"build:fixLoaderImportPaths": "node ./scripts/fix-loader-import-paths.js",
"build:fixGeneratedImportPaths": "fix-esm-import-path src/components/stencil-generated",
"build:bundles:esm": "tsc -p tsconfig.esm.json",
"build:bundles:iife-cjs": "rollup --config rollup.config.mjs --bundleConfigAsCjs",
Expand Down
1 change: 1 addition & 0 deletions packages/atomic-react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"npm run build:fixLoaderImportPaths",
"npm run build:fixGeneratedImportPaths",
"npm run build:bundles",
"npm run build:assets"
Expand Down
29 changes: 29 additions & 0 deletions packages/atomic-react/scripts/fix-loader-import-paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {promises as fs} from 'fs';
import path from 'path';

const files = [
path.resolve('src/components/stencil-generated/commerce/index.ts'),
path.resolve('src/components/stencil-generated/search/index.ts'),
];

const oldImport =
"import { defineCustomElements } from '@coveo/atomic/dist/loader';";
const newImport =
"import { defineCustomElements } from '@coveo/atomic/loader';";

const updateFiles = async () => {
await Promise.all(
files.map(async (filePath) => {
try {
let data = await fs.readFile(filePath, 'utf8');
const updatedData = data.replace(oldImport, newImport);
await fs.writeFile(filePath, updatedData, 'utf8');
console.log(`File updated: ${filePath}`);
} catch (err) {
console.error(`Error updating file: ${filePath}`, err);
}
})
);
};

updateFiles();
1 change: 0 additions & 1 deletion packages/atomic/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = {
'src/external-builds/**/*',
'dist/**/*',
'www/**/*',
'loader/**/*',
'docs/**/*',
'dist-storybook',
],
Expand Down
6 changes: 3 additions & 3 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"types": "dist/types/index.d.ts",
"exports": {
"./loader": {
"types": "./loader/index.d.ts",
"import": "./loader/index.js",
"require": "./loader/index.cjs.js"
"types": "./dist/loader/index.d.ts",
"import": "./dist/loader/index.js",
"require": "./dist/loader/index.cjs.js"
},
".": {
"types": "./dist/types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"dependsOn": ["^build", "cached:build:stencil"],
"executor": "nx:run-commands",
"options": {
"command": "rm ./loader/package.json",
"command": "rm ./dist/loader/package.json",
"cwd": "packages/atomic"
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/atomic/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export const config: Config = {
{
type: 'dist',
collectionDir: null,
esmLoaderPath: '../loader',
copy: [
{src: 'themes'},
{
Expand Down

0 comments on commit 1ba3b64

Please sign in to comment.