@rollup/plugin-commonjs 25.0.0 → 25.0.2
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 +11 -6
- package/dist/es/index.js +11 -6
- 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 = "25.0.
|
|
14
|
+
var version = "25.0.2";
|
|
15
15
|
var peerDependencies = {
|
|
16
16
|
rollup: "^2.68.0||^3.0.0"
|
|
17
17
|
};
|
|
@@ -1497,6 +1497,7 @@ async function transformCommonjs(
|
|
|
1497
1497
|
let scope = pluginutils.attachScopes(ast, 'scope');
|
|
1498
1498
|
let lexicalDepth = 0;
|
|
1499
1499
|
let programDepth = 0;
|
|
1500
|
+
let classBodyDepth = 0;
|
|
1500
1501
|
let currentTryBlockEnd = null;
|
|
1501
1502
|
let shouldWrap = false;
|
|
1502
1503
|
|
|
@@ -1679,6 +1680,9 @@ async function transformCommonjs(
|
|
|
1679
1680
|
}
|
|
1680
1681
|
return;
|
|
1681
1682
|
}
|
|
1683
|
+
case 'ClassBody':
|
|
1684
|
+
classBodyDepth += 1;
|
|
1685
|
+
return;
|
|
1682
1686
|
case 'ConditionalExpression':
|
|
1683
1687
|
case 'IfStatement':
|
|
1684
1688
|
// skip dead branches
|
|
@@ -1775,7 +1779,7 @@ async function transformCommonjs(
|
|
|
1775
1779
|
return;
|
|
1776
1780
|
case 'ThisExpression':
|
|
1777
1781
|
// rewrite top-level `this` as `commonjsHelpers.commonjsGlobal`
|
|
1778
|
-
if (lexicalDepth === 0) {
|
|
1782
|
+
if (lexicalDepth === 0 && !classBodyDepth) {
|
|
1779
1783
|
uses.global = true;
|
|
1780
1784
|
if (!ignoreGlobal) {
|
|
1781
1785
|
replacedGlobal.push(node);
|
|
@@ -1826,6 +1830,7 @@ async function transformCommonjs(
|
|
|
1826
1830
|
programDepth -= 1;
|
|
1827
1831
|
if (node.scope) scope = scope.parent;
|
|
1828
1832
|
if (functionType.test(node.type)) lexicalDepth -= 1;
|
|
1833
|
+
if (node.type === 'ClassBody') classBodyDepth -= 1;
|
|
1829
1834
|
}
|
|
1830
1835
|
});
|
|
1831
1836
|
|
|
@@ -2092,15 +2097,15 @@ function commonjs(options = {}) {
|
|
|
2092
2097
|
!isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
|
|
2093
2098
|
|
|
2094
2099
|
const checkDynamicRequire = (position) => {
|
|
2095
|
-
const
|
|
2100
|
+
const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
|
|
2096
2101
|
|
|
2097
|
-
if (normalizedId.indexOf(
|
|
2102
|
+
if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) {
|
|
2098
2103
|
this.error(
|
|
2099
2104
|
{
|
|
2100
2105
|
code: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT',
|
|
2101
2106
|
normalizedId,
|
|
2102
|
-
|
|
2103
|
-
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${
|
|
2107
|
+
normalizedDynamicRequireRoot,
|
|
2108
|
+
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${path.dirname(
|
|
2104
2109
|
normalizedId
|
|
2105
2110
|
)}" or one of its parent directories.`
|
|
2106
2111
|
},
|
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 = "25.0.
|
|
10
|
+
var version = "25.0.2";
|
|
11
11
|
var peerDependencies = {
|
|
12
12
|
rollup: "^2.68.0||^3.0.0"
|
|
13
13
|
};
|
|
@@ -1493,6 +1493,7 @@ async function transformCommonjs(
|
|
|
1493
1493
|
let scope = attachScopes(ast, 'scope');
|
|
1494
1494
|
let lexicalDepth = 0;
|
|
1495
1495
|
let programDepth = 0;
|
|
1496
|
+
let classBodyDepth = 0;
|
|
1496
1497
|
let currentTryBlockEnd = null;
|
|
1497
1498
|
let shouldWrap = false;
|
|
1498
1499
|
|
|
@@ -1675,6 +1676,9 @@ async function transformCommonjs(
|
|
|
1675
1676
|
}
|
|
1676
1677
|
return;
|
|
1677
1678
|
}
|
|
1679
|
+
case 'ClassBody':
|
|
1680
|
+
classBodyDepth += 1;
|
|
1681
|
+
return;
|
|
1678
1682
|
case 'ConditionalExpression':
|
|
1679
1683
|
case 'IfStatement':
|
|
1680
1684
|
// skip dead branches
|
|
@@ -1771,7 +1775,7 @@ async function transformCommonjs(
|
|
|
1771
1775
|
return;
|
|
1772
1776
|
case 'ThisExpression':
|
|
1773
1777
|
// rewrite top-level `this` as `commonjsHelpers.commonjsGlobal`
|
|
1774
|
-
if (lexicalDepth === 0) {
|
|
1778
|
+
if (lexicalDepth === 0 && !classBodyDepth) {
|
|
1775
1779
|
uses.global = true;
|
|
1776
1780
|
if (!ignoreGlobal) {
|
|
1777
1781
|
replacedGlobal.push(node);
|
|
@@ -1822,6 +1826,7 @@ async function transformCommonjs(
|
|
|
1822
1826
|
programDepth -= 1;
|
|
1823
1827
|
if (node.scope) scope = scope.parent;
|
|
1824
1828
|
if (functionType.test(node.type)) lexicalDepth -= 1;
|
|
1829
|
+
if (node.type === 'ClassBody') classBodyDepth -= 1;
|
|
1825
1830
|
}
|
|
1826
1831
|
});
|
|
1827
1832
|
|
|
@@ -2088,15 +2093,15 @@ function commonjs(options = {}) {
|
|
|
2088
2093
|
!isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
|
|
2089
2094
|
|
|
2090
2095
|
const checkDynamicRequire = (position) => {
|
|
2091
|
-
const
|
|
2096
|
+
const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
|
|
2092
2097
|
|
|
2093
|
-
if (normalizedId.indexOf(
|
|
2098
|
+
if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) {
|
|
2094
2099
|
this.error(
|
|
2095
2100
|
{
|
|
2096
2101
|
code: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT',
|
|
2097
2102
|
normalizedId,
|
|
2098
|
-
|
|
2099
|
-
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${
|
|
2103
|
+
normalizedDynamicRequireRoot,
|
|
2104
|
+
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${dirname(
|
|
2100
2105
|
normalizedId
|
|
2101
2106
|
)}" or one of its parent directories.`
|
|
2102
2107
|
},
|