next-yak 0.3.0 → 1.0.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # next-yak
2
2
 
3
- ![Yak At Work as Frontend Dev](https://github.com/jantimon/next-yak/assets/4113649/2dcaf443-7205-4ef3-ba44-fbbe3ef2807d)
3
+ ![A yak Riding on a rusty SWC Rocket](https://github.com/user-attachments/assets/72494b1c-db1a-4ff7-bd6f-2ed3535fb126)
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/next-yak.svg)](https://www.npmjs.com/package/next-yak)
6
6
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jantimon/next-yak/blob/main/LICENSE)
@@ -41,18 +41,19 @@ var import_plugin_syntax_typescript = __toESM(require("@babel/plugin-syntax-type
41
41
  var import_getCssModuleLocalIdent = require("next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js");
42
42
  var yakCssImportRegex = (
43
43
  // Make mixin and selector non optional once we dropped support for the babel plugin
44
- /--yak-css-import\:\s*url\("([^"]+)",?(|mixin|selector)\);?/g
44
+ /--yak-css-import\:\s*url\("([^"]+)",?(|mixin|selector)\)(;?)/g
45
45
  );
46
46
  var compilationCache = /* @__PURE__ */ new WeakMap();
47
47
  async function resolveCrossFileConstant(loader, pathContext, css) {
48
48
  const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {
49
- const [fullMatch, encodedArguments, importKind] = match;
49
+ const [fullMatch, encodedArguments, importKind, semicolon] = match;
50
50
  const [moduleSpecifier, ...specifier] = encodedArguments.split(":").map((entry) => decodeURIComponent(entry));
51
51
  return {
52
52
  encodedArguments,
53
53
  moduleSpecifier,
54
54
  specifier,
55
55
  importKind,
56
+ semicolon,
56
57
  position: match.index,
57
58
  size: fullMatch.length
58
59
  };
@@ -79,7 +80,7 @@ async function resolveCrossFileConstant(loader, pathContext, css) {
79
80
  );
80
81
  let result = css;
81
82
  for (let i = matches.length - 1; i >= 0; i--) {
82
- const { position, size, importKind, specifier } = matches[i];
83
+ const { position, size, importKind, specifier, semicolon } = matches[i];
83
84
  const resolved = resolvedValues[i];
84
85
  if (importKind === "selector") {
85
86
  if (resolved.type === "mixin") {
@@ -98,7 +99,14 @@ async function resolveCrossFileConstant(loader, pathContext, css) {
98
99
  null,
99
100
  resolved.name,
100
101
  {}
101
- )})` : resolved.value;
102
+ )})` : resolved.value + // resolved.value can be of two different types:
103
+ // - mixin:
104
+ // ${mixinName};
105
+ // - constant:
106
+ // color: ${value};
107
+ // For mixins the semicolon is already included in the value
108
+ // but for constants it has to be added manually
109
+ (["}", ";"].includes(String(resolved.value).trimEnd().slice(-1)) ? "" : semicolon);
102
110
  result = result.slice(0, position) + String(replacement) + result.slice(position + size);
103
111
  }
104
112
  return result;
@@ -231,6 +239,19 @@ async function parseExports(sourceContents, isTSX) {
231
239
  });
232
240
  }
233
241
  },
