@rollup/plugin-commonjs 22.0.0-13 → 22.0.0-14
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/CHANGELOG.md +16 -0
- package/dist/cjs/index.js +15 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +15 -6
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @rollup/plugin-commonjs ChangeLog
|
|
2
2
|
|
|
3
|
+
## v21.0.3
|
|
4
|
+
|
|
5
|
+
_2022-03-27_
|
|
6
|
+
|
|
7
|
+
### Updates
|
|
8
|
+
|
|
9
|
+
- docs: sync required rollup version (#1118)
|
|
10
|
+
|
|
11
|
+
## v21.0.2
|
|
12
|
+
|
|
13
|
+
_2022-02-23_
|
|
14
|
+
|
|
15
|
+
### Updates
|
|
16
|
+
|
|
17
|
+
- chore: transpile dynamic helper to ES5 (#1082)
|
|
18
|
+
|
|
3
19
|
## v21.0.1
|
|
4
20
|
|
|
5
21
|
_2021-10-19_
|
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 = "22.0.0-
|
|
19
|
+
var version = "22.0.0-14";
|
|
20
20
|
var peerDependencies = {
|
|
21
21
|
rollup: "^2.68.0"
|
|
22
22
|
};
|
|
@@ -1211,7 +1211,7 @@ function getRequireStringArg(node) {
|
|
|
1211
1211
|
function getRequireHandlers() {
|
|
1212
1212
|
const requireExpressions = [];
|
|
1213
1213
|
|
|
1214
|
-
function
|
|
1214
|
+
function addRequireExpression(
|
|
1215
1215
|
sourceId,
|
|
1216
1216
|
node,
|
|
1217
1217
|
scope,
|
|
@@ -1291,7 +1291,7 @@ function getRequireHandlers() {
|
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
1293
|
return {
|
|
1294
|
-
|
|
1294
|
+
addRequireExpression,
|
|
1295
1295
|
rewriteRequireExpressionsAndGetImportBlock
|
|
1296
1296
|
};
|
|
1297
1297
|
}
|
|
@@ -1417,7 +1417,7 @@ async function transformCommonjs(
|
|
|
1417
1417
|
// unconditional require elsewhere.
|
|
1418
1418
|
let currentConditionalNodeEnd = null;
|
|
1419
1419
|
const conditionalNodes = new Set();
|
|
1420
|
-
const {
|
|
1420
|
+
const { addRequireExpression, rewriteRequireExpressionsAndGetImportBlock } = getRequireHandlers();
|
|
1421
1421
|
|
|
1422
1422
|
// See which names are assigned to. This is necessary to prevent
|
|
1423
1423
|
// illegally replacing `var foo = require('foo')` with `import foo from 'foo'`,
|
|
@@ -1572,14 +1572,22 @@ async function transformCommonjs(
|
|
|
1572
1572
|
const requireStringArg = getRequireStringArg(node);
|
|
1573
1573
|
if (!ignoreRequire(requireStringArg)) {
|
|
1574
1574
|
const usesReturnValue = parent.type !== 'ExpressionStatement';
|
|
1575
|
-
|
|
1575
|
+
const toBeRemoved =
|
|
1576
|
+
parent.type === 'ExpressionStatement' &&
|
|
1577
|
+
(!currentConditionalNodeEnd ||
|
|
1578
|
+
// We should completely remove requires directly in a try-catch
|
|
1579
|
+
// so that Rollup can remove up the try-catch
|
|
1580
|
+
(currentTryBlockEnd !== null && currentTryBlockEnd < currentConditionalNodeEnd))
|
|
1581
|
+
? parent
|
|
1582
|
+
: node;
|
|
1583
|
+
addRequireExpression(
|
|
1576
1584
|
requireStringArg,
|
|
1577
1585
|
node,
|
|
1578
1586
|
scope,
|
|
1579
1587
|
usesReturnValue,
|
|
1580
1588
|
currentTryBlockEnd !== null,
|
|
1581
1589
|
currentConditionalNodeEnd !== null,
|
|
1582
|
-
|
|
1590
|
+
toBeRemoved
|
|
1583
1591
|
);
|
|
1584
1592
|
if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {
|
|
1585
1593
|
for (const name of pluginutils.extractAssignedNames(parent.id)) {
|
|
@@ -1781,6 +1789,7 @@ async function transformCommonjs(
|
|
|
1781
1789
|
!(
|
|
1782
1790
|
shouldWrap ||
|
|
1783
1791
|
isRequired ||
|
|
1792
|
+
needsRequireWrapper ||
|
|
1784
1793
|
uses.module ||
|
|
1785
1794
|
uses.exports ||
|
|
1786
1795
|
uses.require ||
|