@swissquote/crafty-preset-lightningcss 1.25.0 → 1.26.0-alpha.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.
@@ -64,9 +64,9 @@ async function loader(content, map, meta) {
64
64
  if (this._compilation && this._compilation.options && this._compilation.options.experiments && this._compilation.options.experiments.buildHttp) {
65
65
  isSupportAbsoluteURL = true;
66
66
  }
67
- const isSupportDataURL = options.esModule && Boolean("fsStartTime" in this._compiler);
68
67
  if ((0, _utils.shouldUseImportPlugin)(options)) {
69
68
  plugins.push((0, _plugins.importParser)({
69
+ // TODO need to fix on webpack side, webpack tries to resolve `./runtime/api.js paths like `http://site.com/runtime/api.js`, maybe we should try first request like absolute, the second like a relative to context
70
70
  isSupportAbsoluteURL: false,
71
71
  isSupportDataURL: false,
72
72
  isCSSStyleSheet: options.exportType === "css-style-sheet",
@@ -82,7 +82,7 @@ async function loader(content, map, meta) {
82
82
  const needToResolveURL = !options.esModule;
83
83
  plugins.push((0, _plugins.urlParser)({
84
84
  isSupportAbsoluteURL,
85
- isSupportDataURL,
85
+ isSupportDataURL: options.esModule,
86
86
  imports: urlPluginImports,
87
87
  replacements,
88
88
  context: this.context,
@@ -190,6 +190,22 @@ async function loader(content, map, meta) {
190
190
  return;
191
191
  }
192
192
  const exportCode = (0, _utils.getExportCode)(exports, replacements, needToUseIcssPlugin, options, isTemplateLiteralSupported);
193
+ const {
194
+ getJSON
195
+ } = options.modules;
196
+ if (typeof getJSON === "function") {
197
+ try {
198
+ await getJSON({
199
+ resourcePath,
200
+ imports,
201
+ exports,
202
+ replacements
203
+ });
204
+ } catch (error) {
205
+ callback(error);
206
+ return;
207
+ }
208
+ }
193
209
  callback(null, `${importCode}${moduleCode}${exportCode}`);
194
210
  }
195
211
 
@@ -1049,43 +1065,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
1049
1065
  */
1050
1066
 
1051
1067
  const WEBPACK_IGNORE_COMMENT_REGEXP = exports.WEBPACK_IGNORE_COMMENT_REGEXP = /webpackIgnore:(\s+)?(true|false)/;
1052
- const matchRelativePath = /^\.\.?[/\\]/;
1053
- function isAbsolutePath(str) {
1054
- return _path.default.posix.isAbsolute(str) || _path.default.win32.isAbsolute(str);
1055
- }
1056
- function isRelativePath(str) {
1057
- return matchRelativePath.test(str);
1058
- }
1059
-
1060
- // TODO simplify for the next major release
1061
1068
  function stringifyRequest(loaderContext, request) {
1062
- if (typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function") {
1063
- return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
1064
- }
1065
- const splitted = request.split("!");
1066
- const {
1067
- context
1068
- } = loaderContext;
1069
- return JSON.stringify(splitted.map(part => {
1070
- // First, separate singlePath from query, because the query might contain paths again
1071
- const splittedPart = part.match(/^(.*?)(\?.*)/);
1072
- const query = splittedPart ? splittedPart[2] : "";
1073
- let singlePath = splittedPart ? splittedPart[1] : part;
1074
- if (isAbsolutePath(singlePath) && context) {
1075
- singlePath = _path.default.relative(context, singlePath);
1076
- if (isAbsolutePath(singlePath)) {
1077
- // If singlePath still matches an absolute path, singlePath was on a different drive than context.
1078
- // In this case, we leave the path platform-specific without replacing any separators.
1079
- // @see https://github.com/webpack/loader-utils/pull/14
1080
- return singlePath + query;
1081
- }
1082
- if (isRelativePath(singlePath) === false) {
1083
- // Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
1084
- singlePath = `./${singlePath}`;
1085
- }
1086
- }
1087
- return singlePath.replace(/\\/g, "/") + query;
1088
- }).join("!"));
1069
+ return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
1089
1070
  }
1090
1071
 
1091
1072
  // We can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
@@ -1279,7 +1260,7 @@ const filenameReservedRegex = /[<>:"/\\|?*]/g;
1279
1260
  // eslint-disable-next-line no-control-regex
1280
1261
  const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
1281
1262
  function escapeLocalIdent(localident) {
1282
- // TODO simplify in the next major release
1263
+ // TODO simplify?
1283
1264
  return escape(localident
1284
1265
  // For `[hash]` placeholder
1285
1266
  .replace(/^((-?[0-9])|--)/, "_$1").replace(filenameReservedRegex, "-").replace(reControlChars, "-").replace(/\./g, "-"));
@@ -1324,10 +1305,8 @@ function defaultGetLocalIdent(loaderContext, localIdentName, localName, options)
1324
1305
  }
1325
1306
  let localIdentHash = "";
1326
1307
  for (let tier = 0; localIdentHash.length < hashDigestLength; tier++) {
1327
- // TODO remove this in the next major release
1328
- const hash = loaderContext.utils && typeof loaderContext.utils.createHash === "function" ? loaderContext.utils.createHash(hashFunction) :
1329
1308
  // eslint-disable-next-line no-underscore-dangle
1330
- loaderContext._compiler.webpack.util.createHash(hashFunction);
1309
+ const hash = loaderContext._compiler.webpack.util.createHash(hashFunction);
1331
1310
  if (hashSalt) {
1332
1311
  hash.update(hashSalt);
1333
1312
  }
@@ -1447,7 +1426,7 @@ function getValidLocalName(localName, exportLocalsConvention) {
1447
1426
  }
1448
1427
  const IS_MODULES = /\.module(s)?\.\w+$/i;
1449
1428
  const IS_ICSS = /\.icss\.\w+$/i;
1450
- function getModulesOptions(rawOptions, exportType, loaderContext) {
1429
+ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
1451
1430
  if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
1452
1431
  return false;
1453
1432
  }
@@ -1477,6 +1456,8 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
1477
1456
  outputOptions
1478
1457
  } = loaderContext._compilation;
1479
1458
  const needNamedExport = exportType === "css-style-sheet" || exportType === "string";
1459
+ const namedExport = typeof rawModulesOptions.namedExport !== "undefined" ? rawModulesOptions.namedExport : needNamedExport || esModule;
1460
+ const exportLocalsConvention = typeof rawModulesOptions.exportLocalsConvention !== "undefined" ? rawModulesOptions.exportLocalsConvention : namedExport ? "as-is" : "camel-case-only";
1480
1461
  const modulesOptions = {
1481
1462
  auto,
1482
1463
  mode: "local",
@@ -1491,21 +1472,25 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
1491
1472
  localIdentRegExp: undefined,
1492
1473
  // eslint-disable-next-line no-undefined
1493
1474
  getLocalIdent: undefined,
1494
- namedExport: needNamedExport || false,
1495
- exportLocalsConvention: (rawModulesOptions.namedExport === true || needNamedExport) && typeof rawModulesOptions.exportLocalsConvention === "undefined" ? "camelCaseOnly" : "asIs",
1475
+ // TODO improve me and enable by default
1496
1476
  exportOnlyLocals: false,
1497
1477
  ...rawModulesOptions,
1498
- useExportsAs: rawModulesOptions.exportLocalsConvention === "asIs"
1478
+ exportLocalsConvention,
1479
+ namedExport
1499
1480
  };
1500
- let exportLocalsConventionType;
1501
1481
  if (typeof modulesOptions.exportLocalsConvention === "string") {
1502
- exportLocalsConventionType = modulesOptions.exportLocalsConvention;
1482
+ // eslint-disable-next-line no-shadow
1483
+ const {
1484
+ exportLocalsConvention
1485
+ } = modulesOptions;
1503
1486
  modulesOptions.exportLocalsConvention = name => {
1504
- switch (exportLocalsConventionType) {
1487
+ switch (exportLocalsConvention) {
1488
+ case "camel-case":
1505
1489
  case "camelCase":
1506
1490
  {
1507
1491
  return [name, camelCase(name)];
1508
1492
  }
1493
+ case "camel-case-only":
1509
1494
  case "camelCaseOnly":
1510
1495
  {
1511
1496
  return camelCase(name);
@@ -1514,10 +1499,12 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
1514
1499
  {
1515
1500
  return [name, dashesCamelCase(name)];
1516
1501
  }
1502
+ case "dashes-only":
1517
1503
  case "dashesOnly":
1518
1504
  {
1519
1505
  return dashesCamelCase(name);
1520
1506
  }
1507
+ case "as-is":
1521
1508
  case "asIs":
1522
1509
  default:
1523
1510
  return name;
@@ -1555,33 +1542,29 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
1555
1542
  modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath, loaderContext.resourceQuery, loaderContext.resourceFragment);
1556
1543
  }
1557
1544
  if (needNamedExport) {
1558
- if (rawOptions.esModule === false) {
1545
+ if (esModule === false) {
1559
1546
  throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled");
1560
1547
  }
1561
1548
  if (modulesOptions.namedExport === false) {
1562
1549
  throw new Error("The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'modules.namedExport' option to be enabled");
1563
1550
  }
1564
1551
  }
1565
- if (modulesOptions.namedExport === true) {
1566
- if (rawOptions.esModule === false) {
1567
- throw new Error("The 'modules.namedExport' option requires the 'esModule' option to be enabled");
1568
- }
1569
- if (typeof exportLocalsConventionType === "string" && exportLocalsConventionType !== "asIs" && exportLocalsConventionType !== "camelCaseOnly" && exportLocalsConventionType !== "dashesOnly") {
1570
- throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly" or "dashesOnly"');
1571
- }
1552
+ if (modulesOptions.namedExport === true && esModule === false) {
1553
+ throw new Error("The 'modules.namedExport' option requires the 'esModule' option to be enabled");
1572
1554
  }
1573
1555
  return modulesOptions;
1574
1556
  }
1575
1557
  function normalizeOptions(rawOptions, loaderContext) {
1576
1558
  const exportType = typeof rawOptions.exportType === "undefined" ? "array" : rawOptions.exportType;
1577
- const modulesOptions = getModulesOptions(rawOptions, exportType, loaderContext);
1559
+ const esModule = typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule;
1560
+ const modulesOptions = getModulesOptions(rawOptions, esModule, exportType, loaderContext);
1578
1561
  return {
1579
1562
  url: typeof rawOptions.url === "undefined" ? true : rawOptions.url,
1580
1563
  import: typeof rawOptions.import === "undefined" ? true : rawOptions.import,
1581
1564
  modules: modulesOptions,
1582
1565
  sourceMap: typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap,
1583
1566
  importLoaders: typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
1584
- esModule: typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule,
1567
+ esModule,
1585
1568
  exportType
1586
1569
  };
1587
1570
  }
@@ -1876,6 +1859,8 @@ function convertToTemplateLiteral(str) {
1876
1859
  function dashesCamelCase(str) {
1877
1860
  return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
1878
1861
  }
1862
+ const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u;
1863
+ const keywords = new Set(["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"]);
1879
1864
  function getExportCode(exports, replacements, icssPluginUsed, options, isTemplateLiteralSupported) {
1880
1865
  let code = "// Exports\n";
1881
1866
  if (icssPluginUsed) {
@@ -1883,10 +1868,13 @@ function getExportCode(exports, replacements, icssPluginUsed, options, isTemplat
1883
1868
  let identifierId = 0;
1884
1869
  const addExportToLocalsCode = (names, value) => {
1885
1870
  const normalizedNames = Array.isArray(names) ? new Set(names) : new Set([names]);
1886
- for (const name of normalizedNames) {
1871
+ for (let name of normalizedNames) {
1887
1872
  const serializedValue = isTemplateLiteralSupported ? convertToTemplateLiteral(value) : JSON.stringify(value);
1888
1873
  if (options.modules.namedExport) {
1889
- if (options.modules.useExportsAs) {
1874
+ if (name === "default") {
1875
+ name = `_${name}`;
1876
+ }
1877
+ if (!validIdentifier.test(name) || keywords.has(name)) {
1890
1878
  identifierId += 1;
1891
1879
  const id = `_${identifierId.toString(16)}`;
1892
1880
  localsCode += `var ${id} = ${serializedValue};\n`;
@@ -2743,54 +2731,63 @@ module.exports = (options = {}) => {
2743
2731
  });
2744
2732
 
2745
2733
  root.walkDecls(/^composes$/, (declaration) => {
2746
- const matches = declaration.value.match(matchImports);
2734
+ const multiple = declaration.value.split(",");
2735
+ const values = [];
2747
2736
 
2748
- if (!matches) {
2749
- return;
2750
- }
2751
-
2752
- let tmpSymbols;
2753
- let [
2754
- ,
2755
- /*match*/ symbols,
2756
- doubleQuotePath,
2757
- singleQuotePath,
2758
- global,
2759
- ] = matches;
2760
-
2761
- if (global) {
2762
- // Composing globals simply means changing these classes to wrap them in global(name)
2763
- tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
2764
- } else {
2765
- const importPath = doubleQuotePath || singleQuotePath;
2737
+ multiple.forEach((value) => {
2738
+ const matches = value.trim().match(matchImports);
2766
2739
 
2767
- let parent = declaration.parent;
2768
- let parentIndexes = "";
2740
+ if (!matches) {
2741
+ values.push(value);
2769
2742
 
2770
- while (parent.type !== "root") {
2771
- parentIndexes =
2772
- parent.parent.index(parent) + "_" + parentIndexes;
2773
- parent = parent.parent;
2743
+ return;
2774
2744
  }
2775
2745
 
2776
- const { selector } = declaration.parent;
2777
- const parentRule = `_${parentIndexes}${selector}`;
2778
-
2779
- addImportToGraph(importPath, parentRule, graph, visited);
2746
+ let tmpSymbols;
2747
+ let [
2748
+ ,
2749
+ /*match*/ symbols,
2750
+ doubleQuotePath,
2751
+ singleQuotePath,
2752
+ global,
2753
+ ] = matches;
2754
+
2755
+ if (global) {
2756
+ // Composing globals simply means changing these classes to wrap them in global(name)
2757
+ tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
2758
+ } else {
2759
+ const importPath = doubleQuotePath || singleQuotePath;
2780
2760
 
2781
- importDecls[importPath] = declaration;
2782
- imports[importPath] = imports[importPath] || {};
2761
+ let parent = declaration.parent;
2762
+ let parentIndexes = "";
2783
2763
 
2784
- tmpSymbols = symbols.split(/\s+/).map((s) => {
2785
- if (!imports[importPath][s]) {
2786
- imports[importPath][s] = createImportedName(s, importPath);
2764
+ while (parent.type !== "root") {
2765
+ parentIndexes =
2766
+ parent.parent.index(parent) + "_" + parentIndexes;
2767
+ parent = parent.parent;
2787
2768
  }
2788
2769
 
2789
- return imports[importPath][s];
2790
- });
2791
- }
2770
+ const { selector } = declaration.parent;
2771
+ const parentRule = `_${parentIndexes}${selector}`;
2772
+
2773
+ addImportToGraph(importPath, parentRule, graph, visited);
2774
+
2775
+ importDecls[importPath] = declaration;
2776
+ imports[importPath] = imports[importPath] || {};
2777
+
2778
+ tmpSymbols = symbols.split(/\s+/).map((s) => {
2779
+ if (!imports[importPath][s]) {
2780
+ imports[importPath][s] = createImportedName(s, importPath);
2781
+ }
2782
+
2783
+ return imports[importPath][s];
2784
+ });
2785
+ }
2786
+
2787
+ values.push(tmpSymbols.join(" "));
2788
+ });
2792
2789
 
2793
- declaration.value = tmpSymbols.join(" ");
2790
+ declaration.value = values.join(", ");
2794
2791
  });
2795
2792
 
2796
2793
  const importsOrder = topologicalSort(graph, failOnWrongOrder);
@@ -3480,31 +3477,33 @@ module.exports = (options = {}) => {
3480
3477
  });
3481
3478
  });
3482
3479
  } else if (/scope$/i.test(atRule.name)) {
3483
- atRule.params = atRule.params
3484
- .split("to")
3485
- .map((item) => {
3486
- const selector = item.trim().slice(1, -1).trim();
3487
- const context = localizeNode(
3488
- selector,
3489
- options.mode,
3490
- localAliasMap
3491
- );
3480
+ if (atRule.params) {
3481
+ atRule.params = atRule.params
3482
+ .split("to")
3483
+ .map((item) => {
3484
+ const selector = item.trim().slice(1, -1).trim();
3485
+ const context = localizeNode(
3486
+ selector,
3487
+ options.mode,
3488
+ localAliasMap
3489
+ );
3492
3490
 
3493
- context.options = options;
3494
- context.localAliasMap = localAliasMap;
3491
+ context.options = options;
3492
+ context.localAliasMap = localAliasMap;
3495
3493
 
3496
- if (pureMode && context.hasPureGlobals) {
3497
- throw atRule.error(
3498
- 'Selector in at-rule"' +
3499
- selector +
3500
- '" is not pure ' +
3501
- "(pure selectors must contain at least one local class or id)"
3502
- );
3503
- }
3494
+ if (pureMode && context.hasPureGlobals) {
3495
+ throw atRule.error(
3496
+ 'Selector in at-rule"' +
3497
+ selector +
3498
+ '" is not pure ' +
3499
+ "(pure selectors must contain at least one local class or id)"
3500
+ );
3501
+ }
3504
3502
 
3505
- return `(${context.selector})`;
3506
- })
3507
- .join(" to ");
3503
+ return `(${context.selector})`;
3504
+ })
3505
+ .join(" to ");
3506
+ }
3508
3507
 
3509
3508
  atRule.nodes.forEach((declaration) => {
3510
3509
  if (declaration.type === "decl") {
@@ -3684,7 +3683,7 @@ const plugin = (options = {}) => {
3684
3683
  Once(root, { rule }) {
3685
3684
  const exports = Object.create(null);
3686
3685
 
3687
- function exportScopedName(name, rawName, node, needExport = true) {
3686
+ function exportScopedName(name, rawName, node) {
3688
3687
  const scopedName = generateScopedName(
3689
3688
  rawName ? rawName : name,
3690
3689
  root.source.input.from,
@@ -3700,10 +3699,6 @@ const plugin = (options = {}) => {
3700
3699
  );
3701
3700
  const { key, value } = exportEntry;
3702
3701
 
3703
- if (!needExport) {
3704
- return scopedName;
3705
- }
3706
-
3707
3702
  exports[key] = exports[key] || [];
3708
3703
 
3709
3704
  if (exports[key].indexOf(value) < 0) {
@@ -3713,18 +3708,17 @@ const plugin = (options = {}) => {
3713
3708
  return scopedName;
3714
3709
  }
3715
3710
 
3716
- function localizeNode(node, needExport = true) {
3711
+ function localizeNode(node) {
3717
3712
  switch (node.type) {
3718
3713
  case "selector":
3719
- node.nodes = node.map((item) => localizeNode(item, needExport));
3714
+ node.nodes = node.map((item) => localizeNode(item));
3720
3715
  return node;
3721
3716
  case "class":
3722
3717
  return selectorParser.className({
3723
3718
  value: exportScopedName(
3724
3719
  node.value,
3725
3720
  node.raws && node.raws.value ? node.raws.value : null,
3726
- node,
3727
- needExport
3721
+ node
3728
3722
  ),
3729
3723
  });
3730
3724
  case "id": {
@@ -3732,8 +3726,7 @@ const plugin = (options = {}) => {
3732
3726
  value: exportScopedName(
3733
3727
  node.value,
3734
3728
  node.raws && node.raws.value ? node.raws.value : null,
3735
- node,
3736
- needExport
3729
+ node
3737
3730
  ),
3738
3731
  });
3739
3732
  }
@@ -3743,7 +3736,7 @@ const plugin = (options = {}) => {
3743
3736
  attribute: node.attribute,
3744
3737
  operator: node.operator,
3745
3738
  quoteMark: "'",
3746
- value: exportScopedName(node.value, null, null, needExport),
3739
+ value: exportScopedName(node.value, null, null),
3747
3740
  });
3748
3741
  }
3749
3742
  }
@@ -3754,7 +3747,7 @@ const plugin = (options = {}) => {
3754
3747
  );
3755
3748
  }
3756
3749
 
3757
- function traverseNode(node, needExport = true) {
3750
+ function traverseNode(node) {
3758
3751
  switch (node.type) {
3759
3752
  case "pseudo":
3760
3753
  if (node.value === ":local") {
@@ -3762,7 +3755,7 @@ const plugin = (options = {}) => {
3762
3755
  throw new Error('Unexpected comma (",") in :local block');
3763
3756
  }
3764
3757
 
3765
- const selector = localizeNode(node.first, needExport);
3758
+ const selector = localizeNode(node.first);
3766
3759
  // move the spaces that were around the pseudo selector to the first
3767
3760
  // non-container node
3768
3761
  selector.first.spaces = node.spaces;
@@ -3785,12 +3778,12 @@ const plugin = (options = {}) => {
3785
3778
  /* falls through */
3786
3779
  case "root":
3787
3780
  case "selector": {
3788
- node.each((item) => traverseNode(item, needExport));
3781
+ node.each((item) => traverseNode(item));
3789
3782
  break;
3790
3783
  }
3791
3784
  case "id":
3792
3785
  case "class":
3793
- if (needExport && exportGlobals) {
3786
+ if (exportGlobals) {
3794
3787
  exports[node.value] = [node.value];
3795
3788
  }
3796
3789
  break;
@@ -3813,35 +3806,39 @@ const plugin = (options = {}) => {
3813
3806
 
3814
3807
  rule.selector = traverseNode(parsedSelector.clone()).toString();
3815
3808
 
3816
- rule.walkDecls(/composes|compose-with/i, (decl) => {
3809
+ rule.walkDecls(/^(composes|compose-with)$/i, (decl) => {
3817
3810
  const localNames = getSingleLocalNamesForComposes(
3818
3811
  parsedSelector,
3819
3812
  decl.parent
3820
3813
  );
3821
- const classes = decl.value.split(/\s+/);
3814
+ const multiple = decl.value.split(",");
3822
3815
 
3823
- classes.forEach((className) => {
3824
- const global = /^global\(([^)]+)\)$/.exec(className);
3816
+ multiple.forEach((value) => {
3817
+ const classes = value.trim().split(/\s+/);
3825
3818
 
3826
- if (global) {
3827
- localNames.forEach((exportedName) => {
3828
- exports[exportedName].push(global[1]);
3829
- });
3830
- } else if (hasOwnProperty.call(importedNames, className)) {
3831
- localNames.forEach((exportedName) => {
3832
- exports[exportedName].push(className);
3833
- });
3834
- } else if (hasOwnProperty.call(exports, className)) {
3835
- localNames.forEach((exportedName) => {
3836
- exports[className].forEach((item) => {
3837
- exports[exportedName].push(item);
3819
+ classes.forEach((className) => {
3820
+ const global = /^global\(([^)]+)\)$/.exec(className);
3821
+
3822
+ if (global) {
3823
+ localNames.forEach((exportedName) => {
3824
+ exports[exportedName].push(global[1]);
3838
3825
  });
3839
- });
3840
- } else {
3841
- throw decl.error(
3842
- `referenced class name "${className}" in ${decl.prop} not found`
3843
- );
3844
- }
3826
+ } else if (hasOwnProperty.call(importedNames, className)) {
3827
+ localNames.forEach((exportedName) => {
3828
+ exports[exportedName].push(className);
3829
+ });
3830
+ } else if (hasOwnProperty.call(exports, className)) {
3831
+ localNames.forEach((exportedName) => {
3832
+ exports[className].forEach((item) => {
3833
+ exports[exportedName].push(item);
3834
+ });
3835
+ });
3836
+ } else {
3837
+ throw decl.error(
3838
+ `referenced class name "${className}" in ${decl.prop} not found`
3839
+ );
3840
+ }
3841
+ });
3845
3842
  });
3846
3843
 
3847
3844
  decl.remove();
@@ -3894,22 +3891,24 @@ const plugin = (options = {}) => {
3894
3891
  });
3895
3892
 
3896
3893
  root.walkAtRules(/scope$/i, (atRule) => {
3897
- atRule.params = atRule.params
3898
- .split("to")
3899
- .map((item) => {
3900
- const selector = item.trim().slice(1, -1).trim();
3894
+ if (atRule.params) {
3895
+ atRule.params = atRule.params
3896
+ .split("to")
3897
+ .map((item) => {
3898
+ const selector = item.trim().slice(1, -1).trim();
3901
3899
 
3902
- const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(selector);
3900
+ const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(selector);
3903
3901
 
3904
- if (!localMatch) {
3905
- return `(${selector})`;
3906
- }
3902
+ if (!localMatch) {
3903
+ return `(${selector})`;
3904
+ }
3907
3905
 
3908
- let parsedSelector = selectorParser().astSync(selector);
3906
+ let parsedSelector = selectorParser().astSync(selector);
3909
3907
 
3910
- return `(${traverseNode(parsedSelector, false).toString()})`;
3911
- })
3912
- .join(" to ");
3908
+ return `(${traverseNode(parsedSelector).toString()})`;
3909
+ })
3910
+ .join(" to ");
3911
+ }
3913
3912
  });
3914
3913
 
3915
3914
  // If we found any :locals, insert an :export rule
@@ -5835,9 +5834,14 @@ class MapGenerator {
5835
5834
  } else if (this.previous().length === 1) {
5836
5835
  let prev = this.previous()[0].consumer()
5837
5836
  prev.file = this.outputFile()
5838
- this.map = SourceMapGenerator.fromSourceMap(prev)
5837
+ this.map = SourceMapGenerator.fromSourceMap(prev, {
5838
+ ignoreInvalidMapping: true
5839
+ })
5839
5840
  } else {
5840
- this.map = new SourceMapGenerator({ file: this.outputFile() })
5841
+ this.map = new SourceMapGenerator({
5842
+ file: this.outputFile(),
5843
+ ignoreInvalidMapping: true
5844
+ })
5841
5845
  this.map.addMapping({
5842
5846
  generated: { column: 0, line: 1 },
5843
5847
  original: { column: 0, line: 1 },
@@ -5860,7 +5864,10 @@ class MapGenerator {
5860
5864
 
5861
5865
  generateString() {
5862
5866
  this.css = ''
5863
- this.map = new SourceMapGenerator({ file: this.outputFile() })
5867
+ this.map = new SourceMapGenerator({
5868
+ file: this.outputFile(),
5869
+ ignoreInvalidMapping: true
5870
+ })
5864
5871
 
5865
5872
  let line = 1
5866
5873
  let column = 1
@@ -6492,7 +6499,7 @@ class Node {
6492
6499
  column: opts.end.column,
6493
6500
  line: opts.end.line
6494
6501
  }
6495
- } else if (opts.endIndex) {
6502
+ } else if (typeof opts.endIndex === 'number') {
6496
6503
  end = this.positionInside(opts.endIndex)
6497
6504
  } else if (opts.index) {
6498
6505
  end = this.positionInside(opts.index + 1)
@@ -7573,7 +7580,7 @@ let Root = __nccwpck_require__(9659)
7573
7580
 
7574
7581
  class Processor {
7575
7582
  constructor(plugins = []) {
7576
- this.version = '8.4.35'
7583
+ this.version = '8.4.38'
7577
7584
  this.plugins = this.normalize(plugins)
7578
7585
  }
7579
7586
 
@@ -9197,7 +9204,7 @@ module.exports = { nanoid, customAlphabet }
9197
9204
  /***/ ((module) => {
9198
9205
 
9199
9206
  "use strict";
9200
- module.exports = JSON.parse('{"title":"CSS Loader options","additionalProperties":false,"properties":{"url":{"description":"Allows to enables/disables `url()`/`image-set()` functions handling.","link":"https://github.com/webpack-contrib/css-loader#url","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"import":{"description":"Allows to enables/disables `@import` at-rules handling.","link":"https://github.com/webpack-contrib/css-loader#import","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"modules":{"description":"Allows to enable/disable CSS Modules or ICSS and setup configuration.","link":"https://github.com/webpack-contrib/css-loader#modules","anyOf":[{"type":"boolean"},{"enum":["local","global","pure","icss"]},{"type":"object","additionalProperties":false,"properties":{"auto":{"description":"Allows auto enable CSS modules based on filename.","link":"https://github.com/webpack-contrib/css-loader#auto","anyOf":[{"instanceof":"RegExp"},{"instanceof":"Function"},{"type":"boolean"}]},"mode":{"description":"Setup `mode` option.","link":"https://github.com/webpack-contrib/css-loader#mode","anyOf":[{"enum":["local","global","pure","icss"]},{"instanceof":"Function"}]},"localIdentName":{"description":"Allows to configure the generated local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentname","type":"string","minLength":1},"localIdentContext":{"description":"Allows to redefine basic loader context for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentcontext","type":"string","minLength":1},"localIdentHashSalt":{"description":"Allows to add custom hash to generate more unique classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashsalt","type":"string","minLength":1},"localIdentHashFunction":{"description":"Allows to specify hash function to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashfunction","type":"string","minLength":1},"localIdentHashDigest":{"description":"Allows to specify hash digest to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigest","type":"string","minLength":1},"localIdentHashDigestLength":{"description":"Allows to specify hash digest length to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigestlength","type":"number"},"hashStrategy":{"description":"Allows to specify should localName be used when computing the hash.","link":"https://github.com/webpack-contrib/css-loader#hashstrategy","enum":["resource-path-and-local-name","minimal-subset"]},"localIdentRegExp":{"description":"Allows to specify custom RegExp for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentregexp","anyOf":[{"type":"string","minLength":1},{"instanceof":"RegExp"}]},"getLocalIdent":{"description":"Allows to specify a function to generate the classname.","link":"https://github.com/webpack-contrib/css-loader#getlocalident","instanceof":"Function"},"namedExport":{"description":"Enables/disables ES modules named export for locals.","link":"https://github.com/webpack-contrib/css-loader#namedexport","type":"boolean"},"exportGlobals":{"description":"Allows to export names from global class or id, so you can use that as local name.","link":"https://github.com/webpack-contrib/css-loader#exportglobals","type":"boolean"},"exportLocalsConvention":{"description":"Style of exported classnames.","link":"https://github.com/webpack-contrib/css-loader#localsconvention","anyOf":[{"enum":["asIs","camelCase","camelCaseOnly","dashes","dashesOnly"]},{"instanceof":"Function"}]},"exportOnlyLocals":{"description":"Export only locals.","link":"https://github.com/webpack-contrib/css-loader#exportonlylocals","type":"boolean"}}}]},"sourceMap":{"description":"Allows to enable/disable source maps.","link":"https://github.com/webpack-contrib/css-loader#sourcemap","type":"boolean"},"importLoaders":{"description":"Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports.","link":"https://github.com/webpack-contrib/css-loader#importloaders","anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}]},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"exportType":{"description":"Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).","link":"https://github.com/webpack-contrib/css-loader#exporttype","enum":["array","string","css-style-sheet"]}},"type":"object"}');
9207
+ module.exports = JSON.parse('{"title":"CSS Loader options","additionalProperties":false,"properties":{"url":{"description":"Allows to enables/disables `url()`/`image-set()` functions handling.","link":"https://github.com/webpack-contrib/css-loader#url","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"import":{"description":"Allows to enables/disables `@import` at-rules handling.","link":"https://github.com/webpack-contrib/css-loader#import","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"modules":{"description":"Allows to enable/disable CSS Modules or ICSS and setup configuration.","link":"https://github.com/webpack-contrib/css-loader#modules","anyOf":[{"type":"boolean"},{"enum":["local","global","pure","icss"]},{"type":"object","additionalProperties":false,"properties":{"auto":{"description":"Allows auto enable CSS modules based on filename.","link":"https://github.com/webpack-contrib/css-loader#auto","anyOf":[{"instanceof":"RegExp"},{"instanceof":"Function"},{"type":"boolean"}]},"mode":{"description":"Setup `mode` option.","link":"https://github.com/webpack-contrib/css-loader#mode","anyOf":[{"enum":["local","global","pure","icss"]},{"instanceof":"Function"}]},"localIdentName":{"description":"Allows to configure the generated local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentname","type":"string","minLength":1},"localIdentContext":{"description":"Allows to redefine basic loader context for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentcontext","type":"string","minLength":1},"localIdentHashSalt":{"description":"Allows to add custom hash to generate more unique classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashsalt","type":"string","minLength":1},"localIdentHashFunction":{"description":"Allows to specify hash function to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashfunction","type":"string","minLength":1},"localIdentHashDigest":{"description":"Allows to specify hash digest to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigest","type":"string","minLength":1},"localIdentHashDigestLength":{"description":"Allows to specify hash digest length to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigestlength","type":"number"},"hashStrategy":{"description":"Allows to specify should localName be used when computing the hash.","link":"https://github.com/webpack-contrib/css-loader#hashstrategy","enum":["resource-path-and-local-name","minimal-subset"]},"localIdentRegExp":{"description":"Allows to specify custom RegExp for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentregexp","anyOf":[{"type":"string","minLength":1},{"instanceof":"RegExp"}]},"getLocalIdent":{"description":"Allows to specify a function to generate the classname.","link":"https://github.com/webpack-contrib/css-loader#getlocalident","instanceof":"Function"},"namedExport":{"description":"Enables/disables ES modules named export for locals.","link":"https://github.com/webpack-contrib/css-loader#namedexport","type":"boolean"},"exportGlobals":{"description":"Allows to export names from global class or id, so you can use that as local name.","link":"https://github.com/webpack-contrib/css-loader#exportglobals","type":"boolean"},"exportLocalsConvention":{"description":"Style of exported classnames.","link":"https://github.com/webpack-contrib/css-loader#localsconvention","anyOf":[{"enum":["asIs","as-is","camelCase","camel-case","camelCaseOnly","camel-case-only","dashes","dashesOnly","dashes-only"]},{"instanceof":"Function"}]},"exportOnlyLocals":{"description":"Export only locals.","link":"https://github.com/webpack-contrib/css-loader#exportonlylocals","type":"boolean"},"getJSON":{"description":"Allows outputting of CSS modules mapping through a callback.","link":"https://github.com/webpack-contrib/css-loader#getJSON","instanceof":"Function"}}}]},"sourceMap":{"description":"Allows to enable/disable source maps.","link":"https://github.com/webpack-contrib/css-loader#sourcemap","type":"boolean"},"importLoaders":{"description":"Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports.","link":"https://github.com/webpack-contrib/css-loader#importloaders","anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}]},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"exportType":{"description":"Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).","link":"https://github.com/webpack-contrib/css-loader#exporttype","enum":["array","string","css-style-sheet"]}},"type":"object"}');
9201
9208
 
9202
9209
  /***/ }),
9203
9210
 
@@ -9205,7 +9212,7 @@ module.exports = JSON.parse('{"title":"CSS Loader options","additionalProperties
9205
9212
  /***/ ((module) => {
9206
9213
 
9207
9214
  "use strict";
9208
- module.exports = JSON.parse('{"name":"postcss","version":"8.4.35","description":"Tool for transforming styles with JS plugins","engines":{"node":"^10 || ^12 || >=14"},"exports":{".":{"require":"./lib/postcss.js","import":"./lib/postcss.mjs"},"./lib/at-rule":"./lib/at-rule.js","./lib/comment":"./lib/comment.js","./lib/container":"./lib/container.js","./lib/css-syntax-error":"./lib/css-syntax-error.js","./lib/declaration":"./lib/declaration.js","./lib/fromJSON":"./lib/fromJSON.js","./lib/input":"./lib/input.js","./lib/lazy-result":"./lib/lazy-result.js","./lib/no-work-result":"./lib/no-work-result.js","./lib/list":"./lib/list.js","./lib/map-generator":"./lib/map-generator.js","./lib/node":"./lib/node.js","./lib/parse":"./lib/parse.js","./lib/parser":"./lib/parser.js","./lib/postcss":"./lib/postcss.js","./lib/previous-map":"./lib/previous-map.js","./lib/processor":"./lib/processor.js","./lib/result":"./lib/result.js","./lib/root":"./lib/root.js","./lib/rule":"./lib/rule.js","./lib/stringifier":"./lib/stringifier.js","./lib/stringify":"./lib/stringify.js","./lib/symbols":"./lib/symbols.js","./lib/terminal-highlight":"./lib/terminal-highlight.js","./lib/tokenize":"./lib/tokenize.js","./lib/warn-once":"./lib/warn-once.js","./lib/warning":"./lib/warning.js","./package.json":"./package.json"},"main":"./lib/postcss.js","types":"./lib/postcss.d.ts","keywords":["css","postcss","rework","preprocessor","parser","source map","transform","manipulation","transpiler"],"funding":[{"type":"opencollective","url":"https://opencollective.com/postcss/"},{"type":"tidelift","url":"https://tidelift.com/funding/github/npm/postcss"},{"type":"github","url":"https://github.com/sponsors/ai"}],"author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT","homepage":"https://postcss.org/","repository":"postcss/postcss","bugs":{"url":"https://github.com/postcss/postcss/issues"},"dependencies":{"nanoid":"^3.3.7","picocolors":"^1.0.0","source-map-js":"^1.0.2"},"browser":{"./lib/terminal-highlight":false,"source-map-js":false,"path":false,"url":false,"fs":false}}');
9215
+ module.exports = JSON.parse('{"name":"postcss","version":"8.4.38","description":"Tool for transforming styles with JS plugins","engines":{"node":"^10 || ^12 || >=14"},"exports":{".":{"require":"./lib/postcss.js","import":"./lib/postcss.mjs"},"./lib/at-rule":"./lib/at-rule.js","./lib/comment":"./lib/comment.js","./lib/container":"./lib/container.js","./lib/css-syntax-error":"./lib/css-syntax-error.js","./lib/declaration":"./lib/declaration.js","./lib/fromJSON":"./lib/fromJSON.js","./lib/input":"./lib/input.js","./lib/lazy-result":"./lib/lazy-result.js","./lib/no-work-result":"./lib/no-work-result.js","./lib/list":"./lib/list.js","./lib/map-generator":"./lib/map-generator.js","./lib/node":"./lib/node.js","./lib/parse":"./lib/parse.js","./lib/parser":"./lib/parser.js","./lib/postcss":"./lib/postcss.js","./lib/previous-map":"./lib/previous-map.js","./lib/processor":"./lib/processor.js","./lib/result":"./lib/result.js","./lib/root":"./lib/root.js","./lib/rule":"./lib/rule.js","./lib/stringifier":"./lib/stringifier.js","./lib/stringify":"./lib/stringify.js","./lib/symbols":"./lib/symbols.js","./lib/terminal-highlight":"./lib/terminal-highlight.js","./lib/tokenize":"./lib/tokenize.js","./lib/warn-once":"./lib/warn-once.js","./lib/warning":"./lib/warning.js","./package.json":"./package.json"},"main":"./lib/postcss.js","types":"./lib/postcss.d.ts","keywords":["css","postcss","rework","preprocessor","parser","source map","transform","manipulation","transpiler"],"funding":[{"type":"opencollective","url":"https://opencollective.com/postcss/"},{"type":"tidelift","url":"https://tidelift.com/funding/github/npm/postcss"},{"type":"github","url":"https://github.com/sponsors/ai"}],"author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT","homepage":"https://postcss.org/","repository":"postcss/postcss","bugs":{"url":"https://github.com/postcss/postcss/issues"},"dependencies":{"nanoid":"^3.3.7","picocolors":"^1.0.0","source-map-js":"^1.2.0"},"browser":{"./lib/terminal-highlight":false,"source-map-js":false,"path":false,"url":false,"fs":false}}');
9209
9216
 
9210
9217
  /***/ }),
9211
9218