@rollup/plugin-commonjs 22.0.0-10 → 22.0.0-11
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.
- package/dist/cjs/index.js +26 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +26 -15
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
|
|
|
16
16
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
17
17
|
var isReference__default = /*#__PURE__*/_interopDefaultLegacy(isReference);
|
|
18
18
|
|
|
19
|
-
var version = "
|
|
19
|
+
var version = "22.0.0-11";
|
|
20
20
|
var peerDependencies = {
|
|
21
21
|
rollup: "^2.67.0"
|
|
22
22
|
};
|
|
@@ -597,6 +597,9 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
597
597
|
return false;
|
|
598
598
|
};
|
|
599
599
|
|
|
600
|
+
// Once a module is listed here, its type (wrapped or not) is fixed any may
|
|
601
|
+
// not change for the rest of the current build, to not break already
|
|
602
|
+
// transformed modules.
|
|
600
603
|
const fullyAnalyzedModules = Object.create(null);
|
|
601
604
|
|
|
602
605
|
const getTypeForFullyAnalyzedModule = (id) => {
|
|
@@ -604,7 +607,6 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
604
607
|
if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) {
|
|
605
608
|
return knownType;
|
|
606
609
|
}
|
|
607
|
-
fullyAnalyzedModules[id] = true;
|
|
608
610
|
if (isCyclic(id)) {
|
|
609
611
|
return (knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS);
|
|
610
612
|
}
|
|
@@ -612,13 +614,11 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
612
614
|
};
|
|
613
615
|
|
|
614
616
|
const setInitialParentType = (id, initialCommonJSType) => {
|
|
615
|
-
//
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
knownCjsModuleTypes[id] =
|
|
620
|
-
? knownCjsModuleTypes[id]
|
|
621
|
-
: initialCommonJSType;
|
|
617
|
+
// Fully analyzed modules may never change type
|
|
618
|
+
if (fullyAnalyzedModules[id]) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
knownCjsModuleTypes[id] = initialCommonJSType;
|
|
622
622
|
if (
|
|
623
623
|
detectCyclesAndConditional &&
|
|
624
624
|
knownCjsModuleTypes[id] === true &&
|
|
@@ -629,7 +629,7 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
631
|
|
|
632
|
-
const
|
|
632
|
+
const analyzeRequiredModule = async (parentId, resolved, isConditional, loadModule) => {
|
|
633
633
|
const childId = resolved.id;
|
|
634
634
|
requiredIds[childId] = true;
|
|
635
635
|
if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) {
|
|
@@ -638,9 +638,10 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
638
638
|
|
|
639
639
|
getDependencies(parentId).add(childId);
|
|
640
640
|
if (!isCyclic(childId)) {
|
|
641
|
-
// This makes sure the current transform handler waits for all direct
|
|
642
|
-
// loaded and transformed and therefore for all
|
|
643
|
-
// loaded as well so that all
|
|
641
|
+
// This makes sure the current transform handler waits for all direct
|
|
642
|
+
// dependencies to be loaded and transformed and therefore for all
|
|
643
|
+
// transitive CommonJS dependencies to be loaded as well so that all
|
|
644
|
+
// cycles have been found and knownCjsModuleTypes is reliable.
|
|
644
645
|
await loadModule(resolved);
|
|
645
646
|
}
|
|
646
647
|
};
|
|
@@ -659,7 +660,7 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
659
660
|
setInitialParentType(parentId, parentMeta.initialCommonJSType);
|
|
660
661
|
await Promise.all(
|
|
661
662
|
parentMeta.requires.map(({ resolved, isConditional }) =>
|
|
662
|
-
|
|
663
|
+
analyzeRequiredModule(parentId, resolved, isConditional, this.load)
|
|
663
664
|
)
|
|
664
665
|
);
|
|
665
666
|
if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) {
|
|
@@ -672,6 +673,14 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
672
673
|
return true;
|
|
673
674
|
}
|
|
674
675
|
}
|
|
676
|
+
// Now that we decided to go with the cached copy, neither the parent
|
|
677
|
+
// module nor any of its children may change types anymore
|
|
678
|
+
fullyAnalyzedModules[parentId] = true;
|
|
679
|
+
for (const {
|
|
680
|
+
resolved: { id }
|
|
681
|
+
} of parentMeta.requires) {
|
|
682
|
+
fullyAnalyzedModules[id] = true;
|
|
683
|
+
}
|
|
675
684
|
return false;
|
|
676
685
|
},
|
|
677
686
|
/* eslint-disable no-param-reassign */
|
|
@@ -703,16 +712,18 @@ function getRequireResolver(extensions, detectCyclesAndConditional) {
|
|
|
703
712
|
return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false };
|
|
704
713
|
}
|
|
705
714
|
parentMeta.requires.push({ resolved, isConditional });
|
|
706
|
-
await
|
|
715
|
+
await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
|
|
707
716
|
return { id: childId, allowProxy: true };
|
|
708
717
|
})
|
|
709
718
|
);
|
|
710
719
|
parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId);
|
|
720
|
+
fullyAnalyzedModules[parentId] = true;
|
|
711
721
|
return requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
|
|
712
722
|
// eslint-disable-next-line no-multi-assign
|
|
713
723
|
const isCommonJS = (parentMeta.isRequiredCommonJS[
|
|
714
724
|
dependencyId
|
|
715
725
|
] = getTypeForFullyAnalyzedModule(dependencyId));
|
|
726
|
+
fullyAnalyzedModules[dependencyId] = true;
|
|
716
727
|
return {
|
|
717
728
|
source: sources[index].source,
|
|
718
729
|
id: allowProxy
|