@rollup/plugin-commonjs 28.0.7 → 28.0.9
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 +31 -13
- package/dist/es/index.js +31 -13
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var estreeWalker = require('estree-walker');
|
|
|
11
11
|
var MagicString = require('magic-string');
|
|
12
12
|
var isReference = require('is-reference');
|
|
13
13
|
|
|
14
|
-
var version = "28.0.
|
|
14
|
+
var version = "28.0.9";
|
|
15
15
|
var peerDependencies = {
|
|
16
16
|
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
|
17
17
|
};
|
|
@@ -840,26 +840,44 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
|
|
|
840
840
|
getTypeForFullyAnalyzedModule(dependencyId));
|
|
841
841
|
// Special-case external Node built-ins to be handled via a lazy __require
|
|
842
842
|
// helper instead of hoisted ESM imports when strict wrapping is used.
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const actualId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
849
|
-
const isNodeBuiltin = actualId.startsWith('node:');
|
|
850
|
-
if (isNodeBuiltin) {
|
|
843
|
+
const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
|
|
844
|
+
let resolvedDependencyId = dependencyId;
|
|
845
|
+
if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
|
|
846
|
+
const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
847
|
+
if (actualExternalId.startsWith('node:')) {
|
|
851
848
|
isCommonJS = IS_WRAPPED_COMMONJS;
|
|
849
|
+
parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
|
|
850
|
+
}
|
|
851
|
+
} else if (isExternalWrapped && !allowProxy) {
|
|
852
|
+
// If the parent is not wrapped but the dependency is a node: builtin external,
|
|
853
|
+
// unwrap the EXTERNAL_SUFFIX so it's treated as a normal external.
|
|
854
|
+
// This avoids trying to load the lazy __require proxy for non-wrapped contexts.
|
|
855
|
+
const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
856
|
+
if (actualExternalId.startsWith('node:')) {
|
|
857
|
+
resolvedDependencyId = actualExternalId;
|
|
852
858
|
}
|
|
853
859
|
}
|
|
854
860
|
const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
|
|
855
861
|
fullyAnalyzedModules[dependencyId] = true;
|
|
862
|
+
const moduleInfo =
|
|
863
|
+
isWrappedCommonJS && !isExternalWrapped
|
|
864
|
+
? rollupContext.getModuleInfo(dependencyId)
|
|
865
|
+
: null;
|
|
866
|
+
// For wrapped dependencies, annotate the generated require call as pure only
|
|
867
|
+
// when Rollup has module info and it explicitly reports no side effects.
|
|
868
|
+
// Note: For external Node built-ins (handled via EXTERNAL_SUFFIX), the module
|
|
869
|
+
// has not been loaded yet at this point and getModuleInfo returns null.
|
|
870
|
+
// Default to side effects = true in that case to be safe.
|
|
871
|
+
// Preserve Rollup's tri-state semantics (true | false | 'no-treeshake') when available.
|
|
872
|
+
const wrappedModuleSideEffects = !isWrappedCommonJS
|
|
873
|
+
? false
|
|
874
|
+
: moduleInfo?.moduleSideEffects ?? true;
|
|
856
875
|
return {
|
|
857
|
-
wrappedModuleSideEffects
|
|
858
|
-
isWrappedCommonJS && rollupContext.getModuleInfo(dependencyId).moduleSideEffects,
|
|
876
|
+
wrappedModuleSideEffects,
|
|
859
877
|
source: sources[index].source,
|
|
860
878
|
id: allowProxy
|
|
861
|
-
? wrapId(
|
|
862
|
-
:
|
|
879
|
+
? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
|
|
880
|
+
: resolvedDependencyId,
|
|
863
881
|
isCommonJS
|
|
864
882
|
};
|
|
865
883
|
});
|
package/dist/es/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { walk } from 'estree-walker';
|
|
|
7
7
|
import MagicString from 'magic-string';
|
|
8
8
|
import isReference from 'is-reference';
|
|
9
9
|
|
|
10
|
-
var version = "28.0.
|
|
10
|
+
var version = "28.0.9";
|
|
11
11
|
var peerDependencies = {
|
|
12
12
|
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
|
13
13
|
};
|
|
@@ -836,26 +836,44 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
|
|
|
836
836
|
getTypeForFullyAnalyzedModule(dependencyId));
|
|
837
837
|
// Special-case external Node built-ins to be handled via a lazy __require
|
|
838
838
|
// helper instead of hoisted ESM imports when strict wrapping is used.
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
const actualId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
845
|
-
const isNodeBuiltin = actualId.startsWith('node:');
|
|
846
|
-
if (isNodeBuiltin) {
|
|
839
|
+
const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
|
|
840
|
+
let resolvedDependencyId = dependencyId;
|
|
841
|
+
if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
|
|
842
|
+
const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
843
|
+
if (actualExternalId.startsWith('node:')) {
|
|
847
844
|
isCommonJS = IS_WRAPPED_COMMONJS;
|
|
845
|
+
parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
|
|
846
|
+
}
|
|
847
|
+
} else if (isExternalWrapped && !allowProxy) {
|
|
848
|
+
// If the parent is not wrapped but the dependency is a node: builtin external,
|
|
849
|
+
// unwrap the EXTERNAL_SUFFIX so it's treated as a normal external.
|
|
850
|
+
// This avoids trying to load the lazy __require proxy for non-wrapped contexts.
|
|
851
|
+
const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
|
|
852
|
+
if (actualExternalId.startsWith('node:')) {
|
|
853
|
+
resolvedDependencyId = actualExternalId;
|
|
848
854
|
}
|
|
849
855
|
}
|
|
850
856
|
const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
|
|
851
857
|
fullyAnalyzedModules[dependencyId] = true;
|
|
858
|
+
const moduleInfo =
|
|
859
|
+
isWrappedCommonJS && !isExternalWrapped
|
|
860
|
+
? rollupContext.getModuleInfo(dependencyId)
|
|
861
|
+
: null;
|
|
862
|
+
// For wrapped dependencies, annotate the generated require call as pure only
|
|
863
|
+
// when Rollup has module info and it explicitly reports no side effects.
|
|
864
|
+
// Note: For external Node built-ins (handled via EXTERNAL_SUFFIX), the module
|
|
865
|
+
// has not been loaded yet at this point and getModuleInfo returns null.
|
|
866
|
+
// Default to side effects = true in that case to be safe.
|
|
867
|
+
// Preserve Rollup's tri-state semantics (true | false | 'no-treeshake') when available.
|
|
868
|
+
const wrappedModuleSideEffects = !isWrappedCommonJS
|
|
869
|
+
? false
|
|
870
|
+
: moduleInfo?.moduleSideEffects ?? true;
|
|
852
871
|
return {
|
|
853
|
-
wrappedModuleSideEffects
|
|
854
|
-
isWrappedCommonJS && rollupContext.getModuleInfo(dependencyId).moduleSideEffects,
|
|
872
|
+
wrappedModuleSideEffects,
|
|
855
873
|
source: sources[index].source,
|
|
856
874
|
id: allowProxy
|
|
857
|
-
? wrapId(
|
|
858
|
-
:
|
|
875
|
+
? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
|
|
876
|
+
: resolvedDependencyId,
|
|
859
877
|
isCommonJS
|
|
860
878
|
};
|
|
861
879
|
});
|