Skip to content

Commit 1fb7d59

Browse files
authored
chore: harden vite externals to prevent CJS-in-ESM bundling (#4946)
* chore: harden vite externals to prevent CJS-in-ESM bundling Apply the same external shape used by eds-tokens-sync (#4883) to the remaining vite configs so a transitive dep importing node: built-ins (or bare-name built-ins) can't be silently bundled into ESM output: - eds-tokens-build: replace explicit node:* with /^node:/ regex; add bare-name fs, os, crypto, process - eds-tokens/vite.generate-variables: add /^node:/ regex and process - eds-color-palette-generator: replace explicit node:* with /^node:/ regex; add bare-name fs, path, os, crypto, process Builds verified: dist/ output is byte-identical against pre-change baseline for all three packages. Closes #4886 * chore: align eds-tokens-sync externals with the four-config canonical shape Add 'crypto' and 'process' to the bare-name list so all four vite configs share the same Node built-in external shape, addressing the consistency nit raised in PR #4946 review. Dist output is byte-identical to pre-change baseline.
1 parent e9e7bc1 commit 1fb7d59

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

apps/eds-color-palette-generator/vite.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export default defineConfig({
1212
},
1313
rolldownOptions: {
1414
external: [
15-
'node:fs',
16-
'node:fs/promises',
17-
'node:path',
18-
'node:process',
15+
/^node:/,
16+
'fs',
17+
'path',
18+
'os',
19+
'crypto',
20+
'process',
1921
'colorjs.io',
2022
'colorjs.io/fn',
2123
],

packages/eds-tokens-build/vite.config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ export default defineConfig({
4848
},
4949
rolldownOptions: {
5050
external: [
51-
'node:fs',
52-
'node:fs/promises',
53-
'node:path',
54-
'node:process',
51+
/^node:/,
52+
'fs',
5553
'path',
54+
'os',
55+
'crypto',
56+
'process',
5657
'style-dictionary',
5758
'style-dictionary/types',
5859
'style-dictionary/utils',

packages/eds-tokens-sync/vite.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ export default defineConfig({
1919
formats: ['es'],
2020
},
2121
rolldownOptions: {
22-
external: [/^node:/, 'fs', 'path', 'os', 'dotenv', 'dotenv/config'],
22+
external: [
23+
/^node:/,
24+
'fs',
25+
'path',
26+
'os',
27+
'crypto',
28+
'process',
29+
'dotenv',
30+
'dotenv/config',
31+
],
2332
},
2433
},
2534
plugins: [dts({ bundleTypes: true })],

packages/eds-tokens/vite.generate-variables.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export default defineConfig({
1212
dir: 'build-generate-variables',
1313
},
1414
external: [
15+
/^node:/,
1516
'fs',
1617
'path',
1718
'os',
1819
'crypto',
20+
'process',
1921
'style-dictionary',
2022
'style-dictionary-utils',
2123
'@equinor/eds-tokens-sync',

0 commit comments

Comments
 (0)