@rollup/plugin-commonjs 29.0.0 → 29.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 +27 -4
- package/dist/es/index.js +27 -4
- package/package.json +3 -2
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 = "29.0.
|
|
14
|
+
var version = "29.0.1";
|
|
15
15
|
var peerDependencies = {
|
|
16
16
|
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
|
17
17
|
};
|
|
@@ -928,6 +928,20 @@ function validateVersion(actualVersion, peerDependencyVersion, name) {
|
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
930
|
|
|
931
|
+
function triStateAnd(a, b) {
|
|
932
|
+
if (a === false) return false;
|
|
933
|
+
if (b === false) return false;
|
|
934
|
+
if (a === true && b === true) return true;
|
|
935
|
+
return null;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function triStateOr(a, b) {
|
|
939
|
+
if (a === true) return true;
|
|
940
|
+
if (b === true) return true;
|
|
941
|
+
if (a === false && b === false) return false;
|
|
942
|
+
return null;
|
|
943
|
+
}
|
|
944
|
+
|
|
931
945
|
const operators = {
|
|
932
946
|
'==': (x) => equals(x.left, x.right, false),
|
|
933
947
|
|
|
@@ -939,9 +953,9 @@ const operators = {
|
|
|
939
953
|
|
|
940
954
|
'!': (x) => isFalsy(x.argument),
|
|
941
955
|
|
|
942
|
-
'&&': (x) => isTruthy(x.left)
|
|
956
|
+
'&&': (x) => triStateAnd(isTruthy(x.left), isTruthy(x.right)),
|
|
943
957
|
|
|
944
|
-
'||': (x) => isTruthy(x.left)
|
|
958
|
+
'||': (x) => triStateOr(isTruthy(x.left), isTruthy(x.right))
|
|
945
959
|
};
|
|
946
960
|
|
|
947
961
|
function not(value) {
|
|
@@ -1041,6 +1055,10 @@ function isShorthandProperty(parent) {
|
|
|
1041
1055
|
return parent && parent.type === 'Property' && parent.shorthand;
|
|
1042
1056
|
}
|
|
1043
1057
|
|
|
1058
|
+
function isPropertyDefinitionKey(parent, node) {
|
|
1059
|
+
return parent && parent.type === 'PropertyDefinition' && parent.key === node;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1044
1062
|
function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
|
|
1045
1063
|
const args = [];
|
|
1046
1064
|
const passedArgs = [];
|
|
@@ -1795,7 +1813,7 @@ async function transformCommonjs(
|
|
|
1795
1813
|
if (
|
|
1796
1814
|
!isReference(node, parent) ||
|
|
1797
1815
|
scope.contains(name) ||
|
|
1798
|
-
(parent
|
|
1816
|
+
isPropertyDefinitionKey(parent, node)
|
|
1799
1817
|
)
|
|
1800
1818
|
return;
|
|
1801
1819
|
switch (name) {
|
|
@@ -1822,6 +1840,10 @@ async function transformCommonjs(
|
|
|
1822
1840
|
case 'global':
|
|
1823
1841
|
uses.global = true;
|
|
1824
1842
|
if (!ignoreGlobal) {
|
|
1843
|
+
if (isShorthandProperty(parent)) {
|
|
1844
|
+
skippedNodes.add(parent.value);
|
|
1845
|
+
magicString.prependRight(node.start, 'global: ');
|
|
1846
|
+
}
|
|
1825
1847
|
replacedGlobal.push(node);
|
|
1826
1848
|
}
|
|
1827
1849
|
return;
|
|
@@ -1942,6 +1964,7 @@ async function transformCommonjs(
|
|
|
1942
1964
|
|
|
1943
1965
|
for (const node of replacedGlobal) {
|
|
1944
1966
|
magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, {
|
|
1967
|
+
contentOnly: true,
|
|
1945
1968
|
storeName: true
|
|
1946
1969
|
});
|
|
1947
1970
|
}
|
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 = "29.0.
|
|
10
|
+
var version = "29.0.1";
|
|
11
11
|
var peerDependencies = {
|
|
12
12
|
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
|
13
13
|
};
|
|
@@ -924,6 +924,20 @@ function validateVersion(actualVersion, peerDependencyVersion, name) {
|
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
+
function triStateAnd(a, b) {
|
|
928
|
+
if (a === false) return false;
|
|
929
|
+
if (b === false) return false;
|
|
930
|
+
if (a === true && b === true) return true;
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function triStateOr(a, b) {
|
|
935
|
+
if (a === true) return true;
|
|
936
|
+
if (b === true) return true;
|
|
937
|
+
if (a === false && b === false) return false;
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
|
|
927
941
|
const operators = {
|
|
928
942
|
'==': (x) => equals(x.left, x.right, false),
|
|
929
943
|
|
|
@@ -935,9 +949,9 @@ const operators = {
|
|
|
935
949
|
|
|
936
950
|
'!': (x) => isFalsy(x.argument),
|
|
937
951
|
|
|
938
|
-
'&&': (x) => isTruthy(x.left)
|
|
952
|
+
'&&': (x) => triStateAnd(isTruthy(x.left), isTruthy(x.right)),
|
|
939
953
|
|
|
940
|
-
'||': (x) => isTruthy(x.left)
|
|
954
|
+
'||': (x) => triStateOr(isTruthy(x.left), isTruthy(x.right))
|
|
941
955
|
};
|
|
942
956
|
|
|
943
957
|
function not(value) {
|
|
@@ -1037,6 +1051,10 @@ function isShorthandProperty(parent) {
|
|
|
1037
1051
|
return parent && parent.type === 'Property' && parent.shorthand;
|
|
1038
1052
|
}
|
|
1039
1053
|
|
|
1054
|
+
function isPropertyDefinitionKey(parent, node) {
|
|
1055
|
+
return parent && parent.type === 'PropertyDefinition' && parent.key === node;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1040
1058
|
function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
|
|
1041
1059
|
const args = [];
|
|
1042
1060
|
const passedArgs = [];
|
|
@@ -1791,7 +1809,7 @@ async function transformCommonjs(
|
|
|
1791
1809
|
if (
|
|
1792
1810
|
!isReference(node, parent) ||
|
|
1793
1811
|
scope.contains(name) ||
|
|
1794
|
-
(parent
|
|
1812
|
+
isPropertyDefinitionKey(parent, node)
|
|
1795
1813
|
)
|
|
1796
1814
|
return;
|
|
1797
1815
|
switch (name) {
|
|
@@ -1818,6 +1836,10 @@ async function transformCommonjs(
|
|
|
1818
1836
|
case 'global':
|
|
1819
1837
|
uses.global = true;
|
|
1820
1838
|
if (!ignoreGlobal) {
|
|
1839
|
+
if (isShorthandProperty(parent)) {
|
|
1840
|
+
skippedNodes.add(parent.value);
|
|
1841
|
+
magicString.prependRight(node.start, 'global: ');
|
|
1842
|
+
}
|
|
1821
1843
|
replacedGlobal.push(node);
|
|
1822
1844
|
}
|
|
1823
1845
|
return;
|
|
@@ -1938,6 +1960,7 @@ async function transformCommonjs(
|
|
|
1938
1960
|
|
|
1939
1961
|
for (const node of replacedGlobal) {
|
|
1940
1962
|
magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, {
|
|
1963
|
+
contentOnly: true,
|
|
1941
1964
|
storeName: true
|
|
1942
1965
|
});
|
|
1943
1966
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollup/plugin-commonjs",
|
|
3
|
-
"version": "29.0.
|
|
3
|
+
"version": "29.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"npm",
|
|
37
37
|
"modules",
|
|
38
38
|
"commonjs",
|
|
39
|
-
"require"
|
|
39
|
+
"require",
|
|
40
|
+
"rollup-plugin"
|
|
40
41
|
],
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"rollup": "^2.68.0||^3.0.0||^4.0.0"
|