@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/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 = "22.0.1";
10
+ var version = "22.0.2";
11
11
  var peerDependencies = {
12
12
  rollup: "^2.68.0"
13
13
  };
@@ -965,7 +965,7 @@ function hasDefineEsmProperty(node) {
965
965
  });
966
966
  }
967
967
 
968
- function wrapCode(magicString, uses, moduleName, exportsName) {
968
+ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
969
969
  const args = [];
970
970
  const passedArgs = [];
971
971
  if (uses.module) {
@@ -978,7 +978,7 @@ function wrapCode(magicString, uses, moduleName, exportsName) {
978
978
  }
979
979
  magicString
980
980
  .trim()
981
- .indent('\t')
981
+ .indent('\t', { exclude: indentExclusionRanges })
982
982
  .prepend(`(function (${args.join(', ')}) {\n`)
983
983
  .append(`\n} (${passedArgs.join(', ')}));`);
984
984
  }
@@ -1476,6 +1476,7 @@ async function transformCommonjs(
1476
1476
  const replacedGlobal = [];
1477
1477
  const replacedDynamicRequires = [];
1478
1478
  const importedVariables = new Set();
1479
+ const indentExclusionRanges = [];
1479
1480
 
1480
1481
  walk(ast, {
1481
1482
  enter(node, parent) {
@@ -1774,6 +1775,11 @@ async function transformCommonjs(
1774
1775
  if (!scope.parent) {
1775
1776
  topLevelDeclarations.push(node);
1776
1777
  }
1778
+ return;
1779
+ case 'TemplateElement':
1780
+ if (node.value.raw.includes('\n')) {
1781
+ indentExclusionRanges.push([node.start, node.end]);
1782
+ }
1777
1783
  }
1778
1784
  },
1779
1785
 
@@ -1906,11 +1912,13 @@ async function transformCommonjs(
1906
1912
  );
1907
1913
 
1908
1914
  if (shouldWrap) {
1909
- wrapCode(magicString, uses, moduleName, exportsName);
1915
+ wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
1910
1916
  }
1911
1917
 
1912
1918
  if (usesRequireWrapper) {
1913
- magicString.trim().indent('\t');
1919
+ magicString.trim().indent('\t', {
1920
+ exclude: indentExclusionRanges
1921
+ });
1914
1922
  magicString.prepend(
1915
1923
  `var ${isRequiredName};
1916
1924