@rollup/plugin-commonjs 22.0.1 → 22.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 +13 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +13 -5
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
19
|
+
var version = "22.0.2";
|
|
20
20
|
var peerDependencies = {
|
|
21
21
|
rollup: "^2.68.0"
|
|
22
22
|
};
|
|
@@ -974,7 +974,7 @@ function hasDefineEsmProperty(node) {
|
|
|
974
974
|
});
|
|
975
975
|
}
|
|
976
976
|
|
|
977
|
-
function wrapCode(magicString, uses, moduleName, exportsName) {
|
|
977
|
+
function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
|
|
978
978
|
const args = [];
|
|
979
979
|
const passedArgs = [];
|
|
980
980
|
if (uses.module) {
|
|
@@ -987,7 +987,7 @@ function wrapCode(magicString, uses, moduleName, exportsName) {
|
|
|
987
987
|
}
|
|
988
988
|
magicString
|
|
989
989
|
.trim()
|
|
990
|
-
.indent('\t')
|
|
990
|
+
.indent('\t', { exclude: indentExclusionRanges })
|
|
991
991
|
.prepend(`(function (${args.join(', ')}) {\n`)
|
|
992
992
|
.append(`\n} (${passedArgs.join(', ')}));`);
|
|
993
993
|
}
|
|
@@ -1485,6 +1485,7 @@ async function transformCommonjs(
|
|
|
1485
1485
|
const replacedGlobal = [];
|
|
1486
1486
|
const replacedDynamicRequires = [];
|
|
1487
1487
|
const importedVariables = new Set();
|
|
1488
|
+
const indentExclusionRanges = [];
|
|
1488
1489
|
|
|
1489
1490
|
estreeWalker.walk(ast, {
|
|
1490
1491
|
enter(node, parent) {
|
|
@@ -1783,6 +1784,11 @@ async function transformCommonjs(
|
|
|
1783
1784
|
if (!scope.parent) {
|
|
1784
1785
|
topLevelDeclarations.push(node);
|
|
1785
1786
|
}
|
|
1787
|
+
return;
|
|
1788
|
+
case 'TemplateElement':
|
|
1789
|
+
if (node.value.raw.includes('\n')) {
|
|
1790
|
+
indentExclusionRanges.push([node.start, node.end]);
|
|
1791
|
+
}
|
|
1786
1792
|
}
|
|
1787
1793
|
},
|
|
1788
1794
|
|
|
@@ -1915,11 +1921,13 @@ async function transformCommonjs(
|
|
|
1915
1921
|
);
|
|
1916
1922
|
|
|
1917
1923
|
if (shouldWrap) {
|
|
1918
|
-
wrapCode(magicString, uses, moduleName, exportsName);
|
|
1924
|
+
wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
|
|
1919
1925
|
}
|
|
1920
1926
|
|
|
1921
1927
|
if (usesRequireWrapper) {
|
|
1922
|
-
magicString.trim().indent('\t'
|
|
1928
|
+
magicString.trim().indent('\t', {
|
|
1929
|
+
exclude: indentExclusionRanges
|
|
1930
|
+
});
|
|
1923
1931
|
magicString.prepend(
|
|
1924
1932
|
`var ${isRequiredName};
|
|
1925
1933
|
|