@rollup/plugin-commonjs 25.0.4 → 25.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.
package/dist/cjs/index.js CHANGED
@@ -11,9 +11,9 @@ var estreeWalker = require('estree-walker');
11
11
  var MagicString = require('magic-string');
12
12
  var isReference = require('is-reference');
13
13
 
14
- var version = "25.0.4";
14
+ var version = "25.0.5";
15
15
  var peerDependencies = {
16
- rollup: "^2.68.0||^3.0.0"
16
+ rollup: "^2.68.0||^3.0.0||^4.0.0"
17
17
  };
18
18
 
19
19
  function tryParse(parse, code, id) {
@@ -36,6 +36,7 @@ function hasCjsKeywords(code, ignoreGlobal) {
36
36
 
37
37
  /* eslint-disable no-underscore-dangle */
38
38
 
39
+
39
40
  function analyzeTopLevelStatements(parse, code, id) {
40
41
  const ast = tryParse(parse, code, id);
41
42
 
@@ -82,6 +83,7 @@ function analyzeTopLevelStatements(parse, code, id) {
82
83
 
83
84
  /* eslint-disable import/prefer-default-export */
84
85
 
86
+
85
87
  function deconflict(scopes, globals, identifier) {
86
88
  let i = 1;
87
89
  let deconflicted = pluginutils.makeLegalIdentifier(identifier);
@@ -470,6 +472,7 @@ function getEsImportProxy(id, defaultIsModuleExports) {
470
472
 
471
473
  /* eslint-disable no-param-reassign, no-undefined */
472
474
 
475
+
473
476
  function getCandidatesForExtension(resolved, extension) {
474
477
  return [resolved + extension, `${resolved}${path.sep}index${extension}`];
475
478
  }
@@ -780,6 +783,7 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
780
783
  currentlyResolvingForParent.add(source);
781
784
  const resolved =
782
785
  (await rollupContext.resolve(source, parentId, {
786
+ skipSelf: false,
783
787
  custom: { 'node-resolve': { isRequire: true } }
784
788
  })) || resolveExtensions(source, parentId, extensions);
785
789
  currentlyResolvingForParent.delete(source);
@@ -1448,6 +1452,7 @@ function getGenerateRequireName() {
1448
1452
 
1449
1453
  /* eslint-disable no-param-reassign, no-shadow, no-underscore-dangle, no-continue */
1450
1454
 
1455
+
1451
1456
  const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
1452
1457
 
1453
1458
  const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
@@ -1718,6 +1723,9 @@ async function transformCommonjs(
1718
1723
  }
1719
1724
  if (!ignoreDynamicRequires) {
1720
1725
  if (isShorthandProperty(parent)) {
1726
+ // as key and value are the same object, isReference regards
1727
+ // both as references, so we need to skip now
1728
+ skippedNodes.add(parent.value);
1721
1729
  magicString.prependRight(node.start, 'require: ');
1722
1730
  }
1723
1731
  replacedDynamicRequires.push(node);
@@ -2260,7 +2268,7 @@ function commonjs(options = {}) {
2260
2268
  try {
2261
2269
  return transformAndCheckExports.call(this, code, id);
2262
2270
  } catch (err) {
2263
- return this.error(err, err.loc);
2271
+ return this.error(err, err.pos);
2264
2272
  }
2265
2273
  }
2266
2274
  };
package/dist/es/index.js CHANGED
@@ -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 = "25.0.4";
10
+ var version = "25.0.5";
11
11
  var peerDependencies = {
12
- rollup: "^2.68.0||^3.0.0"
12
+ rollup: "^2.68.0||^3.0.0||^4.0.0"
13
13
  };
14
14
 
15
15
  function tryParse(parse, code, id) {
@@ -32,6 +32,7 @@ function hasCjsKeywords(code, ignoreGlobal) {
32
32
 
33
33
  /* eslint-disable no-underscore-dangle */
34
34
 
35
+
35
36
  function analyzeTopLevelStatements(parse, code, id) {
36
37
  const ast = tryParse(parse, code, id);
37
38
 
@@ -78,6 +79,7 @@ function analyzeTopLevelStatements(parse, code, id) {
78
79
 
79
80
  /* eslint-disable import/prefer-default-export */
80
81
 
82
+
81
83
  function deconflict(scopes, globals, identifier) {
82
84
  let i = 1;
83
85
  let deconflicted = makeLegalIdentifier(identifier);
@@ -466,6 +468,7 @@ function getEsImportProxy(id, defaultIsModuleExports) {
466
468
 
467
469
  /* eslint-disable no-param-reassign, no-undefined */
468
470
 
471
+
469
472
  function getCandidatesForExtension(resolved, extension) {
470
473
  return [resolved + extension, `${resolved}${sep}index${extension}`];
471
474
  }
@@ -776,6 +779,7 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
776
779
  currentlyResolvingForParent.add(source);
777
780
  const resolved =
778
781
  (await rollupContext.resolve(source, parentId, {
782
+ skipSelf: false,
779
783
  custom: { 'node-resolve': { isRequire: true } }
780
784
  })) || resolveExtensions(source, parentId, extensions);
781
785
  currentlyResolvingForParent.delete(source);
@@ -1444,6 +1448,7 @@ function getGenerateRequireName() {
1444
1448
 
1445
1449
  /* eslint-disable no-param-reassign, no-shadow, no-underscore-dangle, no-continue */
1446
1450
 
1451
+
1447
1452
  const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
1448
1453
 
1449
1454
  const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
@@ -1714,6 +1719,9 @@ async function transformCommonjs(
1714
1719
  }
1715
1720
  if (!ignoreDynamicRequires) {
1716
1721
  if (isShorthandProperty(parent)) {
1722
+ // as key and value are the same object, isReference regards
1723
+ // both as references, so we need to skip now
1724
+ skippedNodes.add(parent.value);
1717
1725
  magicString.prependRight(node.start, 'require: ');
1718
1726
  }
1719
1727
  replacedDynamicRequires.push(node);
@@ -2256,7 +2264,7 @@ function commonjs(options = {}) {
2256
2264
  try {
2257
2265
  return transformAndCheckExports.call(this, code, id);
2258
2266
  } catch (err) {
2259
- return this.error(err, err.loc);
2267
+ return this.error(err, err.pos);
2260
2268
  }
2261
2269
  }
2262
2270
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-commonjs",
3
- "version": "25.0.4",
3
+ "version": "25.0.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,7 +54,7 @@
54
54
  "require"
55
55
  ],
56
56
  "peerDependencies": {
57
- "rollup": "^2.68.0||^3.0.0"
57
+ "rollup": "^2.68.0||^3.0.0||^4.0.0"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "rollup": {
@@ -74,7 +74,7 @@
74
74
  "@rollup/plugin-node-resolve": "^15.0.0",
75
75
  "locate-character": "^2.0.5",
76
76
  "require-relative": "^0.8.7",
77
- "rollup": "^3.19.0",
77
+ "rollup": "^4.0.0-24",
78
78
  "shx": "^0.3.4",
79
79
  "source-map": "^0.7.4",
80
80
  "source-map-support": "^0.5.21",