@wyw-in-js/transform 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/esm/cache.js +47 -6
  2. package/esm/cache.js.map +1 -1
  3. package/esm/module.js +2 -2
  4. package/esm/module.js.map +1 -1
  5. package/esm/options/buildOptions.js +23 -2
  6. package/esm/options/buildOptions.js.map +1 -1
  7. package/esm/options/buildOptions.test.js +97 -0
  8. package/esm/options/buildOptions.test.js.map +1 -1
  9. package/esm/plugins/shaker.js +87 -9
  10. package/esm/plugins/shaker.js.map +1 -1
  11. package/esm/transform/Entrypoint.helpers.js +8 -1
  12. package/esm/transform/Entrypoint.helpers.js.map +1 -1
  13. package/esm/transform/Entrypoint.js +5 -3
  14. package/esm/transform/Entrypoint.js.map +1 -1
  15. package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
  16. package/esm/transform/actions/BaseAction.js +1 -1
  17. package/esm/transform/actions/BaseAction.js.map +1 -1
  18. package/esm/transform/generators/processImports.js +53 -0
  19. package/esm/transform/generators/processImports.js.map +1 -1
  20. package/esm/transform/generators/resolveImports.js +2 -2
  21. package/esm/transform/generators/resolveImports.js.map +1 -1
  22. package/esm/utils/importOverrides.js +60 -0
  23. package/esm/utils/importOverrides.js.map +1 -1
  24. package/esm/vm/createVmContext.js +48 -16
  25. package/esm/vm/createVmContext.js.map +1 -1
  26. package/lib/cache.js +47 -7
  27. package/lib/cache.js.map +1 -1
  28. package/lib/module.js +2 -2
  29. package/lib/module.js.map +1 -1
  30. package/lib/options/buildOptions.js +23 -3
  31. package/lib/options/buildOptions.js.map +1 -1
  32. package/lib/options/buildOptions.test.js +97 -0
  33. package/lib/options/buildOptions.test.js.map +1 -1
  34. package/lib/plugins/shaker.js +88 -9
  35. package/lib/plugins/shaker.js.map +1 -1
  36. package/lib/transform/Entrypoint.helpers.js +8 -1
  37. package/lib/transform/Entrypoint.helpers.js.map +1 -1
  38. package/lib/transform/Entrypoint.js +5 -3
  39. package/lib/transform/Entrypoint.js.map +1 -1
  40. package/lib/transform/EvaluatedEntrypoint.js.map +1 -1
  41. package/lib/transform/actions/BaseAction.js +1 -1
  42. package/lib/transform/actions/BaseAction.js.map +1 -1
  43. package/lib/transform/generators/processImports.js +53 -0
  44. package/lib/transform/generators/processImports.js.map +1 -1
  45. package/lib/transform/generators/resolveImports.js +1 -1
  46. package/lib/transform/generators/resolveImports.js.map +1 -1
  47. package/lib/utils/importOverrides.js +62 -0
  48. package/lib/utils/importOverrides.js.map +1 -1
  49. package/lib/vm/createVmContext.js +48 -16
  50. package/lib/vm/createVmContext.js.map +1 -1
  51. package/package.json +5 -4
  52. package/types/cache.d.ts +2 -1
  53. package/types/cache.js +48 -6
  54. package/types/module.js +1 -1
  55. package/types/options/buildOptions.js +29 -2
  56. package/types/plugins/shaker.js +104 -9
  57. package/types/transform/Entrypoint.helpers.js +10 -1
  58. package/types/transform/Entrypoint.js +5 -3
  59. package/types/transform/EvaluatedEntrypoint.d.ts +2 -0
  60. package/types/transform/EvaluatedEntrypoint.js +1 -0
  61. package/types/transform/actions/BaseAction.js +1 -1
  62. package/types/transform/generators/processImports.js +70 -0
  63. package/types/transform/generators/resolveImports.js +1 -1
  64. package/types/utils/importOverrides.d.ts +2 -1
  65. package/types/utils/importOverrides.js +63 -0
  66. package/types/vm/createVmContext.js +61 -13
@@ -40,5 +40,102 @@ describe('buildOptions', () => {
40
40
  presets: ['preset-a', 'preset-b']
41
41
  });
42
42
  });
43
+ it('does not treat pnpm store paths as a single ".pnpm" package', async () => {
44
+ const {
45
+ buildOptions
46
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('./buildOptions')));
47
+ const typescriptPath = '/project/node_modules/.pnpm/@babel+plugin-transform-typescript@7.25.9/node_modules/@babel/plugin-transform-typescript/lib/index.js';
48
+ const reactJsxPath = '/project/node_modules/.pnpm/@babel+plugin-transform-react-jsx@7.25.9/node_modules/@babel/plugin-transform-react-jsx/lib/index.js';
49
+ const merged = buildOptions({
50
+ plugins: [[typescriptPath, {
51
+ foo: true
52
+ }]]
53
+ }, {
54
+ plugins: [[reactJsxPath, {
55
+ bar: true
56
+ }]]
57
+ });
58
+ expect(merged.plugins).toEqual([[typescriptPath, {
59
+ foo: true
60
+ }], [reactJsxPath, {
61
+ bar: true
62
+ }]]);
63
+ });
64
+ it('still recognizes pnpm store paths as Babel plugin keys (Windows path)', async () => {
65
+ const {
66
+ buildOptions
67
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('./buildOptions')));
68
+ const typescriptWindowsPath = 'C:\\project\\node_modules\\.pnpm\\@babel+plugin-transform-typescript@7.25.9\\node_modules\\@babel\\plugin-transform-typescript\\lib\\index.js';
69
+ const merged = buildOptions({
70
+ plugins: [['@babel/plugin-transform-typescript', {
71
+ foo: true
72
+ }]]
73
+ }, {
74
+ plugins: [[typescriptWindowsPath, {
75
+ bar: true
76
+ }]]
77
+ });
78
+ expect(merged.plugins).toEqual([['@babel/plugin-transform-typescript', {
79
+ foo: true,
80
+ bar: true
81
+ }]]);
82
+ });
83
+ it('extracts real package names from pnpm store paths', async () => {
84
+ const {
85
+ buildOptions
86
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('./buildOptions')));
87
+ const typescriptPath = '/project/node_modules/.pnpm/@babel+plugin-transform-typescript@7.25.9/node_modules/@babel/plugin-transform-typescript/lib/index.js';
88
+ const merged = buildOptions({
89
+ plugins: [['@babel/plugin-transform-typescript', {
90
+ foo: true
91
+ }]]
92
+ }, {
93
+ plugins: [[typescriptPath, {
94
+ bar: true
95
+ }]]
96
+ });
97
+ expect(merged.plugins).toEqual([['@babel/plugin-transform-typescript', {
98
+ foo: true,
99
+ bar: true
100
+ }]]);
101
+ });
102
+ it('extracts package names from node_modules paths', async () => {
103
+ const {
104
+ buildOptions
105
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('./buildOptions')));
106
+ const pluginPath = '/project/node_modules/my-plugin/lib/index.js';
107
+ const merged = buildOptions({
108
+ plugins: [['my-plugin', {
109
+ foo: true
110
+ }]]
111
+ }, {
112
+ plugins: [[pluginPath, {
113
+ bar: true
114
+ }]]
115
+ });
116
+ expect(merged.plugins).toEqual([['my-plugin', {
117
+ foo: true,
118
+ bar: true
119
+ }]]);
120
+ });
121
+ it('extracts the innermost package name from nested node_modules paths', async () => {
122
+ const {
123
+ buildOptions
124
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('./buildOptions')));
125
+ const pluginPath = '/project/node_modules/wrapper/node_modules/inner-plugin/lib/index.js';
126
+ const merged = buildOptions({
127
+ plugins: [['inner-plugin', {
128
+ foo: true
129
+ }]]
130
+ }, {
131
+ plugins: [[pluginPath, {
132
+ bar: true
133
+ }]]
134
+ });
135
+ expect(merged.plugins).toEqual([['inner-plugin', {
136
+ foo: true,
137
+ bar: true
138
+ }]]);
139
+ });
43
140
  });