242
+ ExportDeclaration({ node }) {
243
+ if ("specifiers" in node && node.source) {
244
+ const { specifiers, source } = node;
245
+ specifiers.forEach((specifier) => {
246
+ if (specifier.type === "ExportNamespaceSpecifier" && specifier.exported.type === "Identifier") {
247
+ exports[specifier.exported.name] = {
248
+ type: "star-export",
249
+ from: [source.value]
250
+ };
251
+ }
252
+ });
253
+ }
254
+ },
234
255
  ExportAllDeclaration({ node }) {
235
256
  if (Object.keys(exports).length === 0) {
236
257
  exports["*"] ||= {
@@ -322,6 +343,17 @@ async function resolveModuleSpecifierRecursively(loader, module2, specifier) {
322
343
  exportValue.imported,
323
344
  ...specifier.slice(1)
324
345
  ]);
346
+ } else if (exportValue.type === "star-export") {
347
+ const importedModule = await parseModule(
348
+ loader,
349
+ exportValue.from[0],
350
+ import_path.default.dirname(module2.filePath)
351
+ );
352
+ return resolveModuleSpecifierRecursively(
353
+ loader,
354
+ importedModule,
355
+ specifier.slice(1)
356
+ );
325
357
  }
326
358
  if (exportValue.type === "styled-component") {
327
359
  return {
@@ -349,6 +381,8 @@ Key "${specifier[depth]}" was of type "${typeof current}" but only String and Nu
349
381
  depth++;
350
382
  if (depth === specifier.length && "__yak" in current) {
351
383
  return { type: "mixin", value: current["__yak"] };
384
+ } else if (depth === specifier.length && "value" in current) {
385
+ return { type: "constant", value: current["value"] };
352
386
  } else {
353
387
  current = current[specifier[depth]];
354
388
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../loaders/css-loader.ts","../../loaders/lib/resolveCrossFileSelectors.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { resolveCrossFileConstant } from \"./lib/resolveCrossFileSelectors.js\";\nimport { relative } from \"path\";\nimport type { YakConfigOptions } from \"../withYak/index.js\";\n\n/**\n * Transform typescript to css\n *\n * This loader takes the cached result from the yak tsloader\n * and extracts the css from the generated comments\n */\nexport default async function cssExtractLoader(\n this: LoaderContext<YakConfigOptions>,\n // Instead of the source code, we receive the extracted css\n // from the ts-loader transformation\n _code: string,\n sourceMap: string | undefined,\n): Promise<string | void> {\n const callback = this.async();\n // Load the module from the original typescript request (without !=! and the query)\n return this.loadModule(this.resourcePath, (err, source) => {\n if (err) {\n return callback(err);\n }\n const { experiments } = this.getOptions();\n const debugLog = createDebugLogger(this, experiments?.debug);\n\n debugLog(\"ts\", source);\n const css = extractCss(source);\n debugLog(\"css\", css);\n\n return resolveCrossFileConstant(this, this.context, css).then((result) => {\n debugLog(\"css resolved\", css);\n return callback(null, result, sourceMap);\n }, callback);\n });\n}\n\nfunction extractCss(code: string): string {\n const codeParts = code.split(\"/*YAK Extracted CSS:\\n\");\n let result = \"\";\n for (let i = 1; i < codeParts.length; i++) {\n const codeUntilEnd = codeParts[i].split(\"*/\")[0];\n result += codeUntilEnd;\n }\n return result;\n}\n\nfunction createDebugLogger(\n loaderContext: LoaderContext<YakConfigOptions>,\n debugOptions: Required<YakConfigOptions>[\"experiments\"][\"debug\"],\n) {\n if (\n !debugOptions ||\n (debugOptions !== true &&\n debugOptions.filter &&\n !debugOptions.filter(loaderContext.resourcePath))\n ) {\n return () => {};\n }\n const debugType = debugOptions === true ? \"ts\" : debugOptions.type;\n return (messageType: \"ts\" | \"css\" | \"css resolved\", message: string) => {\n if (messageType === debugType || debugType === \"all\") {\n console.log(\n \"🐮 Yak\",\n messageType,\n \"\\n\",\n loaderContext._compiler\n ? relative(\n loaderContext._compiler.context,\n loaderContext.resourcePath,\n )\n : loaderContext.resourcePath,\n \"\\n\\n\",\n message,\n );\n }\n };\n}\n","import path from \"path\";\nimport babel from \"@babel/core\";\n// @ts-expect-error - this is used by babel directly so we ignore that it is not typed\nimport babelPlugin from \"@babel/plugin-syntax-typescript\";\nimport type { Compilation, LoaderContext } from \"webpack\";\nimport { getCssModuleLocalIdent } from \"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js\";\n\nconst yakCssImportRegex =\n // Make mixin and selector non optional once we dropped support for the babel plugin\n /--yak-css-import\\:\\s*url\\(\"([^\"]+)\",?(|mixin|selector)\\);?/g;\n\nconst compilationCache = new WeakMap<\n Compilation,\n Map<string, Promise<ParsedFile>>\n>();\n\n/**\n * Resolves cross-file selectors in css files\n *\n * e.g.:\n * theme.ts:\n * ```ts\n * export const colors = {\n * primary: \"#ff0000\",\n * secondary: \"#00ff00\",\n * };\n * ```\n *\n * styles.ts:\n * ```ts\n * import { colors } from \"./theme\";\n * export const button = css`\n * background-color: ${colors.primary};\n * `;\n */\nexport async function resolveCrossFileConstant(\n loader: LoaderContext<{}>,\n pathContext: string,\n css: string,\n): Promise<string> {\n // Search for --yak-css-import: url(\"path/to/module\") in the css\n const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {\n const [fullMatch, encodedArguments, importKind] = match;\n const [moduleSpecifier, ...specifier] = encodedArguments\n .split(\":\")\n .map((entry) => decodeURIComponent(entry));\n return {\n encodedArguments,\n moduleSpecifier,\n specifier,\n importKind,\n position: match.index!,\n size: fullMatch.length,\n };\n });\n if (matches.length === 0) return css;\n\n try {\n // Resolve all imports concurrently\n const exportCache = new Map<string, Promise<ResolvedExport>>();\n const resolvedValues = await Promise.all(\n matches.map(({ moduleSpecifier, specifier, encodedArguments }) => {\n // The cache prevents resolving the same specifier multiple times\n // e.g.:\n // const a = css`\n // color: ${colors.primary};\n // border-color: ${colors.primary};\n // `;\n const resolvedFromCache = exportCache.get(encodedArguments);\n const resolvedValue =\n resolvedFromCache ||\n parseModule(loader, moduleSpecifier, pathContext).then(\n (parsedModule) =>\n resolveModuleSpecifierRecursively(\n loader,\n parsedModule,\n specifier,\n ),\n );\n if (!resolvedFromCache) {\n exportCache.set(encodedArguments, resolvedValue);\n }\n return resolvedValue;\n }),\n );\n\n // Replace the imports with the resolved values\n let result = css;\n for (let i = matches.length - 1; i >= 0; i--) {\n const { position, size, importKind, specifier } = matches[i];\n const resolved = resolvedValues[i];\n\n if (importKind === \"selector\") {\n if (resolved.type === \"mixin\") {\n throw new Error(\n `Found mixin but expected a selector - did you forget a semicolon after \\`${specifier.join(\n \".\",\n )}\\`?`,\n );\n }\n }\n\n const replacement =\n resolved.type === \"styled-component\"\n ? `:global(.${getCssModuleLocalIdent(\n {\n rootContext: loader.rootContext,\n resourcePath: resolved.from,\n },\n null,\n resolved.name,\n {},\n )})`\n : resolved.value;\n\n result =\n result.slice(0, position) +\n String(replacement) +\n result.slice(position + size);\n }\n\n return result;\n } catch (error) {\n throw new Error(\n `Error resolving cross-file selectors: ${\n (error as Error).message\n }\\nFile: ${loader.resourcePath}`,\n );\n }\n}\n\n/**\n * Resolves a module specifier to a parsed file\n *\n * e.g.:\n * ```\n * parseModule(loader, \"./theme\", \"/path/to/styles.ts\")\n * // -> { type: 'regular', secondary: { type: 'constant', value: '#00ff00' } } }, filePath: '/path/to/theme.ts' }\n * ```\n */\nasync function parseModule(\n loader: LoaderContext<{}>,\n moduleSpecifier: string,\n context: string,\n): Promise<ParsedFile> {\n const compilation = loader._compilation;\n if (!compilation) {\n throw new Error(\"Webpack compilation object not available\");\n }\n let cache = compilationCache.get(compilation);\n if (!cache) {\n cache = new Map();\n compilationCache.set(compilation, cache);\n }\n // The cache key is valid for the entire project so it can be reused\n // for different source files\n const cacheKey = path.resolve(context, moduleSpecifier);\n let filePromise = cache.get(cacheKey);\n if (!filePromise) {\n filePromise = (async () => {\n const resolved = await new Promise<string>((resolve, reject) => {\n loader.resolve(context, moduleSpecifier, (err, result) => {\n if (err) return reject(err);\n if (!result)\n return reject(new Error(`Could not resolve ${moduleSpecifier}`));\n resolve(result);\n });\n });\n return parseFile(loader, resolved);\n })();\n cache.set(cacheKey, filePromise);\n }\n // on file change, invalidate the cache\n loader.addDependency((await filePromise).filePath);\n return filePromise;\n}\n\nasync function parseFile(\n loader: LoaderContext<{}>,\n filePath: string,\n): Promise<ParsedFile> {\n const isYak =\n filePath.endsWith(\".yak.ts\") ||\n filePath.endsWith(\".yak.tsx\") ||\n filePath.endsWith(\".yak.js\") ||\n filePath.endsWith(\".yak.jsx\");\n const isTSX = filePath.endsWith(\".tsx\");\n\n try {\n if (isYak) {\n const module: Record<string, unknown> =\n await loader.importModule(filePath);\n const mappedModule = Object.fromEntries(\n Object.entries(module).map(([key, value]): [string, ParsedExport] => {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return [key, { type: \"constant\" as const, value }];\n } else if (\n value &&\n (typeof value === \"object\" || Array.isArray(value))\n ) {\n return [key, { type: \"record\" as const, value }];\n } else {\n return [key, { type: \"unsupported\" as const }];\n }\n }),\n );\n return { type: \"yak\", exports: mappedModule, filePath };\n }\n const sourceContents = new Promise<string>((resolve, reject) =>\n loader.fs.readFile(filePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n resolve(result || \"\");\n }),\n );\n\n const tranformedSource = new Promise<string>((resolve, reject) => {\n loader.loadModule(filePath, (err, source) => {\n if (err) return reject(err);\n resolve(source || \"\");\n });\n });\n\n const exports = await parseExports(await sourceContents, isTSX);\n const mixins = parseMixins(await tranformedSource);\n\n // Recursively resolve cross-file constants in mixins\n // e.g. cross file mixins inside a cross file mixin\n // or a cross file selector inside a cross file mixin\n await Promise.all(\n Object.entries(mixins).map(async ([name, mixin]) => {\n mixins[name] = {\n type: \"mixin\",\n value: await resolveCrossFileConstant(\n loader,\n path.dirname(filePath),\n mixin.value,\n ),\n };\n }),\n );\n\n return {\n type: \"regular\",\n exports: {\n ...exports,\n ...mixins,\n },\n filePath,\n };\n } catch (error) {\n throw new Error(\n `Error parsing file ${filePath}: ${(error as Error).message}`,\n );\n }\n}\n\nasync function parseExports(\n sourceContents: string,\n isTSX: boolean,\n): Promise<Record<string, ParsedExport>> {\n let exports: Record<string, ParsedExport> = {};\n\n try {\n babel.transformSync(sourceContents, {\n configFile: false,\n plugins: [\n [babelPlugin, { isTSX }],\n [\n (): babel.PluginObj => ({\n visitor: {\n ExportNamedDeclaration({ node }) {\n if (node.source) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === \"ExportSpecifier\" &&\n specifier.exported.type === \"Identifier\" &&\n specifier.local.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"re-export\",\n from: node.source!.value,\n imported: specifier.local.name,\n };\n }\n });\n } else if (node.declaration?.type === \"VariableDeclaration\") {\n node.declaration.declarations.forEach((declaration) => {\n if (\n declaration.id.type === \"Identifier\" &&\n declaration.init\n ) {\n exports[declaration.id.name] = parseExportValueExpression(\n declaration.init,\n );\n }\n });\n }\n },\n ExportAllDeclaration({ node }) {\n if (Object.keys(exports).length === 0) {\n exports[\"*\"] ||= {\n type: \"star-export\",\n from: [],\n };\n if (exports[\"*\"].type !== \"star-export\") {\n throw new Error(\"Invalid star export state\");\n }\n exports[\"*\"].from.push(node.source.value);\n }\n },\n },\n }),\n ],\n ],\n });\n\n return exports;\n } catch (error) {\n throw new Error(`Error parsing exports: ${(error as Error).message}`);\n }\n}\n\nfunction parseMixins(\n sourceContents: string,\n): Record<string, { type: \"mixin\"; value: string }> {\n // Mixins are always in the following format:\n // /*YAK EXPORTED MIXIN:name\n // css\n // */\n const mixinParts = sourceContents.split(\"/*YAK EXPORTED MIXIN:\");\n let mixins: Record<string, { type: \"mixin\"; value: string }> = {};\n for (let i = 1; i < mixinParts.length; i++) {\n const [comment] = mixinParts[i].split(\"*/\", 1);\n const position = comment.indexOf(\"\\n\");\n const name = comment.slice(0, position);\n const value = comment.slice(position + 1);\n mixins[name] = { type: \"mixin\", value };\n }\n return mixins;\n}\n\nfunction parseExportValueExpression(\n node: babel.types.Expression,\n): ParsedExport {\n if (\n node.type === \"CallExpression\" ||\n node.type === \"TaggedTemplateExpression\"\n ) {\n return { type: \"styled-component\" };\n } else if (node.type === \"StringLiteral\" || node.type === \"NumericLiteral\") {\n return { type: \"constant\", value: node.value };\n } else if (node.type === \"TemplateLiteral\" && node.quasis.length === 1) {\n return { type: \"constant\", value: node.quasis[0].value.raw };\n } else if (node.type === \"ObjectExpression\") {\n return { type: \"record\", value: parseObjectExpression(node) };\n }\n return { type: \"unsupported\" };\n}\n\nfunction parseObjectExpression(\n node: babel.types.ObjectExpression,\n): Record<string, any> {\n let result: Record<string, any> = {};\n for (const property of node.properties) {\n if (\n property.type === \"ObjectProperty\" &&\n property.key.type === \"Identifier\"\n ) {\n const key = property.key.name;\n result[key] = parseExportValueExpression(\n property.value as babel.types.Expression,\n );\n }\n }\n return result;\n}\n\n/**\n * Follows a specifier recursively until it finds its constant value\n * for example here it follows \"colors.primary\"\n *\n * ```\n * resolveModuleSpecifierRecursively(loader, \"@/theme\", [\"colors\", \"primary\"], \"colors:primary\")`\n * // -> { type: 'constant', value: '#ff0000' }\n * ```\n *\n * example structure:\n *\n * styles.ts:\n * ```\n * import { colors } from \"@/theme\";\n * export const button = css`color: ${colors.primary}`;\n * ```\n *\n * theme.ts:\n * ```\n * export { colors } from \"./colors\";\n * ```\n *\n * colors.ts:\n * ```\n * export const colors = { primary: \"#ff0000\" };\n * ```\n *\n */\nasync function resolveModuleSpecifierRecursively(\n loader: LoaderContext<{}>,\n module: ParsedFile,\n specifier: string[],\n): Promise<ResolvedExport> {\n try {\n const exportName = specifier[0];\n let exportValue = module.exports[exportName];\n // Follow star exports if there is only a single one\n // and the export does not exist in the current module\n if (exportValue === undefined) {\n const starExport = module.exports[\"*\"];\n if (starExport?.type === \"star-export\") {\n if (starExport.from.length > 1) {\n throw new Error(\n `Could not resolve ${specifier.join(\".\")} in module ${\n module.filePath\n } - Multiple star exports are not supported for performance reasons`,\n );\n }\n exportValue = {\n type: \"re-export\" as const,\n from: starExport.from[0],\n imported: exportName,\n };\n } else {\n throw new Error(\n `Could not resolve \"${specifier.join(\".\")}\" in module ${\n module.filePath\n }`,\n );\n }\n }\n // Follow reexport\n if (exportValue.type === \"re-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from,\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(loader, importedModule, [\n exportValue.imported,\n ...specifier.slice(1),\n ]);\n }\n\n if (exportValue.type === \"styled-component\") {\n return {\n type: \"styled-component\",\n from: module.filePath,\n name: specifier[specifier.length - 1],\n };\n } else if (exportValue.type === \"constant\") {\n return { type: \"constant\", value: exportValue.value };\n } else if (exportValue.type === \"record\") {\n let current: any = exportValue.value;\n let depth = 0;\n /// Drill down the specifier e.g. colors.primary\n do {\n if (typeof current === \"string\" || typeof current === \"number\") {\n return {\n type: \"constant\" as const,\n value: current,\n };\n } else if (\n !current ||\n (typeof current !== \"object\" && !Array.isArray(current))\n ) {\n throw new Error(\n `Error unpacking Record/Array \"${exportName}\".\\nKey \"${\n specifier[depth]\n }\" was of type \"${typeof current}\" but only String and Number are supported`,\n );\n }\n depth++;\n // mixins in .yak files are wrapped inside an object with a __yak key\n if (depth === specifier.length && \"__yak\" in current) {\n return { type: \"mixin\", value: current[\"__yak\"] };\n } else {\n current = current[specifier[depth]];\n }\n } while (current);\n if (specifier[depth] === undefined) {\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${specifier\n .slice(0, depth)\n .join(\".\")}\\` is not a string or number`,\n );\n }\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${\n specifier[depth]\n }\\` from \\`${specifier.slice(0, depth).join(\".\")}\\``,\n );\n } else if (exportValue.type === \"mixin\") {\n return { type: \"mixin\", value: exportValue.value };\n }\n throw new Error(\n `Error unpacking Record/Array - unexpected exportValue \"${\n exportValue.type\n }\" for specifier \"${specifier.join(\".\")}\"`,\n );\n } catch (error) {\n throw new Error(\n `Error resolving from module ${module.filePath}: ${\n (error as Error).message\n }`,\n );\n }\n}\n\ntype ParsedFile =\n | { type: \"regular\"; exports: Record<string, ParsedExport>; filePath: string }\n | { type: \"yak\"; exports: Record<string, ParsedExport>; filePath: string };\n\ntype ParsedExport =\n | { type: \"styled-component\" }\n | { type: \"mixin\"; value: string }\n | { type: \"constant\"; value: string | number }\n | { type: \"record\"; value: {} }\n | { type: \"unsupported\" }\n | { type: \"re-export\"; from: string; imported: string }\n | { type: \"star-export\"; from: string[] };\n\ntype ResolvedExport =\n | { type: \"styled-component\"; from: string; name: string }\n | { type: \"mixin\"; value: string | number }\n | { type: \"constant\"; value: string | number };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;AACjB,kBAAkB;AAElB,sCAAwB;AAExB,oCAAuC;AAEvC,IAAM;AAAA;AAAA,EAEJ;AAAA;AAEF,IAAM,mBAAmB,oBAAI,QAG3B;AAqBF,eAAsB,yBACpB,QACA,aACA,KACiB;AAEjB,QAAM,UAAU,CAAC,GAAG,IAAI,SAAS,iBAAiB,CAAC,EAAE,IAAI,CAAC,UAAU;AAClE,UAAM,CAAC,WAAW,kBAAkB,UAAU,IAAI;AAClD,UAAM,CAAC,iBAAiB,GAAG,SAAS,IAAI,iBACrC,MAAM,GAAG,EACT,IAAI,CAAC,UAAU,mBAAmB,KAAK,CAAC;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,MAAM,UAAU;AAAA,IAClB;AAAA,EACF,CAAC;AACD,M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;AACP,aAAO,SAAS,GAAG;AAAA,IACrB;AACA,UAAM,EAAE,YAAY,IAAI,KAAK,WAAW;AACxC,UAAM,WAAW,kBAAkB,MAAM,aAAa,KAAK;AAE3D,aAAS,MAAM,MAAM;AACrB,UAAM,MAAM,WAAW,MAAM;AAC7B,aAAS,OAAO,GAAG;AAEnB,WAAO,yBAAyB,MAAM,KAAK,SAAS,GAAG,EAAE,KAAK,CAAC,WAAW;AACxE,eAAS,gBAAgB,GAAG;AAC5B,aAAO,SAAS,MAAM,QAAQ,SAAS;AAAA,IACzC,GAAG,QAAQ;AAAA,EACb,CAAC;AACH;AAEA,SAAS,WAAW,MAAsB;AACxC,QAAM,YAAY,KAAK,MAAM,wBAAwB;AACrD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAM,eAAe,UAAU,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;AAC/C,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAEA,SAAS,kBACP,eACA,cACA;AACA,MACE,CAAC,gBACA,iBAAiB,QAChB,aAAa,UACb,CAAC,aAAa,OAAO,cAAc,YAAY,GACjD;AACA,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,YAAY,iBAAiB,OAAO,OAAO,aAAa;AAC9D,SAAO,CAAC,aAA4C,YAAoB;AACtE,QAAI,gBAAgB,aAAa,cAAc,OAAO;AACpD,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,gBACV;AAAA,UACE,cAAc,UAAU;AAAA,UACxB,cAAc;AAAA,QAChB,IACA,cAAc;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","module","babel","babelPlugin","import_path"]}
1
+ {"version":3,"sources":["../../loaders/css-loader.ts","../../loaders/lib/resolveCrossFileSelectors.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { resolveCrossFileConstant } from \"./lib/resolveCrossFileSelectors.js\";\nimport { relative } from \"path\";\nimport type { YakConfigOptions } from \"../withYak/index.js\";\n\n/**\n * Transform typescript to css\n *\n * This loader takes the cached result from the yak tsloader\n * and extracts the css from the generated comments\n */\nexport default async function cssExtractLoader(\n this: LoaderContext<YakConfigOptions>,\n // Instead of the source code, we receive the extracted css\n // from the ts-loader transformation\n _code: string,\n sourceMap: string | undefined,\n): Promise<string | void> {\n const callback = this.async();\n // Load the module from the original typescript request (without !=! and the query)\n return this.loadModule(this.resourcePath, (err, source) => {\n if (err) {\n return callback(err);\n }\n const { experiments } = this.getOptions();\n const debugLog = createDebugLogger(this, experiments?.debug);\n\n debugLog(\"ts\", source);\n const css = extractCss(source);\n debugLog(\"css\", css);\n\n return resolveCrossFileConstant(this, this.context, css).then((result) => {\n debugLog(\"css resolved\", css);\n return callback(null, result, sourceMap);\n }, callback);\n });\n}\n\nfunction extractCss(code: string): string {\n const codeParts = code.split(\"/*YAK Extracted CSS:\\n\");\n let result = \"\";\n for (let i = 1; i < codeParts.length; i++) {\n const codeUntilEnd = codeParts[i].split(\"*/\")[0];\n result += codeUntilEnd;\n }\n return result;\n}\n\nfunction createDebugLogger(\n loaderContext: LoaderContext<YakConfigOptions>,\n debugOptions: Required<YakConfigOptions>[\"experiments\"][\"debug\"],\n) {\n if (\n !debugOptions ||\n (debugOptions !== true &&\n debugOptions.filter &&\n !debugOptions.filter(loaderContext.resourcePath))\n ) {\n return () => {};\n }\n const debugType = debugOptions === true ? \"ts\" : debugOptions.type;\n return (messageType: \"ts\" | \"css\" | \"css resolved\", message: string) => {\n if (messageType === debugType || debugType === \"all\") {\n console.log(\n \"🐮 Yak\",\n messageType,\n \"\\n\",\n loaderContext._compiler\n ? relative(\n loaderContext._compiler.context,\n loaderContext.resourcePath,\n )\n : loaderContext.resourcePath,\n \"\\n\\n\",\n message,\n );\n }\n };\n}\n","import path from \"path\";\nimport babel from \"@babel/core\";\n// @ts-expect-error - this is used by babel directly so we ignore that it is not typed\nimport babelPlugin from \"@babel/plugin-syntax-typescript\";\nimport type { Compilation, LoaderContext } from \"webpack\";\nimport { getCssModuleLocalIdent } from \"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js\";\n\nconst yakCssImportRegex =\n // Make mixin and selector non optional once we dropped support for the babel plugin\n /--yak-css-import\\:\\s*url\\(\"([^\"]+)\",?(|mixin|selector)\\)(;?)/g;\n\nconst compilationCache = new WeakMap<\n Compilation,\n Map<string, Promise<ParsedFile>>\n>();\n\n/**\n * Resolves cross-file selectors in css files\n *\n * e.g.:\n * theme.ts:\n * ```ts\n * export const colors = {\n * primary: \"#ff0000\",\n * secondary: \"#00ff00\",\n * };\n * ```\n *\n * styles.ts:\n * ```ts\n * import { colors } from \"./theme\";\n * export const button = css`\n * background-color: ${colors.primary};\n * `;\n */\nexport async function resolveCrossFileConstant(\n loader: LoaderContext<{}>,\n pathContext: string,\n css: string,\n): Promise<string> {\n // Search for --yak-css-import: url(\"path/to/module\") in the css\n const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {\n const [fullMatch, encodedArguments, importKind, semicolon] = match;\n const [moduleSpecifier, ...specifier] = encodedArguments\n .split(\":\")\n .map((entry) => decodeURIComponent(entry));\n return {\n encodedArguments,\n moduleSpecifier,\n specifier,\n importKind,\n semicolon,\n position: match.index!,\n size: fullMatch.length,\n };\n });\n if (matches.length === 0) return css;\n\n try {\n // Resolve all imports concurrently\n const exportCache = new Map<string, Promise<ResolvedExport>>();\n const resolvedValues = await Promise.all(\n matches.map(({ moduleSpecifier, specifier, encodedArguments }) => {\n // The cache prevents resolving the same specifier multiple times\n // e.g.:\n // const a = css`\n // color: ${colors.primary};\n // border-color: ${colors.primary};\n // `;\n const resolvedFromCache = exportCache.get(encodedArguments);\n const resolvedValue =\n resolvedFromCache ||\n parseModule(loader, moduleSpecifier, pathContext).then(\n (parsedModule) =>\n resolveModuleSpecifierRecursively(\n loader,\n parsedModule,\n specifier,\n ),\n );\n if (!resolvedFromCache) {\n exportCache.set(encodedArguments, resolvedValue);\n }\n return resolvedValue;\n }),\n );\n\n // Replace the imports with the resolved values\n let result = css;\n for (let i = matches.length - 1; i >= 0; i--) {\n const { position, size, importKind, specifier, semicolon } = matches[i];\n const resolved = resolvedValues[i];\n\n if (importKind === \"selector\") {\n if (resolved.type === \"mixin\") {\n throw new Error(\n `Found mixin but expected a selector - did you forget a semicolon after \\`${specifier.join(\n \".\",\n )}\\`?`,\n );\n }\n }\n\n const replacement =\n resolved.type === \"styled-component\"\n ? `:global(.${getCssModuleLocalIdent(\n {\n rootContext: loader.rootContext,\n resourcePath: resolved.from,\n },\n null,\n resolved.name,\n {},\n )})`\n : resolved.value +\n // resolved.value can be of two different types:\n // - mixin:\n // ${mixinName};\n // - constant:\n // color: ${value};\n // For mixins the semicolon is already included in the value\n // but for constants it has to be added manually\n ([\"}\", \";\"].includes(String(resolved.value).trimEnd().slice(-1))\n ? \"\"\n : semicolon);\n\n result =\n result.slice(0, position) +\n String(replacement) +\n result.slice(position + size);\n }\n\n return result;\n } catch (error) {\n throw new Error(\n `Error resolving cross-file selectors: ${\n (error as Error).message\n }\\nFile: ${loader.resourcePath}`,\n );\n }\n}\n\n/**\n * Resolves a module specifier to a parsed file\n *\n * e.g.:\n * ```\n * parseModule(loader, \"./theme\", \"/path/to/styles.ts\")\n * // -> { type: 'regular', secondary: { type: 'constant', value: '#00ff00' } } }, filePath: '/path/to/theme.ts' }\n * ```\n */\nasync function parseModule(\n loader: LoaderContext<{}>,\n moduleSpecifier: string,\n context: string,\n): Promise<ParsedFile> {\n const compilation = loader._compilation;\n if (!compilation) {\n throw new Error(\"Webpack compilation object not available\");\n }\n let cache = compilationCache.get(compilation);\n if (!cache) {\n cache = new Map();\n compilationCache.set(compilation, cache);\n }\n // The cache key is valid for the entire project so it can be reused\n // for different source files\n const cacheKey = path.resolve(context, moduleSpecifier);\n let filePromise = cache.get(cacheKey);\n if (!filePromise) {\n filePromise = (async () => {\n const resolved = await new Promise<string>((resolve, reject) => {\n loader.resolve(context, moduleSpecifier, (err, result) => {\n if (err) return reject(err);\n if (!result)\n return reject(new Error(`Could not resolve ${moduleSpecifier}`));\n resolve(result);\n });\n });\n return parseFile(loader, resolved);\n })();\n cache.set(cacheKey, filePromise);\n }\n // on file change, invalidate the cache\n loader.addDependency((await filePromise).filePath);\n return filePromise;\n}\n\nasync function parseFile(\n loader: LoaderContext<{}>,\n filePath: string,\n): Promise<ParsedFile> {\n const isYak =\n filePath.endsWith(\".yak.ts\") ||\n filePath.endsWith(\".yak.tsx\") ||\n filePath.endsWith(\".yak.js\") ||\n filePath.endsWith(\".yak.jsx\");\n const isTSX = filePath.endsWith(\".tsx\");\n\n try {\n if (isYak) {\n const module: Record<string, unknown> =\n await loader.importModule(filePath);\n const mappedModule = Object.fromEntries(\n Object.entries(module).map(([key, value]): [string, ParsedExport] => {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return [key, { type: \"constant\" as const, value }];\n } else if (\n value &&\n (typeof value === \"object\" || Array.isArray(value))\n ) {\n return [key, { type: \"record\" as const, value }];\n } else {\n return [key, { type: \"unsupported\" as const }];\n }\n }),\n );\n return { type: \"yak\", exports: mappedModule, filePath };\n }\n const sourceContents = new Promise<string>((resolve, reject) =>\n loader.fs.readFile(filePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n resolve(result || \"\");\n }),\n );\n\n const tranformedSource = new Promise<string>((resolve, reject) => {\n loader.loadModule(filePath, (err, source) => {\n if (err) return reject(err);\n resolve(source || \"\");\n });\n });\n\n const exports = await parseExports(await sourceContents, isTSX);\n const mixins = parseMixins(await tranformedSource);\n\n // Recursively resolve cross-file constants in mixins\n // e.g. cross file mixins inside a cross file mixin\n // or a cross file selector inside a cross file mixin\n await Promise.all(\n Object.entries(mixins).map(async ([name, mixin]) => {\n mixins[name] = {\n type: \"mixin\",\n value: await resolveCrossFileConstant(\n loader,\n path.dirname(filePath),\n mixin.value,\n ),\n };\n }),\n );\n\n return {\n type: \"regular\",\n exports: {\n ...exports,\n ...mixins,\n },\n filePath,\n };\n } catch (error) {\n throw new Error(\n `Error parsing file ${filePath}: ${(error as Error).message}`,\n );\n }\n}\n\nasync function parseExports(\n sourceContents: string,\n isTSX: boolean,\n): Promise<Record<string, ParsedExport>> {\n let exports: Record<string, ParsedExport> = {};\n\n try {\n babel.transformSync(sourceContents, {\n configFile: false,\n plugins: [\n [babelPlugin, { isTSX }],\n [\n (): babel.PluginObj => ({\n visitor: {\n ExportNamedDeclaration({ node }) {\n if (node.source) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === \"ExportSpecifier\" &&\n specifier.exported.type === \"Identifier\" &&\n specifier.local.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"re-export\",\n from: node.source!.value,\n imported: specifier.local.name,\n };\n }\n });\n } else if (node.declaration?.type === \"VariableDeclaration\") {\n node.declaration.declarations.forEach((declaration) => {\n if (\n declaration.id.type === \"Identifier\" &&\n declaration.init\n ) {\n exports[declaration.id.name] = parseExportValueExpression(\n declaration.init,\n );\n }\n });\n }\n },\n ExportDeclaration({ node }) {\n if (\"specifiers\" in node && node.source) {\n const { specifiers, source } = node;\n specifiers.forEach((specifier) => {\n // export * as color from \"./colors\";\n if (\n specifier.type === \"ExportNamespaceSpecifier\" &&\n specifier.exported.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"star-export\",\n from: [source.value],\n };\n }\n });\n }\n },\n ExportAllDeclaration({ node }) {\n if (Object.keys(exports).length === 0) {\n exports[\"*\"] ||= {\n type: \"star-export\",\n from: [],\n };\n if (exports[\"*\"].type !== \"star-export\") {\n throw new Error(\"Invalid star export state\");\n }\n exports[\"*\"].from.push(node.source.value);\n }\n },\n },\n }),\n ],\n ],\n });\n\n return exports;\n } catch (error) {\n throw new Error(`Error parsing exports: ${(error as Error).message}`);\n }\n}\n\nfunction parseMixins(\n sourceContents: string,\n): Record<string, { type: \"mixin\"; value: string }> {\n // Mixins are always in the following format:\n // /*YAK EXPORTED MIXIN:name\n // css\n // */\n const mixinParts = sourceContents.split(\"/*YAK EXPORTED MIXIN:\");\n let mixins: Record<string, { type: \"mixin\"; value: string }> = {};\n for (let i = 1; i < mixinParts.length; i++) {\n const [comment] = mixinParts[i].split(\"*/\", 1);\n const position = comment.indexOf(\"\\n\");\n const name = comment.slice(0, position);\n const value = comment.slice(position + 1);\n mixins[name] = { type: \"mixin\", value };\n }\n return mixins;\n}\n\nfunction parseExportValueExpression(\n node: babel.types.Expression,\n): ParsedExport {\n if (\n node.type === \"CallExpression\" ||\n node.type === \"TaggedTemplateExpression\"\n ) {\n return { type: \"styled-component\" };\n } else if (node.type === \"StringLiteral\" || node.type === \"NumericLiteral\") {\n return { type: \"constant\", value: node.value };\n } else if (node.type === \"TemplateLiteral\" && node.quasis.length === 1) {\n return { type: \"constant\", value: node.quasis[0].value.raw };\n } else if (node.type === \"ObjectExpression\") {\n return { type: \"record\", value: parseObjectExpression(node) };\n }\n return { type: \"unsupported\" };\n}\n\nfunction parseObjectExpression(\n node: babel.types.ObjectExpression,\n): Record<string, any> {\n let result: Record<string, any> = {};\n for (const property of node.properties) {\n if (\n property.type === \"ObjectProperty\" &&\n property.key.type === \"Identifier\"\n ) {\n const key = property.key.name;\n result[key] = parseExportValueExpression(\n property.value as babel.types.Expression,\n );\n }\n }\n return result;\n}\n\n/**\n * Follows a specifier recursively until it finds its constant value\n * for example here it follows \"colors.primary\"\n *\n * ```\n * resolveModuleSpecifierRecursively(loader, \"@/theme\", [\"colors\", \"primary\"], \"colors:primary\")`\n * // -> { type: 'constant', value: '#ff0000' }\n * ```\n *\n * example structure:\n *\n * styles.ts:\n * ```\n * import { colors } from \"@/theme\";\n * export const button = css`color: ${colors.primary}`;\n * ```\n *\n * theme.ts:\n * ```\n * export { colors } from \"./colors\";\n * ```\n *\n * colors.ts:\n * ```\n * export const colors = { primary: \"#ff0000\" };\n * ```\n *\n */\nasync function resolveModuleSpecifierRecursively(\n loader: LoaderContext<{}>,\n module: ParsedFile,\n specifier: string[],\n): Promise<ResolvedExport> {\n try {\n const exportName = specifier[0];\n let exportValue = module.exports[exportName];\n // Follow star exports if there is only a single one\n // and the export does not exist in the current module\n if (exportValue === undefined) {\n const starExport = module.exports[\"*\"];\n if (starExport?.type === \"star-export\") {\n if (starExport.from.length > 1) {\n throw new Error(\n `Could not resolve ${specifier.join(\".\")} in module ${\n module.filePath\n } - Multiple star exports are not supported for performance reasons`,\n );\n }\n exportValue = {\n type: \"re-export\" as const,\n from: starExport.from[0],\n imported: exportName,\n };\n } else {\n throw new Error(\n `Could not resolve \"${specifier.join(\".\")}\" in module ${\n module.filePath\n }`,\n );\n }\n }\n // Follow reexport\n // e.g. export { colors as primaryColors } from \"./colors\";\n if (exportValue.type === \"re-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from,\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(loader, importedModule, [\n exportValue.imported,\n ...specifier.slice(1),\n ]);\n }\n // Namespace export\n // e.g. export * as colors from \"./colors\";\n else if (exportValue.type === \"star-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from[0],\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(\n loader,\n importedModule,\n specifier.slice(1),\n );\n }\n\n if (exportValue.type === \"styled-component\") {\n return {\n type: \"styled-component\",\n from: module.filePath,\n name: specifier[specifier.length - 1],\n };\n } else if (exportValue.type === \"constant\") {\n return { type: \"constant\", value: exportValue.value };\n } else if (exportValue.type === \"record\") {\n let current: any = exportValue.value;\n let depth = 0;\n /// Drill down the specifier e.g. colors.primary\n do {\n if (typeof current === \"string\" || typeof current === \"number\") {\n return {\n type: \"constant\" as const,\n value: current,\n };\n } else if (\n !current ||\n (typeof current !== \"object\" && !Array.isArray(current))\n ) {\n throw new Error(\n `Error unpacking Record/Array \"${exportName}\".\\nKey \"${\n specifier[depth]\n }\" was of type \"${typeof current}\" but only String and Number are supported`,\n );\n }\n depth++;\n // mixins in .yak files are wrapped inside an object with a __yak key\n if (depth === specifier.length && \"__yak\" in current) {\n return { type: \"mixin\", value: current[\"__yak\"] };\n } else if (depth === specifier.length && \"value\" in current) {\n return { type: \"constant\", value: current[\"value\"] };\n } else {\n current = current[specifier[depth]];\n }\n } while (current);\n if (specifier[depth] === undefined) {\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${specifier\n .slice(0, depth)\n .join(\".\")}\\` is not a string or number`,\n );\n }\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${\n specifier[depth]\n }\\` from \\`${specifier.slice(0, depth).join(\".\")}\\``,\n );\n } else if (exportValue.type === \"mixin\") {\n return { type: \"mixin\", value: exportValue.value };\n }\n throw new Error(\n `Error unpacking Record/Array - unexpected exportValue \"${\n exportValue.type\n }\" for specifier \"${specifier.join(\".\")}\"`,\n );\n } catch (error) {\n throw new Error(\n `Error resolving from module ${module.filePath}: ${\n (error as Error).message\n }`,\n );\n }\n}\n\ntype ParsedFile =\n | { type: \"regular\"; exports: Record<string, ParsedExport>; filePath: string }\n | { type: \"yak\"; exports: Record<string, ParsedExport>; filePath: string };\n\ntype ParsedExport =\n | { type: \"styled-component\" }\n | { type: \"mixin\"; value: string }\n | { type: \"constant\"; value: string | number }\n | { type: \"record\"; value: {} }\n | { type: \"unsupported\" }\n | { type: \"re-export\"; from: string; imported: string }\n | { type: \"star-export\"; from: string[] };\n\ntype ResolvedExport =\n | { type: \"styled-component\"; from: string; name: string }\n | { type: \"mixin\"; value: string | number }\n | { type: \"constant\"; value: string | number };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;AACjB,kBAAkB;AAElB,sCAAwB;AAExB,oCAAuC;AAEvC,IAAM;AAAA;AAAA,EAEJ;AAAA;AAEF,IAAM,mBAAmB,oBAAI,QAG3B;AAqBF,eAAsB,yBACpB,QACA,aACA,KACiB;AAEjB,QAAM,UAAU,CAAC,GAAG,IAAI,SAAS,iBAAiB,CAAC,E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,UAAM,EAAE,YAAY,IAAI,KAAK,WAAW;AACxC,UAAM,WAAW,kBAAkB,MAAM,aAAa,KAAK;AAE3D,aAAS,MAAM,MAAM;AACrB,UAAM,MAAM,WAAW,MAAM;AAC7B,aAAS,OAAO,GAAG;AAEnB,WAAO,yBAAyB,MAAM,KAAK,SAAS,GAAG,EAAE,KAAK,CAAC,WAAW;AACxE,eAAS,gBAAgB,GAAG;AAC5B,aAAO,SAAS,MAAM,QAAQ,SAAS;AAAA,IACzC,GAAG,QAAQ;AAAA,EACb,CAAC;AACH;AAEA,SAAS,WAAW,MAAsB;AACxC,QAAM,YAAY,KAAK,MAAM,wBAAwB;AACrD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAM,eAAe,UAAU,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;AAC/C,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAEA,SAAS,kBACP,eACA,cACA;AACA,MACE,CAAC,gBACA,iBAAiB,QAChB,aAAa,UACb,CAAC,aAAa,OAAO,cAAc,YAAY,GACjD;AACA,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,YAAY,iBAAiB,OAAO,OAAO,aAAa;AAC9D,SAAO,CAAC,aAA4C,YAAoB;AACtE,QAAI,gBAAgB,aAAa,cAAc,OAAO;AACpD,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,gBACV;AAAA,UACE,cAAc,UAAU;AAAA,UACxB,cAAc;AAAA,QAChB,IACA,cAAc;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","module","babel","babelPlugin","import_path"]}
@@ -1145,8 +1145,7 @@ async function tsloader(source) {
1145
1145
  {
1146
1146
  replaces,
1147
1147
  rootContext,
1148
- devMode: this.mode === "development",
1149
- crossFile: this.getOptions().experiments?.crossFileSelectors ?? false
1148
+ devMode: this.mode === "development"
1150
1149
  }
1151
1150
  ]
1152
1151
  ]