Skip to content

Commit

Permalink
chore: convert externalpackagemappings script to js (#4907)
Browse files Browse the repository at this point in the history
This PR converts the externalpackagemappings script to js for easier
reuse in other packages

https://coveord.atlassian.net/browse/KIT-3905
  • Loading branch information
fpbrault authored Jan 28, 2025
1 parent fe1f002 commit 6aa41a8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/atomic/.storybook/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {StorybookConfig} from '@storybook/web-components-vite';
import path from 'path';
import {PluginImpl} from 'rollup';
import {mergeConfig} from 'vite';
import {generateExternalPackageMappings} from '../scripts/externalPackageMappings';
import {generateExternalPackageMappings} from '../scripts/externalPackageMappings.mjs';

const externalizeDependencies: PluginImpl = () => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import path from 'node:path';
import buenoJson from '../../bueno/package.json';
import headlessJson from '../../headless/package.json';
import {readFileSync} from 'fs';
import path from 'path';

const buenoJsonPath = new URL('../../bueno/package.json', import.meta.url);
const buenoJson = JSON.parse(readFileSync(buenoJsonPath, 'utf-8'));

const headlessJsonPath = new URL(
'../../headless/package.json',
import.meta.url
);
const headlessJson = JSON.parse(readFileSync(headlessJsonPath, 'utf-8'));

const isNightly = process.env.IS_NIGHTLY === 'true';

Expand All @@ -12,9 +20,7 @@ const buenoVersion = isNightly
? `v${buenoJson.version.split('.').shift()}-nightly`
: 'v' + buenoJson.version;

export function generateExternalPackageMappings(basePath: string): {
[key: string]: {devWatch: string; cdn: string};
} {
export function generateExternalPackageMappings(basePath) {
return {
'@coveo/headless/commerce': {
devWatch: path.resolve(
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import html from 'rollup-plugin-html';
import {inlineSvg} from 'stencil-inline-svg';
import tailwind from 'tailwindcss';
import tailwindNesting from 'tailwindcss/nesting';
import {generateExternalPackageMappings} from './scripts/externalPackageMappings';
import {generateExternalPackageMappings} from './scripts/externalPackageMappings.mjs';
import {generateAngularModuleDefinition as angularModule} from './stencil-plugin/atomic-angular-module';

const isProduction = process.env.BUILD === 'production';
Expand Down
3 changes: 1 addition & 2 deletions packages/atomic/tsconfig.storybook.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
".storybook/*.tsx",
".storybook/*.jsx",
".storybook/register.tsx",
".storybook/main.mts",
"scripts/externalPackageMappings.ts"
".storybook/main.mts"
]
}
2 changes: 1 addition & 1 deletion packages/samples/headless-commerce-react/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import react from '@vitejs/plugin-react';
import {defineConfig} from 'vite';
import {viteStaticCopy} from 'vite-plugin-static-copy';
import {generateExternalPackageMappings} from '../../atomic/scripts/externalPackageMappings';
import {generateExternalPackageMappings} from '../../atomic/scripts/externalPackageMappings.mjs';
import buenoJson from '../../bueno/package.json';
import headlessJson from '../../headless/package.json';

Expand Down

0 comments on commit 6aa41a8

Please sign in to comment.