@rollup/plugin-commonjs 22.0.0-4 → 22.0.0-8

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.
@@ -7,9 +7,9 @@ import { walk } from 'estree-walker';
7
7
  import MagicString from 'magic-string';
8
8
  import isReference from 'is-reference';
9
9
 
10
- var version = "22.0.0-4";
10
+ var version = "22.0.0-8";
11
11
  var peerDependencies = {
12
- rollup: "^2.61.1"
12
+ rollup: "^2.66.1"
13
13
  };
14
14
 
15
15
  function tryParse(parse, code, id) {
@@ -328,7 +328,8 @@ const WRAPPED_SUFFIX = '?commonjs-wrapped';
328
328
  const EXTERNAL_SUFFIX = '?commonjs-external';
329
329
  const EXPORTS_SUFFIX = '?commonjs-exports';
330
330
  const MODULE_SUFFIX = '?commonjs-module';
331
- const ES_IMPORT_SUFFIX = '?es-import';
331
+ const ENTRY_SUFFIX = '?commonjs-entry';
332
+ const ES_IMPORT_SUFFIX = '?commonjs-es-import';
332
333
 
333
334
  const DYNAMIC_MODULES_ID = '\0commonjs-dynamic-modules';
334
335
  const HELPERS_ID = '\0commonjsHelpers.js';
@@ -396,21 +397,15 @@ function getUnknownRequireProxy(id, requireReturnsDefault) {
396
397
  return `import * as ${name} from ${JSON.stringify(id)}; ${exported}`;
397
398
  }
398
399
 
399
- async function getStaticRequireProxy(
400
- id,
401
- requireReturnsDefault,
402
- esModulesWithDefaultExport,
403
- esModulesWithNamedExports,
404
- loadModule
405
- ) {
400
+ async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
406
401
  const name = getName(id);
407
402
  const {
408
403
  meta: { commonjs: commonjsMeta }
409
404
  } = await loadModule({ id });
410
- if (commonjsMeta && commonjsMeta.isCommonJS) {
411
- return `export { __moduleExports as default } from ${JSON.stringify(id)};`;
412
- } else if (!commonjsMeta) {
405
+ if (!commonjsMeta) {
413
406
  return getUnknownRequireProxy(id, requireReturnsDefault);
407
+ } else if (commonjsMeta.isCommonJS) {
408
+ return `export { __moduleExports as default } from ${JSON.stringify(id)};`;
414
409
  } else if (!requireReturnsDefault) {
415
410
  return `import { getAugmentedNamespace } from "${HELPERS_ID}"; import * as ${name} from ${JSON.stringify(
416
411
  id
@@ -418,14 +413,30 @@ async function getStaticRequireProxy(
418
413
  } else if (
419
414
  requireReturnsDefault !== true &&
420
415
  (requireReturnsDefault === 'namespace' ||
421
- !esModulesWithDefaultExport.has(id) ||
422
- (requireReturnsDefault === 'auto' && esModulesWithNamedExports.has(id)))
416
+ !commonjsMeta.hasDefaultExport ||
417
+ (requireReturnsDefault === 'auto' && commonjsMeta.hasNamedExports))
423
418
  ) {
424
419
  return `import * as ${name} from ${JSON.stringify(id)}; export default ${name};`;
425
420
  }
426
421
  return `export { default } from ${JSON.stringify(id)};`;
427
422
  }
428
423
 
424
+ async function getEntryProxy(id, defaultIsModuleExports, loadModule) {
425
+ const {
426
+ meta: { commonjs: commonjsMeta },
427
+ hasDefaultExport
428
+ } = await loadModule({ id, moduleSideEffects: true });
429
+ if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) {
430
+ const stringifiedId = JSON.stringify(id);
431
+ let code = `export * from ${stringifiedId};`;
432
+ if (hasDefaultExport) {
433
+ code += `export { default } from ${stringifiedId};`;
434
+ }
435
+ return code;
436
+ }
437
+ return getEsImportProxy(id, defaultIsModuleExports);
438
+ }
439
+
429
440
  function getEsImportProxy(id, defaultIsModuleExports) {
430
441
  const name = getName(id);
431
442
  const exportsName = `${name}Exports`;
@@ -494,6 +505,7 @@ function getResolveId(extensions) {
494
505
  }
495
506
 
496
507
  if (
508
+ importee.endsWith(ENTRY_SUFFIX) ||
497
509
  isWrappedId(importee, MODULE_SUFFIX) ||
498
510
  isWrappedId(importee, EXPORTS_SUFFIX) ||
499
511
  isWrappedId(importee, PROXY_SUFFIX) ||
@@ -510,7 +522,8 @@ function getResolveId(extensions) {
510
522
  importer === DYNAMIC_MODULES_ID ||
511
523
  // Proxies are only importing resolved ids, no need to resolve again
512
524
  isWrappedId(importer, PROXY_SUFFIX) ||
513
- isWrappedId(importer, ES_IMPORT_SUFFIX)
525
+ isWrappedId(importer, ES_IMPORT_SUFFIX) ||
526
+ importer.endsWith(ENTRY_SUFFIX)
514
527
  ) {
515
528
  return importee;
516
529
  }
@@ -540,9 +553,19 @@ function getResolveId(extensions) {
540
553
  const resolved =
541
554
  (await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions))) ||
542
555
  resolveExtensions(importee, importer, extensions);
543
- if (!resolved || resolved.external) {
556
+ // Make sure that even if other plugins resolve again, we ignore our own proxies
557
+ if (
558
+ !resolved ||
559
+ resolved.external ||
560
+ resolved.id.endsWith(ENTRY_SUFFIX) ||
561
+ isWrappedId(resolved.id, ES_IMPORT_SUFFIX)
562
+ ) {
544
563
  return resolved;
545
564
  }
565
+ if (resolveOptions.isEntry) {
566
+ // We must not precede entry proxies with a `\0` as that will mess up relative external resolution
567
+ return resolved.id + ENTRY_SUFFIX;
568
+ }
546
569
  const {
547
570
  meta: { commonjs: commonjsMeta }
548
571
  } = await this.load(resolved);
@@ -553,7 +576,7 @@ function getResolveId(extensions) {
553
576
  };
554
577
  }
555
578
 
556
- function getResolveRequireSourcesAndGetMeta(extensions, detectCyclesAndConditional) {
579
+ function getRequireResolver(extensions, detectCyclesAndConditional) {
557
580
  const knownCjsModuleTypes = Object.create(null);
558
581
  const requiredIds = Object.create(null);
559
582
  const unconditionallyRequiredIds = Object.create(null);
@@ -577,11 +600,7 @@ function getResolveRequireSourcesAndGetMeta(extensions, detectCyclesAndCondition
577
600
 
578
601
  const getTypeForFullyAnalyzedModule = (id) => {
579
602
  const knownType = knownCjsModuleTypes[id];
580
- if (
581
- knownType === IS_WRAPPED_COMMONJS ||
582
- !detectCyclesAndConditional ||
583
- fullyAnalyzedModules[id]
584
- ) {
603
+ if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) {
585
604
  return knownType;
586
605
  }
587
606
  fullyAnalyzedModules[id] = true;
@@ -591,26 +610,80 @@ function getResolveRequireSourcesAndGetMeta(extensions, detectCyclesAndCondition
591
610
  return knownType;
592
611
  };
593
612
 
613
+ const setInitialParentType = (id, initialCommonJSType) => {
614
+ // It is possible a transformed module is already fully analyzed when using
615
+ // the cache and one dependency introduces a new cycle. Then transform is
616
+ // run for a fully analzyed module again. Fully analyzed modules may never
617
+ // change their type as importers already trust their type.
618
+ knownCjsModuleTypes[id] = fullyAnalyzedModules[id]
619
+ ? knownCjsModuleTypes[id]
620
+ : initialCommonJSType;
621
+ if (
622
+ detectCyclesAndConditional &&
623
+ knownCjsModuleTypes[id] === true &&
624
+ requiredIds[id] &&
625
+ !unconditionallyRequiredIds[id]
626
+ ) {
627
+ knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
628
+ }
629
+ };
630
+
631
+ const setTypesForRequiredModules = async (parentId, resolved, isConditional, loadModule) => {
632
+ const childId = resolved.id;
633
+ requiredIds[childId] = true;
634
+ if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) {
635
+ unconditionallyRequiredIds[childId] = true;
636
+ }
637
+
638
+ getDependencies(parentId).add(childId);
639
+ if (!isCyclic(childId)) {
640
+ // This makes sure the current transform handler waits for all direct dependencies to be
641
+ // loaded and transformed and therefore for all transitive CommonJS dependencies to be
642
+ // loaded as well so that all cycles have been found and knownCjsModuleTypes is reliable.
643
+ await loadModule(resolved);
644
+ }
645
+ };
646
+
594
647
  return {
595
648
  getWrappedIds: () =>
596
649
  Object.keys(knownCjsModuleTypes).filter(
597
650
  (id) => knownCjsModuleTypes[id] === IS_WRAPPED_COMMONJS
598
651
  ),
599
652
  isRequiredId: (id) => requiredIds[id],
600
- resolveRequireSourcesAndGetMeta: (rollupContext) => async (
653
+ async shouldTransformCachedModule({ id: parentId, meta: { commonjs: parentMeta } }) {
654
+ // Ignore modules that did not pass through the original transformer in a previous build
655
+ if (!(parentMeta && parentMeta.requires)) {
656
+ return false;
657
+ }
658
+ setInitialParentType(parentId, parentMeta.initialCommonJSType);
659
+ await Promise.all(
660
+ parentMeta.requires.map(({ resolved, isConditional }) =>
661
+ setTypesForRequiredModules(parentId, resolved, isConditional, this.load)
662
+ )
663
+ );
664
+ if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) {
665
+ return true;
666
+ }
667
+ for (const {
668
+ resolved: { id }
669
+ } of parentMeta.requires) {
670
+ if (getTypeForFullyAnalyzedModule(id) !== parentMeta.isRequiredCommonJS[id]) {
671
+ return true;
672
+ }
673
+ }
674
+ return false;
675
+ },
676
+ /* eslint-disable no-param-reassign */
677
+ resolveRequireSourcesAndUpdateMeta: (rollupContext) => async (
601
678
  parentId,
602
679
  isParentCommonJS,
680
+ parentMeta,
603
681
  sources
604
682
  ) => {
605
- knownCjsModuleTypes[parentId] = isParentCommonJS;
606
- if (
607
- detectCyclesAndConditional &&
608
- knownCjsModuleTypes[parentId] &&
609
- requiredIds[parentId] &&
610
- !unconditionallyRequiredIds[parentId]
611
- ) {
612
- knownCjsModuleTypes[parentId] = IS_WRAPPED_COMMONJS;
613
- }
683
+ parentMeta.initialCommonJSType = isParentCommonJS;
684
+ parentMeta.requires = [];
685
+ parentMeta.isRequiredCommonJS = Object.create(null);
686
+ setInitialParentType(parentId, isParentCommonJS);
614
687
  const requireTargets = await Promise.all(
615
688
  sources.map(async ({ source, isConditional }) => {
616
689
  // Never analyze or proxy internal modules
@@ -628,38 +701,27 @@ function getResolveRequireSourcesAndGetMeta(extensions, detectCyclesAndCondition
628
701
  if (resolved.external) {
629
702
  return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false };
630
703
  }
631
- requiredIds[childId] = true;
632
- if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) {
633
- unconditionallyRequiredIds[childId] = true;
634
- }
635
-
636
- getDependencies(parentId).add(childId);
637
- if (!isCyclic(childId)) {
638
- // This makes sure the current transform handler waits for all direct dependencies to be
639
- // loaded and transformed and therefore for all transitive CommonJS dependencies to be
640
- // loaded as well so that all cycles have been found and knownCjsModuleTypes is reliable.
641
- await rollupContext.load(resolved);
642
- } else if (detectCyclesAndConditional && knownCjsModuleTypes[parentId]) {
643
- knownCjsModuleTypes[parentId] = IS_WRAPPED_COMMONJS;
644
- }
704
+ parentMeta.requires.push({ resolved, isConditional });
705
+ await setTypesForRequiredModules(parentId, resolved, isConditional, rollupContext.load);
645
706
  return { id: childId, allowProxy: true };
646
707
  })
647
708
  );
648
- return {
649
- requireTargets: requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
650
- const isCommonJS = getTypeForFullyAnalyzedModule(dependencyId);
651
- return {
652
- source: sources[index].source,
653
- id: allowProxy
654
- ? isCommonJS === IS_WRAPPED_COMMONJS
655
- ? wrapId(dependencyId, WRAPPED_SUFFIX)
656
- : wrapId(dependencyId, PROXY_SUFFIX)
657
- : dependencyId,
658
- isCommonJS
659
- };
660
- }),
661
- usesRequireWrapper: getTypeForFullyAnalyzedModule(parentId) === IS_WRAPPED_COMMONJS
662
- };
709
+ parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId);
710
+ return requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
711
+ // eslint-disable-next-line no-multi-assign
712
+ const isCommonJS = (parentMeta.isRequiredCommonJS[
713
+ dependencyId
714
+ ] = getTypeForFullyAnalyzedModule(dependencyId));
715
+ return {
716
+ source: sources[index].source,
717
+ id: allowProxy
718
+ ? isCommonJS === IS_WRAPPED_COMMONJS
719
+ ? wrapId(dependencyId, WRAPPED_SUFFIX)
720
+ : wrapId(dependencyId, PROXY_SUFFIX)
721
+ : dependencyId,
722
+ isCommonJS
723
+ };
724
+ });
663
725
  }
664
726
  };
665
727
  }
@@ -1133,11 +1195,12 @@ function getRequireHandlers() {
1133
1195
  exportsName,
1134
1196
  id,
1135
1197
  exportMode,
1136
- resolveRequireSourcesAndGetMeta,
1198
+ resolveRequireSourcesAndUpdateMeta,
1137
1199
  needsRequireWrapper,
1138
1200
  isEsModule,
1139
1201
  isDynamicRequireModulesEnabled,
1140
- getIgnoreTryCatchRequireStatementMode
1202
+ getIgnoreTryCatchRequireStatementMode,
1203
+ commonjsMeta
1141
1204
  ) {
1142
1205
  const imports = [];
1143
1206
  imports.push(`import * as ${helpersName} from "${HELPERS_ID}";`);
@@ -1160,9 +1223,10 @@ function getRequireHandlers() {
1160
1223
  );
1161
1224
  }
1162
1225
  const requiresBySource = collectSources(requireExpressions);
1163
- const { requireTargets, usesRequireWrapper } = await resolveRequireSourcesAndGetMeta(
1226
+ const requireTargets = await resolveRequireSourcesAndUpdateMeta(
1164
1227
  id,
1165
1228
  needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule,
1229
+ commonjsMeta,
1166
1230
  Object.keys(requiresBySource).map((source) => {
1167
1231
  return {
1168
1232
  source,
@@ -1177,10 +1241,7 @@ function getRequireHandlers() {
1177
1241
  getIgnoreTryCatchRequireStatementMode,
1178
1242
  magicString
1179
1243
  );
1180
- return {
1181
- importBlock: imports.length ? `${imports.join('\n')}\n\n` : '',
1182
- usesRequireWrapper
1183
- };
1244
+ return imports.length ? `${imports.join('\n')}\n\n` : '';
1184
1245
  }
1185
1246
 
1186
1247
  return {
@@ -1283,9 +1344,10 @@ async function transformCommonjs(
1283
1344
  astCache,
1284
1345
  defaultIsModuleExports,
1285
1346
  needsRequireWrapper,
1286
- resolveRequireSourcesAndGetMeta,
1347
+ resolveRequireSourcesAndUpdateMeta,
1287
1348
  isRequired,
1288
- checkDynamicRequire
1349
+ checkDynamicRequire,
1350
+ commonjsMeta
1289
1351
  ) {
1290
1352
  const ast = astCache || tryParse(parse, code, id);
1291
1353
  const magicString = new MagicString(code);
@@ -1669,7 +1731,7 @@ async function transformCommonjs(
1669
1731
  ) &&
1670
1732
  (ignoreGlobal || !uses.global)
1671
1733
  ) {
1672
- return { meta: { commonjs: { isCommonJS: false, isMixedModule: false } } };
1734
+ return { meta: { commonjs: { isCommonJS: false } } };
1673
1735
  }
1674
1736
 
1675
1737
  let leadingComment = '';
@@ -1691,7 +1753,7 @@ async function transformCommonjs(
1691
1753
  ? 'exports'
1692
1754
  : 'module';
1693
1755
 
1694
- const { importBlock, usesRequireWrapper } = await rewriteRequireExpressionsAndGetImportBlock(
1756
+ const importBlock = await rewriteRequireExpressionsAndGetImportBlock(
1695
1757
  magicString,
1696
1758
  topLevelDeclarations,
1697
1759
  reassignedNames,
@@ -1701,12 +1763,14 @@ async function transformCommonjs(
1701
1763
  exportsName,
1702
1764
  id,
1703
1765
  exportMode,
1704
- resolveRequireSourcesAndGetMeta,
1766
+ resolveRequireSourcesAndUpdateMeta,
1705
1767
  needsRequireWrapper,
1706
1768
  isEsModule,
1707
1769
  isDynamicRequireModulesEnabled,
1708
- getIgnoreTryCatchRequireStatementMode
1770
+ getIgnoreTryCatchRequireStatementMode,
1771
+ commonjsMeta
1709
1772
  );
1773
+ const usesRequireWrapper = commonjsMeta.isCommonJS === IS_WRAPPED_COMMONJS;
1710
1774
  const exportBlock = isEsModule
1711
1775
  ? ''
1712
1776
  : rewriteExportsAndGetExportsBlock(
@@ -1759,15 +1823,12 @@ function ${requireName} () {
1759
1823
  code: magicString.toString(),
1760
1824
  map: sourceMap ? magicString.generateMap() : null,
1761
1825
  syntheticNamedExports: isEsModule || usesRequireWrapper ? false : '__moduleExports',
1762
- meta: {
1763
- commonjs: {
1764
- isCommonJS: !isEsModule && (usesRequireWrapper ? IS_WRAPPED_COMMONJS : true),
1765
- isMixedModule: isEsModule
1766
- }
1767
- }
1826
+ meta: { commonjs: commonjsMeta }
1768
1827
  };
1769
1828
  }
1770
1829
 
1830
+ const PLUGIN_NAME = 'commonjs';
1831
+
1771
1832
  function commonjs(options = {}) {
1772
1833
  const {
1773
1834
  ignoreGlobal,
@@ -1795,11 +1856,6 @@ function commonjs(options = {}) {
1795
1856
  const defaultIsModuleExports =
1796
1857
  typeof options.defaultIsModuleExports === 'boolean' ? options.defaultIsModuleExports : 'auto';
1797
1858
 
1798
- const {
1799
- resolveRequireSourcesAndGetMeta,
1800
- getWrappedIds,
1801
- isRequiredId
1802
- } = getResolveRequireSourcesAndGetMeta(extensions, detectCyclesAndConditional);
1803
1859
  const dynamicRequireRoot =
1804
1860
  typeof options.dynamicRequireRoot === 'string'
1805
1861
  ? resolve(options.dynamicRequireRoot)
@@ -1810,9 +1866,6 @@ function commonjs(options = {}) {
1810
1866
  );
1811
1867
  const isDynamicRequireModulesEnabled = dynamicRequireModules.size > 0;
1812
1868
 
1813
- const esModulesWithDefaultExport = new Set();
1814
- const esModulesWithNamedExports = new Set();
1815
-
1816
1869
  const ignoreRequire =
1817
1870
  typeof options.ignore === 'function'
1818
1871
  ? options.ignore
@@ -1840,25 +1893,31 @@ function commonjs(options = {}) {
1840
1893
 
1841
1894
  const sourceMap = options.sourceMap !== false;
1842
1895
 
1896
+ // Initialized in buildStart
1897
+ let requireResolver;
1898
+
1843
1899
  function transformAndCheckExports(code, id) {
1844
1900
  const { isEsModule, hasDefaultExport, hasNamedExports, ast } = analyzeTopLevelStatements(
1845
1901
  this.parse,
1846
1902
  code,
1847
1903
  id
1848
1904
  );
1905
+
1906
+ const commonjsMeta = this.getModuleInfo(id).meta.commonjs || {};
1849
1907
  if (hasDefaultExport) {
1850
- esModulesWithDefaultExport.add(id);
1908
+ commonjsMeta.hasDefaultExport = true;
1851
1909
  }
1852
1910
  if (hasNamedExports) {
1853
- esModulesWithNamedExports.add(id);
1911
+ commonjsMeta.hasNamedExports = true;
1854
1912
  }
1855
1913
 
1856
1914
  if (
1857
1915
  !dynamicRequireModules.has(normalizePathSlashes(id)) &&
1858
- (!(hasCjsKeywords(code, ignoreGlobal) || isRequiredId(id)) ||
1916
+ (!(hasCjsKeywords(code, ignoreGlobal) || requireResolver.isRequiredId(id)) ||
1859
1917
  (isEsModule && !options.transformMixedEsModules))
1860
1918
  ) {
1861
- return { meta: { commonjs: { isCommonJS: false } } };
1919
+ commonjsMeta.isCommonJS = false;
1920
+ return { meta: { commonjs: commonjsMeta } };
1862
1921
  }
1863
1922
 
1864
1923
  const needsRequireWrapper =
@@ -1897,14 +1956,15 @@ function commonjs(options = {}) {
1897
1956
  ast,
1898
1957
  defaultIsModuleExports,
1899
1958
  needsRequireWrapper,
1900
- resolveRequireSourcesAndGetMeta(this),
1901
- isRequiredId(id),
1902
- checkDynamicRequire
1959
+ requireResolver.resolveRequireSourcesAndUpdateMeta(this),
1960
+ requireResolver.isRequiredId(id),
1961
+ checkDynamicRequire,
1962
+ commonjsMeta
1903
1963
  );
1904
1964
  }
1905
1965
 
1906
1966
  return {
1907
- name: 'commonjs',
1967
+ name: PLUGIN_NAME,
1908
1968
 
1909
1969
  version,
1910
1970
 
@@ -1912,7 +1972,7 @@ function commonjs(options = {}) {
1912
1972
  // We inject the resolver in the beginning so that "catch-all-resolver" like node-resolver
1913
1973
  // do not prevent our plugin from resolving entry points ot proxies.
1914
1974
  const plugins = Array.isArray(rawOptions.plugins)
1915
- ? rawOptions.plugins
1975
+ ? [...rawOptions.plugins]
1916
1976
  : rawOptions.plugins
1917
1977
  ? [rawOptions.plugins]
1918
1978
  : [];
@@ -1934,11 +1994,12 @@ function commonjs(options = {}) {
1934
1994
  'The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.'
1935
1995
  );
1936
1996
  }
1997
+ requireResolver = getRequireResolver(extensions, detectCyclesAndConditional);
1937
1998
  },
1938
1999
 
1939
2000
  buildEnd() {
1940
2001
  if (options.strictRequires === 'debug') {
1941
- const wrappedIds = getWrappedIds();
2002
+ const wrappedIds = requireResolver.getWrappedIds();
1942
2003
  if (wrappedIds.length) {
1943
2004
  this.warn({
1944
2005
  code: 'WRAPPED_IDS',
@@ -1987,6 +2048,11 @@ function commonjs(options = {}) {
1987
2048
  );
1988
2049
  }
1989
2050
 
2051
+ // entry suffix is just appended to not mess up relative external resolution
2052
+ if (id.endsWith(ENTRY_SUFFIX)) {
2053
+ return getEntryProxy(id.slice(0, -ENTRY_SUFFIX.length), defaultIsModuleExports, this.load);
2054
+ }
2055
+
1990
2056
  if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
1991
2057
  return getEsImportProxy(unwrapId(id, ES_IMPORT_SUFFIX), defaultIsModuleExports);
1992
2058
  }
@@ -2002,18 +2068,16 @@ function commonjs(options = {}) {
2002
2068
 
2003
2069
  if (isWrappedId(id, PROXY_SUFFIX)) {
2004
2070
  const actualId = unwrapId(id, PROXY_SUFFIX);
2005
- return getStaticRequireProxy(
2006
- actualId,
2007
- getRequireReturnsDefault(actualId),
2008
- esModulesWithDefaultExport,
2009
- esModulesWithNamedExports,
2010
- this.load
2011
- );
2071
+ return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
2012
2072
  }
2013
2073
 
2014
2074
  return null;
2015
2075
  },
2016
2076
 
2077
+ shouldTransformCachedModule(...args) {
2078
+ return requireResolver.shouldTransformCachedModule.call(this, ...args);
2079
+ },
2080
+
2017
2081
  transform(code, id) {
2018
2082
  const extName = extname(id);
2019
2083
  if (extName !== '.cjs' && (!filter(id) || !extensions.includes(extName))) {
@@ -2030,4 +2094,4 @@ function commonjs(options = {}) {
2030
2094
  }
2031
2095
 
2032
2096
  export { commonjs as default };
2033
- //# sourceMappingURL=index.es.js.map
2097
+ //# sourceMappingURL=index.js.map