44
141
  //# sourceMappingURL=buildOptions.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildOptions.test.js","names":["describe","it","buildOptions","Promise","resolve","then","_interopRequireWildcard","require","expect","presets","not","toThrow","assumptions","setPublicClassFields","parserOpts","plugins","toEqual"],"sources":["../../src/options/buildOptions.test.ts"],"sourcesContent":["describe('buildOptions', () => {\n it('does not crash when @babel/core resolvePreset returns an object (Babel 7.25.7 regression)', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n expect(() =>\n buildOptions({\n presets: ['@babel/preset-typescript', '@babel/preset-react'],\n })\n ).not.toThrow();\n });\n\n it('merges configs deeply and preserves presets/plugins arrays', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n expect(\n buildOptions(\n {\n assumptions: { setPublicClassFields: true },\n parserOpts: { plugins: ['typescript'] },\n presets: ['preset-a'],\n },\n {\n assumptions: { setPublicClassFields: false },\n parserOpts: { plugins: ['jsx'] },\n presets: ['preset-b'],\n }\n )\n ).toEqual({\n assumptions: { setPublicClassFields: false },\n parserOpts: { plugins: ['typescript', 'jsx'] },\n presets: ['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","it","buildOptions","Promise","resolve","then","_interopRequireWildcard","require","expect","presets","not","toThrow","assumptions","setPublicClassFields","parserOpts","plugins","toEqual","typescriptPath","reactJsxPath","merged","foo","bar","typescriptWindowsPath","pluginPath"],"sources":["../../src/options/buildOptions.test.ts"],"sourcesContent":["describe('buildOptions', () => {\n it('does not crash when @babel/core resolvePreset returns an object (Babel 7.25.7 regression)', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n expect(() =>\n buildOptions({\n presets: ['@babel/preset-typescript', '@babel/preset-react'],\n })\n ).not.toThrow();\n });\n\n it('merges configs deeply and preserves presets/plugins arrays', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n expect(\n buildOptions(\n {\n assumptions: { setPublicClassFields: true },\n parserOpts: { plugins: ['typescript'] },\n presets: ['preset-a'],\n },\n {\n assumptions: { setPublicClassFields: false },\n parserOpts: { plugins: ['jsx'] },\n presets: ['preset-b'],\n }\n )\n ).toEqual({\n assumptions: { setPublicClassFields: false },\n parserOpts: { plugins: ['typescript', 'jsx'] },\n presets: ['preset-a', 'preset-b'],\n });\n });\n\n it('does not treat pnpm store paths as a single \".pnpm\" package', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n const typescriptPath =\n '/project/node_modules/.pnpm/@babel+plugin-transform-typescript@7.25.9/node_modules/@babel/plugin-transform-typescript/lib/index.js';\n const reactJsxPath =\n '/project/node_modules/.pnpm/@babel+plugin-transform-react-jsx@7.25.9/node_modules/@babel/plugin-transform-react-jsx/lib/index.js';\n\n const merged = buildOptions(\n {\n plugins: [[typescriptPath, { foo: true }]],\n },\n {\n plugins: [[reactJsxPath, { bar: true }]],\n }\n );\n\n expect(merged.plugins).toEqual([\n [typescriptPath, { foo: true }],\n [reactJsxPath, { bar: true }],\n ]);\n });\n\n it('still recognizes pnpm store paths as Babel plugin keys (Windows path)', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n const typescriptWindowsPath =\n 'C:\\\\project\\\\node_modules\\\\.pnpm\\\\@babel+plugin-transform-typescript@7.25.9\\\\node_modules\\\\@babel\\\\plugin-transform-typescript\\\\lib\\\\index.js';\n\n const merged = buildOptions(\n {\n plugins: [['@babel/plugin-transform-typescript', { foo: true }]],\n },\n {\n plugins: [[typescriptWindowsPath, { bar: true }]],\n }\n );\n\n expect(merged.plugins).toEqual([\n ['@babel/plugin-transform-typescript', { foo: true, bar: true }],\n ]);\n });\n\n it('extracts real package names from pnpm store paths', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n const typescriptPath =\n '/project/node_modules/.pnpm/@babel+plugin-transform-typescript@7.25.9/node_modules/@babel/plugin-transform-typescript/lib/index.js';\n\n const merged = buildOptions(\n {\n plugins: [['@babel/plugin-transform-typescript', { foo: true }]],\n },\n {\n plugins: [[typescriptPath, { bar: true }]],\n }\n );\n\n expect(merged.plugins).toEqual([\n ['@babel/plugin-transform-typescript', { foo: true, bar: true }],\n ]);\n });\n\n it('extracts package names from node_modules paths', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n const pluginPath = '/project/node_modules/my-plugin/lib/index.js';\n\n const merged = buildOptions(\n {\n plugins: [['my-plugin', { foo: true }]],\n },\n {\n plugins: [[pluginPath, { bar: true }]],\n }\n );\n\n expect(merged.plugins).toEqual([['my-plugin', { foo: true, bar: true }]]);\n });\n\n it('extracts the innermost package name from nested node_modules paths', async () => {\n const { buildOptions } = await import('./buildOptions');\n\n const pluginPath =\n '/project/node_modules/wrapper/node_modules/inner-plugin/lib/index.js';\n\n const merged = buildOptions(\n {\n plugins: [['inner-plugin', { foo: true }]],\n },\n {\n plugins: [[pluginPath, { bar: true }]],\n }\n );\n\n expect(merged.plugins).toEqual([\n ['inner-plugin', { foo: true, bar: true }],\n ]);\n });\n});\n"],"mappings":";;;AAAAA,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BC,EAAE,CAAC,2FAA2F,EAAE,YAAY;IAC1G,MAAM;MAAEC;IAAa,CAAC,GAAG,MAAAC,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAA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B,UAAU,GACd,sEAAsE;IAExE,MAAMJ,MAAM,GAAGjB,YAAY,CACzB;MACEa,OAAO,EAAE,CAAC,CAAC,cAAc,EAAE;QAAEK,GAAG,EAAE;MAAK,CAAC,CAAC;IAC3C,CAAC,EACD;MACEL,OAAO,EAAE,CAAC,CAACQ,UAAU,EAAE;QAAEF,GAAG,EAAE;MAAK,CAAC,CAAC;IACvC,CACF,CAAC;IAEDb,MAAM,CAACW,MAAM,CAACJ,OAAO,CAAC,CAACC,OAAO,CAAC,CAC7B,CAAC,cAAc,EAAE;MAAEI,GAAG,EAAE,IAAI;MAAEC,GAAG,EAAE;IAAK,CAAC,CAAC,CAC3C,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -14,6 +14,7 @@ var _traversalCache = require("../utils/traversalCache");
14
14
  var _parseRequest = require("../utils/parseRequest");
15
15
  var _importOverrides = require("../utils/importOverrides");
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ const warnedDynamicImportFiles = new Set();
17
18
  function getNonParamBinding(exportPath, name) {
18
19
  var _exportPath$scope$par, _exportPath$scope$par2;
19
20
  const binding = exportPath.scope.getBinding(name);
@@ -162,13 +163,13 @@ function shakerPlugin(babel, {
162
163
  }
163
164
  const cache = new Map();
164
165
  return source => {
165
- var _importOverrides$sour;
166
+ var _getImportOverride;
166
167
  const cached = cache.get(source);
167
168
  if (cached !== undefined) {
168
169
  return cached;
169
170
  }
170
171
  const strippedSource = (0, _parseRequest.stripQueryAndHash)(source);
171
- const direct = (_importOverrides$sour = importOverrides[source]) !== null && _importOverrides$sour !== void 0 ? _importOverrides$sour : strippedSource !== source ? importOverrides[strippedSource] : null;
172
+ const direct = (_getImportOverride = (0, _importOverrides.getImportOverride)(importOverrides, source)) !== null && _getImportOverride !== void 0 ? _getImportOverride : strippedSource !== source ? (0, _importOverrides.getImportOverride)(importOverrides, strippedSource) : null;
172
173
  if (direct) {
173
174
  const result = shouldKeepOverride(direct);
174
175
  cache.set(source, result);
@@ -188,7 +189,7 @@ function shakerPlugin(babel, {
188
189
  resolved,
189
190
  root
190
191
  });
191
- const override = importOverrides[key];
192
+ const override = (0, _importOverrides.getImportOverride)(importOverrides, key);
192
193
  const result = shouldKeepOverride(override);
193
194
  cache.set(source, result);
194
195
  return result;
@@ -199,8 +200,11 @@ function shakerPlugin(babel, {
199
200
  };
200
201
  })();
201
202
  const collected = (0, _collectExportsAndImports.collectExportsAndImports)(file.path);
202
- const sideEffectImports = collected.imports.filter(_collectExportsAndImports.sideEffectImport);
203
- log('import-and-exports', [`imports: ${collected.imports.length} (side-effects: ${sideEffectImports.length})`, `exports: ${Object.values(collected.exports).length}`, `reexports: ${collected.reexports.length}`].join(', '));
203
+ const {
204
+ imports
205
+ } = collected;
206
+ const sideEffectImports = imports.filter(_collectExportsAndImports.sideEffectImport);
207
+ log('import-and-exports', [`imports: ${imports.length} (side-effects: ${sideEffectImports.length})`, `exports: ${Object.values(collected.exports).length}`, `reexports: ${collected.reexports.length}`].join(', '));
204
208
 
205
209
  // We cannot just throw out exports if they are referred in the code
206
210
  // Let's dome some replacements
@@ -241,7 +245,7 @@ function shakerPlugin(babel, {
241
245
  // See example in shaker-plugin.test.ts
242
246
  // Real-world example was found in preact/compat npm package
243
247
  if (onlyExportsSet.has('default') && hasDefault && !collected.isEsModule) {
244
- this.imports = collected.imports;
248
+ this.imports = imports;
245
249
  this.exports = exports;
246
250
  this.reexports = collected.reexports;
247
251
  this.deadExports = [];
@@ -251,7 +255,7 @@ function shakerPlugin(babel, {
251
255
  // __esModule should be kept alive
252
256
  onlyExportsSet.add('__esModule');
253
257
  const aliveExports = new Set();
254
- const importNames = collected.imports.map(({
258
+ const importNames = imports.map(({
255
259
  imported
256
260
  }) => imported);
257
261
  Object.entries(exports).forEach(([exported, local]) => {
@@ -303,7 +307,7 @@ function shakerPlugin(babel, {
303
307
  });
304
308
  }
305
309
  if (ifUnknownExport === 'skip-shaking') {
306
- this.imports = collected.imports;
310
+ this.imports = imports;
307
311
  this.exports = exports;
308
312
  this.reexports = collected.reexports;
309
313
  this.deadExports = [];
@@ -426,7 +430,7 @@ function shakerPlugin(babel, {
426
430
  }
427
431
  }
428
432
  }
429
- this.imports = withoutRemoved(collected.imports);
433
+ this.imports = withoutRemoved(imports);
430
434
  this.exports = {};
431
435
  this.deadExports = [];
432
436
  Object.entries(exports).forEach(([exported, local]) => {
@@ -441,6 +445,81 @@ function shakerPlugin(babel, {
441
445
  visitor: {},
442
446
  post(file) {
443
447
  const log = shakerLogger.extend((0, _getFileIdx.getFileIdx)(file.opts.filename));
448
+ const dynamicImportWarningsEnabled = Boolean(process.env.WYW_WARN_DYNAMIC_IMPORTS) && process.env.WYW_WARN_DYNAMIC_IMPORTS !== '0' && process.env.WYW_WARN_DYNAMIC_IMPORTS !== 'false';
449
+ const filename = file.opts.filename;
450
+ if (dynamicImportWarningsEnabled && !warnedDynamicImportFiles.has(filename)) {
451
+ const dynamicImports = this.imports.filter(imp => !(0, _collectExportsAndImports.sideEffectImport)(imp) && imp.type === 'dynamic');
452
+ if (dynamicImports.length > 0) {
453
+ const sources = Array.from(new Set(dynamicImports.map(imp => imp.source))).sort();
454
+ const sourcesToWarn = (() => {
455
+ if (!importOverrides || Object.keys(importOverrides).length === 0) {
456
+ return sources;
457
+ }
458
+ const shouldWarn = source => {
459
+ var _getImportOverride2;
460
+ const strippedSource = (0, _parseRequest.stripQueryAndHash)(source);
461
+ const direct = (_getImportOverride2 = (0, _importOverrides.getImportOverride)(importOverrides, source)) !== null && _getImportOverride2 !== void 0 ? _getImportOverride2 : strippedSource !== source ? (0, _importOverrides.getImportOverride)(importOverrides, strippedSource) : undefined;
462
+ if (direct !== undefined) {
463
+ return false;
464
+ }
465
+ const isFileImport = strippedSource.startsWith('.') || _path.default.isAbsolute(strippedSource);
466
+ if (!isFileImport) {
467
+ return true;
468
+ }
469
+ try {
470
+ const resolved = (0, _shared.syncResolve)(strippedSource, filename, []);
471
+ const importKey = (0, _importOverrides.toImportKey)({
472
+ source: strippedSource,
473
+ resolved,
474
+ root
475
+ }).key;
476
+ return (0, _importOverrides.getImportOverride)(importOverrides, importKey) === undefined;
477
+ } catch {
478
+ return true;
479
+ }
480
+ };
481
+ return sources.filter(shouldWarn);
482
+ })();
483
+ if (sourcesToWarn.length > 0) {
484
+ warnedDynamicImportFiles.add(filename);
485
+ const overrideKeys = sourcesToWarn.map(source => {
486
+ const strippedSource = (0, _parseRequest.stripQueryAndHash)(source);
487
+ const isFileImport = strippedSource.startsWith('.') || _path.default.isAbsolute(strippedSource);
488
+ if (!isFileImport) {
489
+ return {
490
+ source,
491
+ key: source
492
+ };
493
+ }
494
+ try {
495
+ const resolved = (0, _shared.syncResolve)(strippedSource, filename, []);
496
+ return {
497
+ source,
498
+ key: (0, _importOverrides.toImportKey)({
499
+ source: strippedSource,
500
+ resolved,
501
+ root
502
+ }).key
503
+ };
504
+ } catch {
505
+ return {
506
+ source,
507
+ key: strippedSource
508
+ };
509
+ }
510
+ }).filter((item, index, array) => {
511
+ const firstIndexForKey = array.findIndex(i => i.key === item.key);
512
+ return firstIndexForKey === index;
513
+ });
514
+ const warning = [`[wyw-in-js] Dynamic imports reached prepare stage`, ``, `file: ${filename}`, `count: ${sourcesToWarn.length}`, `sources:`, ...sourcesToWarn.map(source => ` - ${source}`), ``, `note: these imports will be resolved/processed even if they are lazy (e.g. React.lazy(() => import(...)))`, ``, `tip: if the imported module is runtime-only or heavy, mock it during evaluation via importOverrides:`, ` importOverrides: {`, ...overrideKeys.map(({
515
+ key,
516
+ source
517
+ }) => ` '${key}': { mock: './path/to/mock' }, // from ${source}`), ` }`, ``, `note: importOverrides affects only build-time evaluation (it does not change your bundler runtime behavior)`].join('\n');
518
+ // eslint-disable-next-line no-console
519
+ console.warn(warning);
520
+ }
521
+ }
522
+ }
444
523
  const processedImports = new Set();
445
524
  const imports = new Map();
446
525
  const addImport = ({
@@ -1 +1 @@
1
- {"version":3,"file":"shaker.js","names":["_path","_interopRequireDefault","require","_shared","_collectExportsAndImports","_getFileIdx","_isRemoved","_scopeHelpers","_traversalCache","_parseRequest","_importOverrides","e","__esModule","default","getNonParamBinding","exportPath","name","_exportPath$scope$par","_exportPath$scope$par2","binding","scope","getBinding","kind","parent","getBindingForExport","isIdentifier","node","variableDeclarator","findParent","p","isVariableDeclarator","id","get","isAssignmentExpression","left","isFunctionDeclaration","isClassDeclaration","undefined","withoutRemoved","items","filter","local","isRemoved","rearrangeExports","types","t","root","exportRefs","exports","rearranged","rootScope","forEach","refs","_constantViolations","length","declarator","uid","generateUid","declaration","unshiftContainer","variableDeclaration","identifier","registerDeclaration","constantViolations","ref","replaced","replaceWith","isBindingIdentifier","push","reference","registerConstantViolation","assigmentToExport","expressionStatement","assignmentExpression","memberExpression","body","lastViolation","pathInRoot","find","n","isDescendant","pushed","insertAfter","getPropertyAssignmentStatement","bindingName","assignment","isMemberExpression","object","statement","parentPath","isExpressionStatement","isWithinAliveExport","aliveExports","some","alive","isAncestor","stripExportKeepDeclaration","path","exportDeclaration","isExportNamedDeclaration","isTSEnumDeclaration","isVariableDeclaration","declarators","shakerPlugin","babel","keepSideEffects","ifUnknownExport","importOverrides","onlyExports","shakerLogger","logger","extend","pre","file","filename","opts","log","getFileIdx","join","onlyExportsSet","Set","shouldKeepOverride","override","hasImportOverride","Object","keys","cache","Map","source","_importOverrides$sour","cached","strippedSource","stripQueryAndHash","direct","result","set","isFileImport","startsWith","pathLib","isAbsolute","resolved","syncResolve","key","toImportKey","collected","collectExportsAndImports","sideEffectImports","imports","sideEffectImport","values","reexports","hasWywPreval","__wywPreval","hasDefault","has","delete","size","deadExports","remove","importedAsSideEffect","isEsModule","add","importNames","map","imported","entries","exported","isImportSpecifier","isImportDefaultSpecifier","isImportNamespaceSpecifier","includes","exp","exportToPath","notFoundExports","clear","isAllExportsFound","Error","forDeleting","i","forDeletingSet","queueForDeleting","deleted","dereferenced","changed","action","findActionForNode","outerReferences","referencePaths","candidate","removableAssignmentStatements","removableOuterReferences","blockingReferences","dereference","applyAction","removeWithRelated","unreferenced","getAllBindings","referenced","violation","visitor","post","processedImports","addImport","metadata","wywEvaluator","invalidateTraversalCache"],"sources":["../../src/plugins/shaker.ts"],"sourcesContent":["import pathLib from 'path';\n\nimport type { BabelFile, PluginObj, NodePath } from '@babel/core';\nimport type { Binding } from '@babel/traverse';\nimport type {\n ExportNamedDeclaration,\n Identifier,\n MemberExpression,\n Program,\n VariableDeclarator,\n} from '@babel/types';\n\nimport { logger, syncResolve } from '@wyw-in-js/shared';\nimport type { ImportOverride, ImportOverrides } from '@wyw-in-js/shared';\n\nimport type { Core } from '../babel';\nimport type { IMetadata } from '../utils/ShakerMetadata';\nimport type { Exports, IState } from '../utils/collectExportsAndImports';\nimport {\n collectExportsAndImports,\n sideEffectImport,\n} from '../utils/collectExportsAndImports';\nimport { getFileIdx } from '../utils/getFileIdx';\nimport { isRemoved } from '../utils/isRemoved';\nimport {\n applyAction,\n dereference,\n findActionForNode,\n reference,\n removeWithRelated,\n} from '../utils/scopeHelpers';\nimport { invalidateTraversalCache } from '../utils/traversalCache';\nimport { stripQueryAndHash } from '../utils/parseRequest';\nimport { toImportKey } from '../utils/importOverrides';\n\nexport interface IShakerOptions {\n ifUnknownExport?: 'error' | 'ignore' | 'reexport-all' | 'skip-shaking';\n importOverrides?: ImportOverrides;\n keepSideEffects?: boolean;\n onlyExports: string[];\n root?: string;\n}\n\ninterface NodeWithName {\n name: string;\n}\n\nfunction getNonParamBinding(\n exportPath: NodePath,\n name: string\n): Binding | undefined {\n const binding = exportPath.scope.getBinding(name);\n if (binding && (binding.kind as string) !== 'param') {\n return binding;\n }\n\n // When `exportPath` is inside a function scope, a parameter can shadow\n // the actual export binding (e.g. `export function fallback(fallback) {}`).\n // In such cases we need the binding from the declaration scope.\n return exportPath.scope.parent?.getBinding(name) ?? binding;\n}\n\nfunction getBindingForExport(exportPath: NodePath): Binding | undefined {\n if (exportPath.isIdentifier()) {\n return getNonParamBinding(exportPath, exportPath.node.name);\n }\n\n const variableDeclarator = exportPath.findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n if (variableDeclarator) {\n const id = variableDeclarator.get('id');\n if (id.isIdentifier()) {\n return variableDeclarator.scope.getBinding(id.node.name);\n }\n }\n\n if (exportPath.isAssignmentExpression()) {\n const left = exportPath.get('left');\n if (left.isIdentifier()) {\n return getNonParamBinding(exportPath, left.node.name);\n }\n }\n\n if (exportPath.isFunctionDeclaration() || exportPath.isClassDeclaration()) {\n const { id } = exportPath.node;\n if (!id) {\n // `export default function() {}` / `export default class {}` (anonymous)\n return undefined;\n }\n return getNonParamBinding(exportPath, id.name);\n }\n\n return undefined;\n}\n\nconst withoutRemoved = <T extends { local: NodePath }>(items: T[]): T[] =>\n items.filter(({ local }) => !isRemoved(local));\n\nfunction rearrangeExports(\n { types: t }: Core,\n root: NodePath<Program>,\n exportRefs: Map<string, NodePath<MemberExpression>[]>,\n exports: Exports\n): Exports {\n const rearranged = {\n ...exports,\n };\n\n const rootScope = root.scope;\n exportRefs.forEach((refs, name) => {\n if (refs.length <= 1) {\n if (refs.length === 1) {\n // Maybe exports is assigned to another variable?\n const declarator = refs[0].findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n\n if (!declarator) {\n return;\n }\n } else {\n return;\n }\n }\n\n const uid = rootScope.generateUid(name);\n // Define variable in the beginning\n const [declaration] = root.unshiftContainer('body', [\n t.variableDeclaration('var', [t.variableDeclarator(t.identifier(uid))]),\n ]);\n\n rootScope.registerDeclaration(declaration);\n\n const constantViolations: NodePath<Identifier>[] = [];\n // Replace every reference with defined variable\n refs.forEach((ref) => {\n const [replaced] = ref.replaceWith(t.identifier(uid));\n if (replaced.isBindingIdentifier()) {\n constantViolations.push(replaced);\n } else {\n reference(replaced);\n }\n });\n\n constantViolations.forEach((id) => {\n rootScope.registerConstantViolation(id);\n });\n\n const assigmentToExport = t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.memberExpression(t.identifier('exports'), t.identifier(name)),\n t.identifier(uid)\n )\n );\n\n // export.foo = _foo will be inserted either after the last _foo assigment or in the end of the file\n const body = root.get('body');\n const lastViolation =\n constantViolations[constantViolations.length - 1] ??\n body[body.length - 1];\n const pathInRoot = root\n .get('body')\n .find((n) => lastViolation.isDescendant(n))!;\n\n const [pushed] = pathInRoot.insertAfter(assigmentToExport);\n\n const local = pushed.get('expression.right') as NodePath<Identifier>;\n reference(local);\n\n rearranged[name] = local;\n });\n\n return rearranged;\n}\n\nconst getPropertyAssignmentStatement = (\n ref: NodePath,\n bindingName: string\n): NodePath | null => {\n const assignment = ref.findParent((parent) =>\n parent.isAssignmentExpression()\n );\n if (!assignment?.isAssignmentExpression()) return null;\n\n const left = assignment.get('left');\n if (!left.isMemberExpression()) return null;\n\n const object = left.get('object');\n if (!object.isIdentifier({ name: bindingName })) return null;\n\n const statement = assignment.parentPath;\n return statement?.isExpressionStatement() ? statement : null;\n};\n\nconst isWithinAliveExport = (\n ref: NodePath,\n aliveExports: Set<NodePath>\n): boolean =>\n [...aliveExports].some((alive) => alive === ref || alive.isAncestor(ref));\n\nfunction stripExportKeepDeclaration(path: NodePath): boolean {\n const exportDeclaration = path.findParent((p) =>\n p.isExportNamedDeclaration()\n ) as NodePath<ExportNamedDeclaration> | null;\n if (!exportDeclaration) return false;\n\n const declaration = exportDeclaration.get('declaration');\n if (!declaration.node) return false;\n\n if (\n declaration.isFunctionDeclaration() ||\n declaration.isClassDeclaration() ||\n declaration.isTSEnumDeclaration()\n ) {\n exportDeclaration.replaceWith(declaration.node);\n return true;\n }\n\n if (declaration.isVariableDeclaration()) {\n const declarators = declaration.get('declarations');\n if (declarators.length !== 1) {\n return false;\n }\n\n exportDeclaration.replaceWith(declaration.node);\n return true;\n }\n\n return false;\n}\n\nexport default function shakerPlugin(\n babel: Core,\n {\n keepSideEffects = false,\n ifUnknownExport = 'skip-shaking',\n importOverrides,\n onlyExports,\n root,\n }: IShakerOptions\n): PluginObj<IState & { filename: string }> {\n const shakerLogger = logger.extend('shaker');\n\n return {\n name: '@wyw-in-js/transform/shaker',\n pre(file: BabelFile) {\n this.filename = file.opts.filename!;\n const log = shakerLogger.extend(getFileIdx(this.filename));\n\n log('start', `${this.filename}, onlyExports: ${onlyExports.join(',')}`);\n const onlyExportsSet = new Set(onlyExports);\n\n const shouldKeepOverride = (\n override: ImportOverride | undefined\n ): boolean => !!override && ('mock' in override || 'noShake' in override);\n\n const hasImportOverride = (() => {\n if (!importOverrides || Object.keys(importOverrides).length === 0) {\n return () => false;\n }\n\n const cache = new Map<string, boolean>();\n\n return (source: string): boolean => {\n const cached = cache.get(source);\n if (cached !== undefined) {\n return cached;\n }\n\n const strippedSource = stripQueryAndHash(source);\n\n const direct =\n importOverrides[source] ??\n (strippedSource !== source\n ? importOverrides[strippedSource]\n : null);\n if (direct) {\n const result = shouldKeepOverride(direct);\n cache.set(source, result);\n return result;\n }\n\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n if (!isFileImport) {\n cache.set(source, false);\n return false;\n }\n\n try {\n const resolved = syncResolve(strippedSource, this.filename, []);\n const { key } = toImportKey({\n source: strippedSource,\n resolved,\n root,\n });\n const override = importOverrides[key];\n const result = shouldKeepOverride(override);\n cache.set(source, result);\n return result;\n } catch {\n cache.set(source, false);\n return false;\n }\n };\n })();\n\n const collected = collectExportsAndImports(file.path);\n const sideEffectImports = collected.imports.filter(sideEffectImport);\n log(\n 'import-and-exports',\n [\n `imports: ${collected.imports.length} (side-effects: ${sideEffectImports.length})`,\n `exports: ${Object.values(collected.exports).length}`,\n `reexports: ${collected.reexports.length}`,\n ].join(', ')\n );\n\n // We cannot just throw out exports if they are referred in the code\n // Let's dome some replacements\n const exports = rearrangeExports(\n babel,\n file.path,\n collected.exportRefs,\n collected.exports\n );\n\n Object.values(exports).forEach((local) => {\n if (local.isAssignmentExpression()) {\n const left = local.get('left');\n if (left.isIdentifier()) {\n // For some reason babel does not mark id in AssignmentExpression as a reference\n // So we need to do it manually\n reference(left, left, true);\n }\n }\n });\n\n const hasWywPreval = exports.__wywPreval !== undefined;\n const hasDefault = exports.default !== undefined;\n\n // If __wywPreval is not exported, we can remove it from onlyExports\n if (onlyExportsSet.has('__wywPreval') && !hasWywPreval) {\n onlyExportsSet.delete('__wywPreval');\n }\n\n if (onlyExportsSet.size === 0) {\n // Fast-lane: if there are no exports to keep, we can just shake out the whole file\n this.imports = [];\n this.exports = {};\n this.reexports = [];\n this.deadExports = Object.keys(exports);\n\n file.path.get('body').forEach((p) => {\n p.remove();\n });\n\n return;\n }\n\n const importedAsSideEffect = onlyExportsSet.has('side-effect');\n onlyExportsSet.delete('side-effect');\n\n // Hackaround for packages which include a 'default' export without specifying __esModule; such packages cannot be\n // shaken as they will break interopRequireDefault babel helper\n // See example in shaker-plugin.test.ts\n // Real-world example was found in preact/compat npm package\n if (\n onlyExportsSet.has('default') &&\n hasDefault &&\n !collected.isEsModule\n ) {\n this.imports = collected.imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n return;\n }\n\n if (!onlyExportsSet.has('*')) {\n // __esModule should be kept alive\n onlyExportsSet.add('__esModule');\n\n const aliveExports = new Set<NodePath>();\n const importNames = collected.imports.map(({ imported }) => imported);\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (onlyExportsSet.has(exported)) {\n aliveExports.add(local);\n return;\n }\n\n const binding =\n local.isIdentifier() && local.scope.getBinding(local.node.name);\n\n if (\n binding &&\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n importNames.includes((local.node as NodeWithName).name || '')\n ) {\n aliveExports.add(local);\n return;\n }\n\n if ([...aliveExports].some((alive) => alive === local)) {\n // It's possible to export multiple values from a single variable initializer, e.g\n // export const { foo, bar } = baz();\n // We need to treat all of them as used if any of them are used, since otherwise\n // we'll attempt to delete the baz() call\n aliveExports.add(local);\n }\n });\n\n collected.reexports.forEach((exp) => {\n if (onlyExportsSet.has(exp.exported)) {\n aliveExports.add(exp.local);\n }\n });\n\n const exportToPath = new Map<string, NodePath>();\n Object.entries(exports).forEach(([exported, local]) => {\n exportToPath.set(exported, local);\n });\n\n collected.reexports.forEach((exp) => {\n exportToPath.set(exp.exported, exp.local);\n });\n\n const notFoundExports = [...onlyExportsSet].filter(\n (exp) =>\n exp !== '__esModule' && !aliveExports.has(exportToPath.get(exp)!)\n );\n exportToPath.clear();\n\n const isAllExportsFound = notFoundExports.length === 0;\n if (!isAllExportsFound && ifUnknownExport !== 'ignore') {\n if (ifUnknownExport === 'error') {\n throw new Error(\n `Unknown export(s) requested: ${onlyExports.join(',')}`\n );\n }\n\n if (ifUnknownExport === 'reexport-all') {\n // If there are unknown exports, we have keep alive all re-exports.\n if (exports['*'] !== undefined) {\n aliveExports.add(exports['*']);\n }\n\n collected.reexports.forEach((exp) => {\n if (exp.exported === '*') {\n aliveExports.add(exp.local);\n }\n });\n }\n\n if (ifUnknownExport === 'skip-shaking') {\n this.imports = collected.imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n\n return;\n }\n }\n\n const forDeleting = [\n ...Object.values(exports),\n ...collected.reexports.map((i) => i.local),\n ].filter((exp) => !aliveExports.has(exp));\n\n const forDeletingSet = new Set<NodePath>(forDeleting);\n const queueForDeleting = (path: NodePath): boolean => {\n if (isRemoved(path) || forDeletingSet.has(path)) {\n return false;\n }\n\n forDeletingSet.add(path);\n forDeleting.push(path);\n return true;\n };\n\n if (!keepSideEffects && !importedAsSideEffect) {\n // Drop side-effect imports for eval-only builds unless they were explicitly requested.\n // This prevents evaluating unrelated runtime code (e.g. Radix) during __wywPreval eval.\n sideEffectImports.forEach((i) => {\n if (hasImportOverride(i.source)) {\n return;\n }\n\n queueForDeleting(i.local);\n });\n }\n\n const deleted = new Set<NodePath>();\n\n let dereferenced: NodePath<Identifier>[] = [];\n let changed = true;\n while (changed) {\n changed = false;\n // eslint-disable-next-line no-restricted-syntax\n for (const path of forDeleting) {\n if (deleted.has(path)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const binding = getBindingForExport(path);\n const action = findActionForNode(path);\n const parent = action?.[1];\n const outerReferences = (binding?.referencePaths || []).filter(\n (ref) => {\n if (ref === parent || parent?.isAncestor(ref)) {\n return false;\n }\n\n return !forDeleting.some(\n (candidate) =>\n candidate !== path &&\n !isRemoved(candidate) &&\n (candidate === ref || candidate.isAncestor(ref))\n );\n }\n );\n const bindingName = binding?.identifier.name;\n const removableAssignmentStatements = new Set<NodePath>();\n const removableOuterReferences = outerReferences.filter((ref) => {\n if (!bindingName) return false;\n const statement = getPropertyAssignmentStatement(\n ref,\n bindingName\n );\n if (!statement || isWithinAliveExport(statement, aliveExports)) {\n return false;\n }\n\n removableAssignmentStatements.add(statement);\n return true;\n });\n\n const blockingReferences = outerReferences.filter(\n (ref) => !removableOuterReferences.includes(ref)\n );\n\n if (blockingReferences.length > 0 && path.isIdentifier()) {\n // Temporary deref it in order to simplify further checks.\n dereference(path);\n dereferenced.push(path);\n }\n\n if (\n !deleted.has(path) &&\n binding &&\n blockingReferences.length > 0 &&\n stripExportKeepDeclaration(path)\n ) {\n deleted.add(path);\n changed = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (\n !deleted.has(path) &&\n (!binding || blockingReferences.length === 0)\n ) {\n if (removableAssignmentStatements.size > 0) {\n for (const statement of removableAssignmentStatements) {\n if (queueForDeleting(statement)) {\n changed = true;\n }\n }\n }\n\n if (action) {\n applyAction(action);\n } else {\n removeWithRelated([path]);\n }\n\n deleted.add(path);\n changed = true;\n }\n }\n\n dereferenced.forEach((path) => {\n // If path is still alive, we need to reference it back\n if (!isRemoved(path)) {\n reference(path);\n }\n });\n\n dereferenced = [];\n\n // Find and mark for deleting all unreferenced variables\n const unreferenced = Object.values(\n file.scope.getAllBindings()\n ).filter((i) => !i.referenced);\n\n for (const binding of unreferenced) {\n if (binding.path.isVariableDeclarator()) {\n const id = binding.path.get('id');\n if (!isRemoved(id) && !forDeletingSet.has(id)) {\n // Drop dead variable declarations, e.g. `const foo = make();` when `foo` is no longer referenced.\n for (const violation of binding.constantViolations) {\n if (queueForDeleting(violation)) {\n changed = true;\n }\n }\n\n if (queueForDeleting(id)) {\n changed = true;\n }\n }\n }\n\n // Drop import specifiers whose bindings lost all references during shaking\n // (e.g. when we keep only __wywPreval and the rest of the module is removed).\n if (\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n !isRemoved(binding.path) &&\n !forDeletingSet.has(binding.path)\n ) {\n if (queueForDeleting(binding.path)) {\n changed = true;\n }\n }\n }\n }\n }\n\n this.imports = withoutRemoved(collected.imports);\n this.exports = {};\n this.deadExports = [];\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (isRemoved(local)) {\n this.deadExports.push(exported);\n } else {\n this.exports[exported] = local;\n }\n });\n\n this.reexports = withoutRemoved(collected.reexports);\n },\n visitor: {},\n post(file: BabelFile) {\n const log = shakerLogger.extend(getFileIdx(file.opts.filename!));\n\n const processedImports = new Set<string>();\n const imports = new Map<string, string[]>();\n const addImport = ({\n imported,\n source,\n }: {\n imported: string;\n source: string;\n }) => {\n if (processedImports.has(`${source}:${imported}`)) {\n return;\n }\n\n if (!imports.has(source)) {\n imports.set(source, []);\n }\n\n if (imported) {\n imports.get(source)!.push(imported);\n }\n\n processedImports.add(`${source}:${imported}`);\n };\n\n this.imports.forEach(addImport);\n this.reexports.forEach(addImport);\n\n log('end', `remaining imports: %O`, imports);\n\n // eslint-disable-next-line no-param-reassign\n (file.metadata as IMetadata).wywEvaluator = {\n imports,\n };\n\n invalidateTraversalCache(file.path);\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAYA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,yBAAA,GAAAF,OAAA;AAIA,IAAAG,WAA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ACuJ,SAAS,CAAC;MAC/B,IAAI,CAACpD,SAAS,CAACnG,OAAO,CAACuJ,SAAS,CAAC;MAEjCtF,GAAG,CAAC,KAAK,EAAE,uBAAuB,EAAE+B,OAAO,CAAC;;MAE5C;MACClC,IAAI,CAAC0F,QAAQ,CAAeC,YAAY,GAAG;QAC1CzD;MACF,CAAC;MAED,IAAA0D,wCAAwB,EAAC5F,IAAI,CAAChB,IAAI,CAAC;IACrC;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"shaker.js","names":["_path","_interopRequireDefault","require","_shared","_collectExportsAndImports","_getFileIdx","_isRemoved","_scopeHelpers","_traversalCache","_parseRequest","_importOverrides","e","__esModule","default","warnedDynamicImportFiles","Set","getNonParamBinding","exportPath","name","_exportPath$scope$par","_exportPath$scope$par2","binding","scope","getBinding","kind","parent","getBindingForExport","isIdentifier","node","variableDeclarator","findParent","p","isVariableDeclarator","id","get","isAssignmentExpression","left","isFunctionDeclaration","isClassDeclaration","undefined","withoutRemoved","items","filter","local","isRemoved","rearrangeExports","types","t","root","exportRefs","exports","rearranged","rootScope","forEach","refs","_constantViolations","length","declarator","uid","generateUid","declaration","unshiftContainer","variableDeclaration","identifier","registerDeclaration","constantViolations","ref","replaced","replaceWith","isBindingIdentifier","push","reference","registerConstantViolation","assigmentToExport","expressionStatement","assignmentExpression","memberExpression","body","lastViolation","pathInRoot","find","n","isDescendant","pushed","insertAfter","getPropertyAssignmentStatement","bindingName","assignment","isMemberExpression","object","statement","parentPath","isExpressionStatement","isWithinAliveExport","aliveExports","some","alive","isAncestor","stripExportKeepDeclaration","path","exportDeclaration","isExportNamedDeclaration","isTSEnumDeclaration","isVariableDeclaration","declarators","shakerPlugin","babel","keepSideEffects","ifUnknownExport","importOverrides","onlyExports","shakerLogger","logger","extend","pre","file","filename","opts","log","getFileIdx","join","onlyExportsSet","shouldKeepOverride","override","hasImportOverride","Object","keys","cache","Map","source","_getImportOverride","cached","strippedSource","stripQueryAndHash","direct","getImportOverride","result","set","isFileImport","startsWith","pathLib","isAbsolute","resolved","syncResolve","key","toImportKey","collected","collectExportsAndImports","imports","sideEffectImports","sideEffectImport","values","reexports","hasWywPreval","__wywPreval","hasDefault","has","delete","size","deadExports","remove","importedAsSideEffect","isEsModule","add","importNames","map","imported","entries","exported","isImportSpecifier","isImportDefaultSpecifier","isImportNamespaceSpecifier","includes","exp","exportToPath","notFoundExports","clear","isAllExportsFound","Error","forDeleting","i","forDeletingSet","queueForDeleting","deleted","dereferenced","changed","action","findActionForNode","outerReferences","referencePaths","candidate","removableAssignmentStatements","removableOuterReferences","blockingReferences","dereference","applyAction","removeWithRelated","unreferenced","getAllBindings","referenced","violation","visitor","post","dynamicImportWarningsEnabled","Boolean","process","env","WYW_WARN_DYNAMIC_IMPORTS","dynamicImports","imp","type","sources","Array","from","sort","sourcesToWarn","shouldWarn","_getImportOverride2","importKey","overrideKeys","item","index","array","firstIndexForKey","findIndex","warning","console","warn","processedImports","addImport","metadata","wywEvaluator","invalidateTraversalCache"],"sources":["../../src/plugins/shaker.ts"],"sourcesContent":["import pathLib from 'path';\n\nimport type { BabelFile, PluginObj, NodePath } from '@babel/core';\nimport type { Binding } from '@babel/traverse';\nimport type {\n ExportNamedDeclaration,\n Identifier,\n MemberExpression,\n Program,\n VariableDeclarator,\n} from '@babel/types';\n\nimport { logger, syncResolve } from '@wyw-in-js/shared';\nimport type { ImportOverride, ImportOverrides } from '@wyw-in-js/shared';\n\nimport type { Core } from '../babel';\nimport type { IMetadata } from '../utils/ShakerMetadata';\nimport type { Exports, IState } from '../utils/collectExportsAndImports';\nimport {\n collectExportsAndImports,\n sideEffectImport,\n} from '../utils/collectExportsAndImports';\nimport { getFileIdx } from '../utils/getFileIdx';\nimport { isRemoved } from '../utils/isRemoved';\nimport {\n applyAction,\n dereference,\n findActionForNode,\n reference,\n removeWithRelated,\n} from '../utils/scopeHelpers';\nimport { invalidateTraversalCache } from '../utils/traversalCache';\nimport { stripQueryAndHash } from '../utils/parseRequest';\nimport { getImportOverride, toImportKey } from '../utils/importOverrides';\n\nconst warnedDynamicImportFiles = new Set<string>();\n\nexport interface IShakerOptions {\n ifUnknownExport?: 'error' | 'ignore' | 'reexport-all' | 'skip-shaking';\n importOverrides?: ImportOverrides;\n keepSideEffects?: boolean;\n onlyExports: string[];\n root?: string;\n}\n\ninterface NodeWithName {\n name: string;\n}\n\nfunction getNonParamBinding(\n exportPath: NodePath,\n name: string\n): Binding | undefined {\n const binding = exportPath.scope.getBinding(name);\n if (binding && (binding.kind as string) !== 'param') {\n return binding;\n }\n\n // When `exportPath` is inside a function scope, a parameter can shadow\n // the actual export binding (e.g. `export function fallback(fallback) {}`).\n // In such cases we need the binding from the declaration scope.\n return exportPath.scope.parent?.getBinding(name) ?? binding;\n}\n\nfunction getBindingForExport(exportPath: NodePath): Binding | undefined {\n if (exportPath.isIdentifier()) {\n return getNonParamBinding(exportPath, exportPath.node.name);\n }\n\n const variableDeclarator = exportPath.findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n if (variableDeclarator) {\n const id = variableDeclarator.get('id');\n if (id.isIdentifier()) {\n return variableDeclarator.scope.getBinding(id.node.name);\n }\n }\n\n if (exportPath.isAssignmentExpression()) {\n const left = exportPath.get('left');\n if (left.isIdentifier()) {\n return getNonParamBinding(exportPath, left.node.name);\n }\n }\n\n if (exportPath.isFunctionDeclaration() || exportPath.isClassDeclaration()) {\n const { id } = exportPath.node;\n if (!id) {\n // `export default function() {}` / `export default class {}` (anonymous)\n return undefined;\n }\n return getNonParamBinding(exportPath, id.name);\n }\n\n return undefined;\n}\n\nconst withoutRemoved = <T extends { local: NodePath }>(items: T[]): T[] =>\n items.filter(({ local }) => !isRemoved(local));\n\nfunction rearrangeExports(\n { types: t }: Core,\n root: NodePath<Program>,\n exportRefs: Map<string, NodePath<MemberExpression>[]>,\n exports: Exports\n): Exports {\n const rearranged = {\n ...exports,\n };\n\n const rootScope = root.scope;\n exportRefs.forEach((refs, name) => {\n if (refs.length <= 1) {\n if (refs.length === 1) {\n // Maybe exports is assigned to another variable?\n const declarator = refs[0].findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n\n if (!declarator) {\n return;\n }\n } else {\n return;\n }\n }\n\n const uid = rootScope.generateUid(name);\n // Define variable in the beginning\n const [declaration] = root.unshiftContainer('body', [\n t.variableDeclaration('var', [t.variableDeclarator(t.identifier(uid))]),\n ]);\n\n rootScope.registerDeclaration(declaration);\n\n const constantViolations: NodePath<Identifier>[] = [];\n // Replace every reference with defined variable\n refs.forEach((ref) => {\n const [replaced] = ref.replaceWith(t.identifier(uid));\n if (replaced.isBindingIdentifier()) {\n constantViolations.push(replaced);\n } else {\n reference(replaced);\n }\n });\n\n constantViolations.forEach((id) => {\n rootScope.registerConstantViolation(id);\n });\n\n const assigmentToExport = t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.memberExpression(t.identifier('exports'), t.identifier(name)),\n t.identifier(uid)\n )\n );\n\n // export.foo = _foo will be inserted either after the last _foo assigment or in the end of the file\n const body = root.get('body');\n const lastViolation =\n constantViolations[constantViolations.length - 1] ??\n body[body.length - 1];\n const pathInRoot = root\n .get('body')\n .find((n) => lastViolation.isDescendant(n))!;\n\n const [pushed] = pathInRoot.insertAfter(assigmentToExport);\n\n const local = pushed.get('expression.right') as NodePath<Identifier>;\n reference(local);\n\n rearranged[name] = local;\n });\n\n return rearranged;\n}\n\nconst getPropertyAssignmentStatement = (\n ref: NodePath,\n bindingName: string\n): NodePath | null => {\n const assignment = ref.findParent((parent) =>\n parent.isAssignmentExpression()\n );\n if (!assignment?.isAssignmentExpression()) return null;\n\n const left = assignment.get('left');\n if (!left.isMemberExpression()) return null;\n\n const object = left.get('object');\n if (!object.isIdentifier({ name: bindingName })) return null;\n\n const statement = assignment.parentPath;\n return statement?.isExpressionStatement() ? statement : null;\n};\n\nconst isWithinAliveExport = (\n ref: NodePath,\n aliveExports: Set<NodePath>\n): boolean =>\n [...aliveExports].some((alive) => alive === ref || alive.isAncestor(ref));\n\nfunction stripExportKeepDeclaration(path: NodePath): boolean {\n const exportDeclaration = path.findParent((p) =>\n p.isExportNamedDeclaration()\n ) as NodePath<ExportNamedDeclaration> | null;\n if (!exportDeclaration) return false;\n\n const declaration = exportDeclaration.get('declaration');\n if (!declaration.node) return false;\n\n if (\n declaration.isFunctionDeclaration() ||\n declaration.isClassDeclaration() ||\n declaration.isTSEnumDeclaration()\n ) {\n exportDeclaration.replaceWith(declaration.node);\n return true;\n }\n\n if (declaration.isVariableDeclaration()) {\n const declarators = declaration.get('declarations');\n if (declarators.length !== 1) {\n return false;\n }\n\n exportDeclaration.replaceWith(declaration.node);\n return true;\n }\n\n return false;\n}\n\nexport default function shakerPlugin(\n babel: Core,\n {\n keepSideEffects = false,\n ifUnknownExport = 'skip-shaking',\n importOverrides,\n onlyExports,\n root,\n }: IShakerOptions\n): PluginObj<IState & { filename: string }> {\n const shakerLogger = logger.extend('shaker');\n\n return {\n name: '@wyw-in-js/transform/shaker',\n pre(file: BabelFile) {\n this.filename = file.opts.filename!;\n const log = shakerLogger.extend(getFileIdx(this.filename));\n\n log('start', `${this.filename}, onlyExports: ${onlyExports.join(',')}`);\n const onlyExportsSet = new Set(onlyExports);\n\n const shouldKeepOverride = (\n override: ImportOverride | undefined\n ): boolean => !!override && ('mock' in override || 'noShake' in override);\n\n const hasImportOverride = (() => {\n if (!importOverrides || Object.keys(importOverrides).length === 0) {\n return () => false;\n }\n\n const cache = new Map<string, boolean>();\n\n return (source: string): boolean => {\n const cached = cache.get(source);\n if (cached !== undefined) {\n return cached;\n }\n\n const strippedSource = stripQueryAndHash(source);\n\n const direct =\n getImportOverride(importOverrides, source) ??\n (strippedSource !== source\n ? getImportOverride(importOverrides, strippedSource)\n : null);\n if (direct) {\n const result = shouldKeepOverride(direct);\n cache.set(source, result);\n return result;\n }\n\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n if (!isFileImport) {\n cache.set(source, false);\n return false;\n }\n\n try {\n const resolved = syncResolve(strippedSource, this.filename, []);\n const { key } = toImportKey({\n source: strippedSource,\n resolved,\n root,\n });\n const override = getImportOverride(importOverrides, key);\n const result = shouldKeepOverride(override);\n cache.set(source, result);\n return result;\n } catch {\n cache.set(source, false);\n return false;\n }\n };\n })();\n\n const collected = collectExportsAndImports(file.path);\n const { imports } = collected;\n const sideEffectImports = imports.filter(sideEffectImport);\n log(\n 'import-and-exports',\n [\n `imports: ${imports.length} (side-effects: ${sideEffectImports.length})`,\n `exports: ${Object.values(collected.exports).length}`,\n `reexports: ${collected.reexports.length}`,\n ].join(', ')\n );\n\n // We cannot just throw out exports if they are referred in the code\n // Let's dome some replacements\n const exports = rearrangeExports(\n babel,\n file.path,\n collected.exportRefs,\n collected.exports\n );\n\n Object.values(exports).forEach((local) => {\n if (local.isAssignmentExpression()) {\n const left = local.get('left');\n if (left.isIdentifier()) {\n // For some reason babel does not mark id in AssignmentExpression as a reference\n // So we need to do it manually\n reference(left, left, true);\n }\n }\n });\n\n const hasWywPreval = exports.__wywPreval !== undefined;\n const hasDefault = exports.default !== undefined;\n\n // If __wywPreval is not exported, we can remove it from onlyExports\n if (onlyExportsSet.has('__wywPreval') && !hasWywPreval) {\n onlyExportsSet.delete('__wywPreval');\n }\n\n if (onlyExportsSet.size === 0) {\n // Fast-lane: if there are no exports to keep, we can just shake out the whole file\n this.imports = [];\n this.exports = {};\n this.reexports = [];\n this.deadExports = Object.keys(exports);\n\n file.path.get('body').forEach((p) => {\n p.remove();\n });\n\n return;\n }\n\n const importedAsSideEffect = onlyExportsSet.has('side-effect');\n onlyExportsSet.delete('side-effect');\n\n // Hackaround for packages which include a 'default' export without specifying __esModule; such packages cannot be\n // shaken as they will break interopRequireDefault babel helper\n // See example in shaker-plugin.test.ts\n // Real-world example was found in preact/compat npm package\n if (\n onlyExportsSet.has('default') &&\n hasDefault &&\n !collected.isEsModule\n ) {\n this.imports = imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n return;\n }\n\n if (!onlyExportsSet.has('*')) {\n // __esModule should be kept alive\n onlyExportsSet.add('__esModule');\n\n const aliveExports = new Set<NodePath>();\n const importNames = imports.map(({ imported }) => imported);\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (onlyExportsSet.has(exported)) {\n aliveExports.add(local);\n return;\n }\n\n const binding =\n local.isIdentifier() && local.scope.getBinding(local.node.name);\n\n if (\n binding &&\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n importNames.includes((local.node as NodeWithName).name || '')\n ) {\n aliveExports.add(local);\n return;\n }\n\n if ([...aliveExports].some((alive) => alive === local)) {\n // It's possible to export multiple values from a single variable initializer, e.g\n // export const { foo, bar } = baz();\n // We need to treat all of them as used if any of them are used, since otherwise\n // we'll attempt to delete the baz() call\n aliveExports.add(local);\n }\n });\n\n collected.reexports.forEach((exp) => {\n if (onlyExportsSet.has(exp.exported)) {\n aliveExports.add(exp.local);\n }\n });\n\n const exportToPath = new Map<string, NodePath>();\n Object.entries(exports).forEach(([exported, local]) => {\n exportToPath.set(exported, local);\n });\n\n collected.reexports.forEach((exp) => {\n exportToPath.set(exp.exported, exp.local);\n });\n\n const notFoundExports = [...onlyExportsSet].filter(\n (exp) =>\n exp !== '__esModule' && !aliveExports.has(exportToPath.get(exp)!)\n );\n exportToPath.clear();\n\n const isAllExportsFound = notFoundExports.length === 0;\n if (!isAllExportsFound && ifUnknownExport !== 'ignore') {\n if (ifUnknownExport === 'error') {\n throw new Error(\n `Unknown export(s) requested: ${onlyExports.join(',')}`\n );\n }\n\n if (ifUnknownExport === 'reexport-all') {\n // If there are unknown exports, we have keep alive all re-exports.\n if (exports['*'] !== undefined) {\n aliveExports.add(exports['*']);\n }\n\n collected.reexports.forEach((exp) => {\n if (exp.exported === '*') {\n aliveExports.add(exp.local);\n }\n });\n }\n\n if (ifUnknownExport === 'skip-shaking') {\n this.imports = imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n\n return;\n }\n }\n\n const forDeleting = [\n ...Object.values(exports),\n ...collected.reexports.map((i) => i.local),\n ].filter((exp) => !aliveExports.has(exp));\n\n const forDeletingSet = new Set<NodePath>(forDeleting);\n const queueForDeleting = (path: NodePath): boolean => {\n if (isRemoved(path) || forDeletingSet.has(path)) {\n return false;\n }\n\n forDeletingSet.add(path);\n forDeleting.push(path);\n return true;\n };\n\n if (!keepSideEffects && !importedAsSideEffect) {\n // Drop side-effect imports for eval-only builds unless they were explicitly requested.\n // This prevents evaluating unrelated runtime code (e.g. Radix) during __wywPreval eval.\n sideEffectImports.forEach((i) => {\n if (hasImportOverride(i.source)) {\n return;\n }\n\n queueForDeleting(i.local);\n });\n }\n\n const deleted = new Set<NodePath>();\n\n let dereferenced: NodePath<Identifier>[] = [];\n let changed = true;\n while (changed) {\n changed = false;\n // eslint-disable-next-line no-restricted-syntax\n for (const path of forDeleting) {\n if (deleted.has(path)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const binding = getBindingForExport(path);\n const action = findActionForNode(path);\n const parent = action?.[1];\n const outerReferences = (binding?.referencePaths || []).filter(\n (ref) => {\n if (ref === parent || parent?.isAncestor(ref)) {\n return false;\n }\n\n return !forDeleting.some(\n (candidate) =>\n candidate !== path &&\n !isRemoved(candidate) &&\n (candidate === ref || candidate.isAncestor(ref))\n );\n }\n );\n const bindingName = binding?.identifier.name;\n const removableAssignmentStatements = new Set<NodePath>();\n const removableOuterReferences = outerReferences.filter((ref) => {\n if (!bindingName) return false;\n const statement = getPropertyAssignmentStatement(\n ref,\n bindingName\n );\n if (!statement || isWithinAliveExport(statement, aliveExports)) {\n return false;\n }\n\n removableAssignmentStatements.add(statement);\n return true;\n });\n\n const blockingReferences = outerReferences.filter(\n (ref) => !removableOuterReferences.includes(ref)\n );\n\n if (blockingReferences.length > 0 && path.isIdentifier()) {\n // Temporary deref it in order to simplify further checks.\n dereference(path);\n dereferenced.push(path);\n }\n\n if (\n !deleted.has(path) &&\n binding &&\n blockingReferences.length > 0 &&\n stripExportKeepDeclaration(path)\n ) {\n deleted.add(path);\n changed = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (\n !deleted.has(path) &&\n (!binding || blockingReferences.length === 0)\n ) {\n if (removableAssignmentStatements.size > 0) {\n for (const statement of removableAssignmentStatements) {\n if (queueForDeleting(statement)) {\n changed = true;\n }\n }\n }\n\n if (action) {\n applyAction(action);\n } else {\n removeWithRelated([path]);\n }\n\n deleted.add(path);\n changed = true;\n }\n }\n\n dereferenced.forEach((path) => {\n // If path is still alive, we need to reference it back\n if (!isRemoved(path)) {\n reference(path);\n }\n });\n\n dereferenced = [];\n\n // Find and mark for deleting all unreferenced variables\n const unreferenced = Object.values(\n file.scope.getAllBindings()\n ).filter((i) => !i.referenced);\n\n for (const binding of unreferenced) {\n if (binding.path.isVariableDeclarator()) {\n const id = binding.path.get('id');\n if (!isRemoved(id) && !forDeletingSet.has(id)) {\n // Drop dead variable declarations, e.g. `const foo = make();` when `foo` is no longer referenced.\n for (const violation of binding.constantViolations) {\n if (queueForDeleting(violation)) {\n changed = true;\n }\n }\n\n if (queueForDeleting(id)) {\n changed = true;\n }\n }\n }\n\n // Drop import specifiers whose bindings lost all references during shaking\n // (e.g. when we keep only __wywPreval and the rest of the module is removed).\n if (\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n !isRemoved(binding.path) &&\n !forDeletingSet.has(binding.path)\n ) {\n if (queueForDeleting(binding.path)) {\n changed = true;\n }\n }\n }\n }\n }\n\n this.imports = withoutRemoved(imports);\n this.exports = {};\n this.deadExports = [];\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (isRemoved(local)) {\n this.deadExports.push(exported);\n } else {\n this.exports[exported] = local;\n }\n });\n\n this.reexports = withoutRemoved(collected.reexports);\n },\n visitor: {},\n post(file: BabelFile) {\n const log = shakerLogger.extend(getFileIdx(file.opts.filename!));\n\n const dynamicImportWarningsEnabled =\n Boolean(process.env.WYW_WARN_DYNAMIC_IMPORTS) &&\n process.env.WYW_WARN_DYNAMIC_IMPORTS !== '0' &&\n process.env.WYW_WARN_DYNAMIC_IMPORTS !== 'false';\n\n const filename = file.opts.filename!;\n\n if (\n dynamicImportWarningsEnabled &&\n !warnedDynamicImportFiles.has(filename)\n ) {\n const dynamicImports = this.imports.filter(\n (imp) => !sideEffectImport(imp) && imp.type === 'dynamic'\n );\n if (dynamicImports.length > 0) {\n const sources = Array.from(\n new Set(dynamicImports.map((imp) => imp.source))\n ).sort();\n const sourcesToWarn = (() => {\n if (!importOverrides || Object.keys(importOverrides).length === 0) {\n return sources;\n }\n\n const shouldWarn = (source: string): boolean => {\n const strippedSource = stripQueryAndHash(source);\n const direct =\n getImportOverride(importOverrides, source) ??\n (strippedSource !== source\n ? getImportOverride(importOverrides, strippedSource)\n : undefined);\n if (direct !== undefined) {\n return false;\n }\n\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n if (!isFileImport) {\n return true;\n }\n\n try {\n const resolved = syncResolve(strippedSource, filename, []);\n const importKey = toImportKey({\n source: strippedSource,\n resolved,\n root,\n }).key;\n return (\n getImportOverride(importOverrides, importKey) === undefined\n );\n } catch {\n return true;\n }\n };\n\n return sources.filter(shouldWarn);\n })();\n\n if (sourcesToWarn.length > 0) {\n warnedDynamicImportFiles.add(filename);\n const overrideKeys = sourcesToWarn\n .map((source) => {\n const strippedSource = stripQueryAndHash(source);\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n\n if (!isFileImport) {\n return { source, key: source };\n }\n\n try {\n const resolved = syncResolve(strippedSource, filename, []);\n return {\n source,\n key: toImportKey({\n source: strippedSource,\n resolved,\n root,\n }).key,\n };\n } catch {\n return { source, key: strippedSource };\n }\n })\n .filter((item, index, array) => {\n const firstIndexForKey = array.findIndex(\n (i) => i.key === item.key\n );\n return firstIndexForKey === index;\n });\n const warning = [\n `[wyw-in-js] Dynamic imports reached prepare stage`,\n ``,\n `file: ${filename}`,\n `count: ${sourcesToWarn.length}`,\n `sources:`,\n ...sourcesToWarn.map((source) => ` - ${source}`),\n ``,\n `note: these imports will be resolved/processed even if they are lazy (e.g. React.lazy(() => import(...)))`,\n ``,\n `tip: if the imported module is runtime-only or heavy, mock it during evaluation via importOverrides:`,\n ` importOverrides: {`,\n ...overrideKeys.map(\n ({ key, source }) =>\n ` '${key}': { mock: './path/to/mock' }, // from ${source}`\n ),\n ` }`,\n ``,\n `note: importOverrides affects only build-time evaluation (it does not change your bundler runtime behavior)`,\n ].join('\\n');\n // eslint-disable-next-line no-console\n console.warn(warning);\n }\n }\n }\n\n const processedImports = new Set<string>();\n const imports = new Map<string, string[]>();\n const addImport = ({\n imported,\n source,\n }: {\n imported: string;\n source: string;\n }) => {\n if (processedImports.has(`${source}:${imported}`)) {\n return;\n }\n\n if (!imports.has(source)) {\n imports.set(source, []);\n }\n\n if (imported) {\n imports.get(source)!.push(imported);\n }\n\n processedImports.add(`${source}:${imported}`);\n };\n\n this.imports.forEach(addImport);\n this.reexports.forEach(addImport);\n\n log('end', `remaining imports: %O`, imports);\n\n // eslint-disable-next-line no-param-reassign\n (file.metadata as IMetadata).wywEvaluator = {\n imports,\n };\n\n invalidateTraversalCache(file.path);\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAYA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,yBAAA,GAAAF,OAAA;AAIA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAOA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAR,OAAA;AAA0E,SAAAD,uBAAAU,CAAA,WAAAA,CAAA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-207,7 +207,14 @@ function loadAndParse(services, name, loadedCode, log) {
207
207
  reason: 'extension'
208
208
  };
209
209
  }
210
- const code = loadedCode !== null && loadedCode !== void 0 ? loadedCode : (0, _fs.readFileSync)(filename, 'utf-8');
210
+ let code = loadedCode;
211
+ if (code === undefined) {
212
+ const cachedEntrypoint = services.cache.get('entrypoints', name);
213
+ if (cachedEntrypoint && 'initialCode' in cachedEntrypoint && typeof cachedEntrypoint.initialCode === 'string') {
214
+ code = cachedEntrypoint.initialCode;
215
+ }
216
+ }
217
+ code !== null && code !== void 0 ? code : code = (0, _fs.readFileSync)(filename, 'utf-8');
211
218
  const {
212
219
  action,
213
220
  babelOptions