@rollup/plugin-commonjs 29.0.0 → 29.0.1
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 +10 -1
- package/dist/es/index.js +10 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1041,6 +1041,10 @@ function isShorthandProperty(parent) {
|
|
|
1041
1041
|
return parent && parent.type === 'Property' && parent.shorthand;
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
|
+
function isPropertyDefinitionKey(parent, node) {
|
|
1045
|
+
return parent && parent.type === 'PropertyDefinition' && parent.key === node;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1044
1048
|
function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
|
|
1045
1049
|
const args = [];
|
|
1046
1050
|
const passedArgs = [];
|
|
@@ -1795,7 +1799,7 @@ async function transformCommonjs(
|
|
|
1795
1799
|
if (
|
|
1796
1800
|
!isReference(node, parent) ||
|
|
1797
1801
|
scope.contains(name) ||
|
|
1798
|
-
(parent
|
|
1802
|
+
isPropertyDefinitionKey(parent, node)
|
|
1799
1803
|
)
|
|
1800
1804
|
return;
|
|
1801
1805
|
switch (name) {
|
|
@@ -1822,6 +1826,10 @@ async function transformCommonjs(
|
|
|
1822
1826
|
case 'global':
|
|
1823
1827
|
uses.global = true;
|
|
1824
1828
|
if (!ignoreGlobal) {
|
|
1829
|
+
if (isShorthandProperty(parent)) {
|
|
1830
|
+
skippedNodes.add(parent.value);
|
|
1831
|
+
magicString.prependRight(node.start, 'global: ');
|
|
1832
|
+
}
|
|
1825
1833
|
replacedGlobal.push(node);
|
|
1826
1834
|
}
|
|
1827
1835
|
return;
|
|
@@ -1942,6 +1950,7 @@ async function transformCommonjs(
|
|
|
1942
1950
|
|
|
1943
1951
|
for (const node of replacedGlobal) {
|
|
1944
1952
|
magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, {
|
|
1953
|
+
contentOnly: true,
|
|
1945
1954
|
storeName: true
|
|
1946
1955
|
});
|
|
1947
1956
|
}
|
package/dist/es/index.js
CHANGED
|
@@ -1037,6 +1037,10 @@ function isShorthandProperty(parent) {
|
|
|
1037
1037
|
return parent && parent.type === 'Property' && parent.shorthand;
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
|
+
function isPropertyDefinitionKey(parent, node) {
|
|
1041
|
+
return parent && parent.type === 'PropertyDefinition' && parent.key === node;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1040
1044
|
function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
|
|
1041
1045
|
const args = [];
|
|
1042
1046
|
const passedArgs = [];
|
|
@@ -1791,7 +1795,7 @@ async function transformCommonjs(
|
|
|
1791
1795
|
if (
|
|
1792
1796
|
!isReference(node, parent) ||
|
|
1793
1797
|
scope.contains(name) ||
|
|
1794
|
-
(parent
|
|
1798
|
+
isPropertyDefinitionKey(parent, node)
|
|
1795
1799
|
)
|
|
1796
1800
|
return;
|
|
1797
1801
|
switch (name) {
|
|
@@ -1818,6 +1822,10 @@ async function transformCommonjs(
|
|
|
1818
1822
|
case 'global':
|
|
1819
1823
|
uses.global = true;
|
|
1820
1824
|
if (!ignoreGlobal) {
|
|
1825
|
+
if (isShorthandProperty(parent)) {
|
|
1826
|
+
skippedNodes.add(parent.value);
|
|
1827
|
+
magicString.prependRight(node.start, 'global: ');
|
|
1828
|
+
}
|
|
1821
1829
|
replacedGlobal.push(node);
|
|
1822
1830
|
}
|
|
1823
1831
|
return;
|
|
@@ -1938,6 +1946,7 @@ async function transformCommonjs(
|
|
|
1938
1946
|
|
|
1939
1947
|
for (const node of replacedGlobal) {
|
|
1940
1948
|
magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, {
|
|
1949
|
+
contentOnly: true,
|
|
1941
1950
|
storeName: true
|
|
1942
1951
|
});
|
|
1943
1952
|
}
|