@rollup/plugin-commonjs 28.0.8 → 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 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.8";
14
+ var version = "28.0.9";
15
15
  var peerDependencies = {
16
16
  rollup: "^2.68.0||^3.0.0||^4.0.0"
17
17
  };
@@ -841,16 +841,21 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
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
843
  const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
844
- if (
845
- parentMeta.initialCommonJSType === IS_WRAPPED_COMMONJS &&
846
- !allowProxy &&
847
- isExternalWrapped
848
- ) {
844
+ let resolvedDependencyId = dependencyId;
845
+ if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
849
846
  const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
850
847
  if (actualExternalId.startsWith('node:')) {
851
848
  isCommonJS = IS_WRAPPED_COMMONJS;
852
849
  parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
853
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;
858
+ }
854
859
  }
855
860
  const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
856
861
  fullyAnalyzedModules[dependencyId] = true;
@@ -871,8 +876,8 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
871
876
  wrappedModuleSideEffects,
872
877
  source: sources[index].source,
873
878
  id: allowProxy
874
- ? wrapId(dependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
875
- : dependencyId,
879
+ ? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
880
+ : resolvedDependencyId,
876
881
  isCommonJS
877
882
  };
878
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.8";
10
+ var version = "28.0.9";
11
11
  var peerDependencies = {
12
12
  rollup: "^2.68.0||^3.0.0||^4.0.0"
13
13
  };
@@ -837,16 +837,21 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
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
839
  const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
840
- if (
841
- parentMeta.initialCommonJSType === IS_WRAPPED_COMMONJS &&
842
- !allowProxy &&
843
- isExternalWrapped
844
- ) {
840
+ let resolvedDependencyId = dependencyId;
841
+ if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
845
842
  const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
846
843
  if (actualExternalId.startsWith('node:')) {
847
844
  isCommonJS = IS_WRAPPED_COMMONJS;
848
845
  parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
849
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;
854
+ }
850
855
  }
851
856
  const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
852
857
  fullyAnalyzedModules[dependencyId] = true;
@@ -867,8 +872,8 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
867
872
  wrappedModuleSideEffects,
868
873
  source: sources[index].source,
869
874
  id: allowProxy
870
- ? wrapId(dependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
871
- : dependencyId,
875
+ ? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX)
876
+ : resolvedDependencyId,
872
877
  isCommonJS
873
878
  };
874
879
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-commonjs",
3
- "version": "28.0.8",
3
+ "version": "28.0.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },