next-yak 8.0.0 → 8.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.
@@ -1,7 +1,42 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
1
30
  // loaders/turbo-loader.ts
2
- import { transform as swcTransform } from "@swc/core";
3
- import { dirname } from "path";
4
- import { createContext, runInContext } from "vm";
31
+ var turbo_loader_exports = {};
32
+ __export(turbo_loader_exports, {
33
+ default: () => cssExtractLoader
34
+ });
35
+ module.exports = __toCommonJS(turbo_loader_exports);
36
+ var import_core = require("@swc/core");
37
+ var import_node_module = require("module");
38
+ var import_node_path = require("path");
39
+ var import_node_vm = require("vm");
5
40
 
6
41
  // cross-file-resolver/parseModule.ts
7
42
  async function parseModule(context, modulePath) {
@@ -36,12 +71,12 @@ async function parseModule(context, modulePath) {
36
71
  }
37
72
  }
38
73
  async function uncachedParseModule(context, modulePath) {
39
- const exports = await context.extractExports(modulePath);
40
- if (!exports.importYak) {
74
+ const exports2 = await context.extractExports(modulePath);
75
+ if (!exports2.importYak) {
41
76
  return {
42
77
  type: "regular",
43
78
  path: modulePath,
44
- exports
79
+ exports: exports2
45
80
  };
46
81
  }
47
82
  const transformed = await context.getTransformed(modulePath);
@@ -54,7 +89,7 @@ async function uncachedParseModule(context, modulePath) {
54
89
  type: "regular",
55
90
  path: modulePath,
56
91
  js: transformed,
57
- exports,
92
+ exports: exports2,
58
93
  styledComponents,
59
94
  mixins
60
95
  };
@@ -257,12 +292,12 @@ async function resolveModule(context, filePath) {
257
292
  }
258
293
  async function uncachedResolveModule(context, filePath) {
259
294
  const parsedModule = await context.parse(filePath);
260
- const exports = parsedModule.exports;
295
+ const exports2 = parsedModule.exports;
261
296
  if (parsedModule.type !== "regular") {
262
297
  return {
263
298
  resolved: {
264
299
  path: parsedModule.path,
265
- exports
300
+ exports: exports2
266
301
  },
267
302
  dependencies: []
268
303
  };
@@ -271,15 +306,15 @@ async function uncachedResolveModule(context, filePath) {
271
306
  if (parsedModule.styledComponents) {
272
307
  Object.values(parsedModule.styledComponents).map((styledComponent) => {
273
308
  if (styledComponent.nameParts.length === 1) {
274
- exports.named[styledComponent.nameParts[0]] = {
309
+ exports2.named[styledComponent.nameParts[0]] = {
275
310
  type: "styled-component",
276
311
  className: styledComponent.value
277
312
  };
278
313
  } else {
279
- let exportEntry = exports.named[styledComponent.nameParts[0]];
314
+ let exportEntry = exports2.named[styledComponent.nameParts[0]];
280
315
  if (!exportEntry) {
281
316
  exportEntry = { type: "record", value: {} };
282
- exports.named[styledComponent.nameParts[0]] = exportEntry;
317
+ exports2.named[styledComponent.nameParts[0]] = exportEntry;
283
318
  } else if (exportEntry.type !== "record") {
284
319
  throw new CauseError(`Error parsing file "${parsedModule.path}"`, {
285
320
  cause: `"${styledComponent.nameParts[0]}" is not a record`
@@ -317,15 +352,15 @@ async function uncachedResolveModule(context, filePath) {
317
352
  dependencies.add(dep);
318
353
  }
319
354
  if (mixin.nameParts.length === 1) {
320
- exports.named[mixin.nameParts[0]] = {
355
+ exports2.named[mixin.nameParts[0]] = {
321
356
  type: "mixin",
322
357
  value: resolved
323
358
  };
324
359
  } else {
325
- let exportEntry = exports.named[mixin.nameParts[0]];
360
+ let exportEntry = exports2.named[mixin.nameParts[0]];
326
361
  if (!exportEntry) {
327
362
  exportEntry = { type: "record", value: {} };
328
- exports.named[mixin.nameParts[0]] = exportEntry;
363
+ exports2.named[mixin.nameParts[0]] = exportEntry;
329
364
  } else if (exportEntry.type !== "record") {
330
365
  throw new CauseError(`Error parsing file "${parsedModule.path}"`, {
331
366
  cause: `"${mixin.nameParts[0]}" is not a record`
@@ -358,7 +393,7 @@ async function uncachedResolveModule(context, filePath) {
358
393
  return {
359
394
  resolved: {
360
395
  path: parsedModule.path,
361
- exports
396
+ exports: exports2
362
397
  },
363
398
  dependencies: Array.from(dependencies)
364
399
  };
@@ -581,13 +616,13 @@ async function sha1(message) {
581
616
  }
582
617
 
583
618
  // loaders/lib/debugLogger.ts
584
- import { relative } from "path";
619
+ var import_path = require("path");
585
620
  function createDebugLogger(loaderContext, debugOptions) {
586
621
  if (!debugOptions) {
587
622
  return () => {
588
623
  };
589
624
  }
590
- const currentPath = loaderContext._compiler ? relative(loaderContext._compiler.context, loaderContext.resourcePath) : loaderContext.resourcePath;
625
+ const currentPath = loaderContext._compiler ? (0, import_path.relative)(loaderContext._compiler.context, loaderContext.resourcePath) : loaderContext.resourcePath;
591
626
  return (messageType, message) => {
592
627
  const pathWithExtension = messageType !== "ts" ? currentPath + `.${messageType}` : currentPath;
593
628
  if (debugOptions === true || new RegExp(debugOptions).test(pathWithExtension)) {
@@ -623,8 +658,8 @@ function extractCss(code, transpilationMode) {
623
658
  }
624
659
 
625
660
  // loaders/lib/resolveCrossFileSelectors.ts
626
- import { parse } from "@babel/parser";
627
- import traverse from "@babel/traverse";
661
+ var import_parser = require("@babel/parser");
662
+ var import_traverse = __toESM(require("@babel/traverse"), 1);
628
663
  async function parseExports(sourceContents) {
629
664
  const moduleExports = {
630
665
  importYak: true,
@@ -634,11 +669,11 @@ async function parseExports(sourceContents) {
634
669
  const variableDeclarations = {};
635
670
  let defaultIdentifier = null;
636
671
  try {
637
- const ast = parse(sourceContents, {
672
+ const ast = (0, import_parser.parse)(sourceContents, {
638
673
  sourceType: "module",
639
674
  plugins: ["jsx", "typescript"]
640
675
  });
641
- traverse.default(ast, {
676
+ import_traverse.default.default(ast, {
642
677
  // Track all variable declarations in the file
643
678
  VariableDeclarator({ node }) {
644
679
  if (node.id.type === "Identifier" && node.init) {
@@ -746,6 +781,9 @@ function parseObjectExpression(node) {
746
781
  }
747
782
 
748
783
  // loaders/turbo-loader.ts
784
+ var import_meta = {};
785
+ var universalRequire = typeof require === "undefined" ? (0, import_node_module.createRequire)(import_meta.url) : require;
786
+ var yakSwcPluginPath = universalRequire.resolve("yak-swc");
749
787
  async function cssExtractLoader(code, sourceMap) {
750
788
  const callback = this.async();
751
789
  if (!code.includes("next-yak")) {
@@ -757,10 +795,10 @@ async function cssExtractLoader(code, sourceMap) {
757
795
  } = this.getOptions();
758
796
  const debugLog = createDebugLogger(this, experiments?.debug);
759
797
  const resolveTurbopack = this.getResolve({});
760
- const transform = createTransform(yakPluginOptions);
798
+ const transform = createTransform(yakPluginOptions, yakSwcPluginPath);
761
799
  const resolveFn = (specifier, importer) => {
762
800
  return new Promise((resolve, reject) => {
763
- resolveTurbopack(dirname(importer), specifier, (err, result2) => {
801
+ resolveTurbopack((0, import_node_path.dirname)(importer), specifier, (err, result2) => {
764
802
  if (err) return reject(err);
765
803
  if (!result2) return reject(new Error(`Could not resolve ${specifier}`));
766
804
  resolve(result2);
@@ -799,7 +837,7 @@ async function cssExtractLoader(code, sourceMap) {
799
837
  },
800
838
  evaluateYakModule: async (modulePath2) => {
801
839
  const code2 = await fsReadFile(modulePath2);
802
- const transformed = await swcTransform(code2, {
840
+ const transformed = await (0, import_core.transform)(code2, {
803
841
  filename: modulePath2,
804
842
  sourceFileName: modulePath2,
805
843
  jsc: {
@@ -807,7 +845,7 @@ async function cssExtractLoader(code, sourceMap) {
807
845
  react: { runtime: "automatic" }
808
846
  },
809
847
  experimental: {
810
- plugins: [["yak-swc", yakPluginOptions]]
848
+ plugins: [[yakSwcPluginPath, yakPluginOptions]]
811
849
  }
812
850
  },
813
851
  module: {
@@ -815,7 +853,7 @@ async function cssExtractLoader(code, sourceMap) {
815
853
  }
816
854
  });
817
855
  const moduleObject = { exports: {} };
818
- const context = createContext({
856
+ const context = (0, import_node_vm.createContext)({
819
857
  require: (path) => {
820
858
  throw new Error(
821
859
  `Yak files cannot have imports in turbopack.
@@ -825,7 +863,7 @@ This will be resolved once Vercel adds "this.importModule" support for turbopack
825
863
  );
826
864
  },
827
865
  __filename: modulePath2,
828
- __dirname: dirname(modulePath2),
866
+ __dirname: (0, import_node_path.dirname)(modulePath2),
829
867
  global: {},
830
868
  console,
831
869
  Buffer,
@@ -839,7 +877,7 @@ This will be resolved once Vercel adds "this.importModule" support for turbopack
839
877
  exports: moduleObject.exports,
840
878
  module: moduleObject
841
879
  });
842
- runInContext(transformed.code, context);
880
+ (0, import_node_vm.runInContext)(transformed.code, context);
843
881
  return moduleObject.exports;
844
882
  }
845
883
  },
@@ -859,10 +897,10 @@ This will be resolved once Vercel adds "this.importModule" support for turbopack
859
897
  debugLog("css-resolved", resolved);
860
898
  return callback(null, codeWithCrossFileResolved, result.map);
861
899
  }
862
- function createTransform(yakPluginOptions) {
900
+ function createTransform(yakPluginOptions, yakSwcPluginPath2) {
863
901
  return (data, modulePath, rootPath, sourceMap) => (
864
902
  // https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-swc-loader.ts#L143
865
- swcTransform(data, {
903
+ (0, import_core.transform)(data, {
866
904
  filename: modulePath,
867
905
  inputSourceMap: sourceMap,
868
906
  sourceMaps: true,
@@ -870,7 +908,7 @@ function createTransform(yakPluginOptions) {
870
908
  sourceRoot: rootPath,
871
909
  jsc: {
872
910
  experimental: {
873
- plugins: [["yak-swc", yakPluginOptions]]
911
+ plugins: [[yakSwcPluginPath2, yakPluginOptions]]
874
912
  },
875
913
  transform: {
876
914
  react: {
@@ -890,7 +928,4 @@ function createTransform(yakPluginOptions) {
890
928
  })
891
929
  );
892
930
  }
893
- export {
894
- cssExtractLoader as default
895
- };
896
- //# sourceMappingURL=turbo-loader.js.map
931
+ //# sourceMappingURL=turbo-loader.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../loaders/turbo-loader.ts","../../cross-file-resolver/parseModule.ts","../../cross-file-resolver/Errors.ts","../../cross-file-resolver/resolveCrossFileConstant.ts","../../loaders/lib/debugLogger.ts","../../loaders/lib/extractCss.ts","../../loaders/lib/resolveCrossFileSelectors.ts"],"sourcesContent":["import { transform as swcTransform } from \"@swc/core\";\nimport { createRequire } from \"node:module\";\nimport { dirname } from \"node:path\";\nimport { createContext, runInContext } from \"node:vm\";\nimport type { LoaderContext } from \"webpack\";\nimport { parseModule } from \"../cross-file-resolver/parseModule.js\";\nimport { resolveCrossFileConstant } from \"../cross-file-resolver/resolveCrossFileConstant.js\";\nimport type { YakConfigOptions } from \"../withYak/index.js\";\nimport { createDebugLogger } from \"./lib/debugLogger.js\";\nimport { extractCss } from \"./lib/extractCss.js\";\nimport { parseExports } from \"./lib/resolveCrossFileSelectors.js\";\n\nconst universalRequire =\n typeof require === \"undefined\" ? createRequire(import.meta.url) : require;\nconst yakSwcPluginPath = universalRequire.resolve(\"yak-swc\");\n\n/**\n * This loader transforms styled-components styles to a static data-url import\n * The compile-time nexy-yak transformation takes javascript/typescript as input,\n * strips all inline css code and adds the css as static css urls\n * e.g.: `import \"data:text/css;base64,\"`\n */\nexport default async function cssExtractLoader(\n this: LoaderContext<{ yakOptions: YakConfigOptions; yakPluginOptions: any }>,\n code: string,\n sourceMap: string | undefined,\n): Promise<string | void> {\n const callback = this.async();\n\n // process only files which include next-yak for maximal compile performance\n if (!code.includes(\"next-yak\")) {\n return callback(null, code, sourceMap);\n }\n\n const {\n yakPluginOptions,\n yakOptions: { experiments },\n } = this.getOptions();\n const debugLog = createDebugLogger(this, experiments?.debug);\n const resolveTurbopack = this.getResolve({});\n const transform = createTransform(yakPluginOptions, yakSwcPluginPath);\n\n const resolveFn = (specifier: string, importer: string) => {\n return new Promise<string>((resolve, reject) => {\n resolveTurbopack(dirname(importer), specifier, (err, result) => {\n if (err) return reject(err);\n if (!result) return reject(new Error(`Could not resolve ${specifier}`));\n resolve(result);\n });\n });\n };\n\n const fsReadFile = (filePath: string) =>\n new Promise<string>((resolve, reject) =>\n this.fs.readFile(filePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n if (!result) return reject(new Error(`File not found: ${filePath}`));\n resolve(result);\n }),\n );\n\n const result = await transform(\n code,\n this.resourcePath,\n this.rootContext,\n sourceMap,\n );\n debugLog(\"ts\", result.code);\n\n let css = extractCss(result.code, \"Css\");\n debugLog(\"css\", css);\n\n const { resolved } = await resolveCrossFileConstant(\n {\n parse: (modulePath) => {\n return parseModule(\n {\n transpilationMode: \"Css\",\n extractExports: async (modulePath) => {\n const sourceContents = await fsReadFile(modulePath);\n return parseExports(sourceContents);\n },\n getTransformed: async (modulePath) => {\n const sourceContent = await fsReadFile(modulePath);\n return transform(sourceContent, modulePath, this.rootContext);\n },\n evaluateYakModule: async (modulePath: string) => {\n const code = await fsReadFile(modulePath);\n\n const transformed = await swcTransform(code, {\n filename: modulePath,\n sourceFileName: modulePath,\n jsc: {\n transform: {\n react: { runtime: \"automatic\" },\n },\n experimental: {\n plugins: [[yakSwcPluginPath, yakPluginOptions]],\n },\n },\n module: {\n type: \"commonjs\",\n },\n });\n\n const moduleObject = { exports: {} };\n const context = createContext({\n require: (path: string) => {\n throw new Error(\n `Yak files cannot have imports in turbopack.\\n` +\n `Found require/import usage in: ${modulePath} to import: ${path}.\\n` +\n `Yak files should be self-contained and only export constants or styled components.\\n` +\n `This will be resolved once Vercel adds \"this.importModule\" support for turbopack.`,\n );\n },\n __filename: modulePath,\n __dirname: dirname(modulePath),\n global: {},\n console,\n Buffer,\n process,\n setTimeout,\n clearTimeout,\n setInterval,\n clearInterval,\n setImmediate,\n clearImmediate,\n exports: moduleObject.exports,\n module: moduleObject,\n });\n runInContext(transformed.code, context);\n\n return moduleObject.exports;\n },\n },\n modulePath,\n );\n },\n resolve: resolveFn,\n },\n this.resourcePath,\n css,\n );\n\n const dataUrl = result.code\n .split(\"\\n\")\n .find((line) => line.includes(\"data:text/css;base64\"))!;\n\n const codeWithCrossFileResolved = result.code.replace(\n dataUrl,\n `import \"data:text/css;base64,${Buffer.from(resolved).toString(\"base64\")}\"`,\n );\n\n debugLog(\"css-resolved\", resolved);\n return callback(null, codeWithCrossFileResolved, result.map);\n}\n\nfunction createTransform(yakPluginOptions: any, yakSwcPluginPath: string) {\n return (\n data: string,\n modulePath: string,\n rootPath: string,\n sourceMap?: any,\n ) =>\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-swc-loader.ts#L143\n swcTransform(data, {\n filename: modulePath,\n inputSourceMap: sourceMap,\n sourceMaps: true,\n sourceFileName: modulePath,\n sourceRoot: rootPath,\n jsc: {\n experimental: {\n plugins: [[yakSwcPluginPath, yakPluginOptions]],\n },\n transform: {\n react: {\n runtime: \"preserve\",\n },\n },\n target: \"es2022\",\n loose: false,\n minify: {\n compress: false,\n mangle: false,\n },\n preserveAllComments: true,\n },\n minify: false,\n isModule: true,\n });\n}\n","import { type Cache } from \"./types.js\";\n\nexport async function parseModule(\n context: ParseContext,\n modulePath: string,\n): Promise<ParsedModule> {\n try {\n const isYak =\n modulePath.endsWith(\".yak.ts\") ||\n modulePath.endsWith(\".yak.tsx\") ||\n modulePath.endsWith(\".yak.js\") ||\n modulePath.endsWith(\".yak.jsx\");\n\n // handle yak file by evaluating and mapping exported value to the\n // `ModuleExport` format. This operation is not cached to always get a fresh\n // value from those modules\n if (isYak && context.evaluateYakModule) {\n const yakModule = await context.evaluateYakModule(modulePath);\n const yakExports = objectToModuleExport(yakModule);\n\n return {\n type: \"yak\",\n exports: { importYak: false, named: yakExports, all: [] },\n path: modulePath,\n };\n }\n\n if (context.cache?.parse === undefined) {\n return uncachedParseModule(context, modulePath);\n }\n\n const cached = context.cache.parse.get(modulePath);\n if (cached === undefined) {\n // We cache the parsed file to avoid re-parsing it.\n // It's ok, that initial parallel requests to the same file will parse it multiple times.\n // This avoid deadlocks do to the fact that we load multiple modules in the chain for cross file references.\n const parsedModule = await uncachedParseModule(context, modulePath);\n\n context.cache.parse.set(modulePath, parsedModule);\n if (context.cache.parse.addDependency) {\n context.cache.parse.addDependency(modulePath, modulePath);\n }\n return parsedModule;\n }\n\n return cached;\n } catch (error) {\n throw new Error(\n `Error parsing file ${modulePath}: ${(error as Error).message}`,\n );\n }\n}\n\nexport async function uncachedParseModule(\n context: ParseContext,\n modulePath: string,\n): Promise<ParsedModule> {\n const exports = await context.extractExports(modulePath);\n\n // early exit if no yak import was found\n if (!exports.importYak) {\n return {\n type: \"regular\",\n path: modulePath,\n exports,\n };\n }\n\n const transformed = await context.getTransformed(modulePath);\n const mixins = parseMixins(transformed.code);\n const styledComponents = parseStyledComponents(\n transformed.code,\n context.transpilationMode,\n );\n\n return {\n type: \"regular\",\n path: modulePath,\n js: transformed,\n exports,\n styledComponents,\n mixins,\n };\n}\n\nfunction parseMixins(sourceContents: string): Record<string, Mixin> {\n // Mixins are always in the following format:\n // /*YAK EXPORTED MIXIN:fancy:aspectRatio:16:9\n // css\n // */\n const mixinParts = sourceContents.split(\"/*YAK EXPORTED MIXIN:\");\n let mixins: Record<\n string,\n { type: \"mixin\"; value: string; nameParts: string[] }\n > = {};\n\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] = {\n type: \"mixin\",\n value,\n nameParts: name.split(\":\").map((part) => decodeURIComponent(part)),\n };\n }\n return mixins;\n}\n\nfunction parseStyledComponents(\n sourceContents: string,\n transpilationMode?: \"Css\" | \"CssModule\",\n): Record<string, StyledComponent> {\n // cross-file Styled Components are always in the following format:\n // /*YAK EXPORTED STYLED:ComponentName:ClassName*/\n const styledParts = sourceContents.split(\"/*YAK EXPORTED STYLED:\");\n let styledComponents: Record<string, StyledComponent> = {};\n\n for (let i = 1; i < styledParts.length; i++) {\n const [comment] = styledParts[i].split(\"*/\", 1);\n const [componentName, className] = comment.split(\":\");\n styledComponents[componentName] = {\n type: \"styled-component\",\n nameParts: componentName.split(\".\"),\n value:\n transpilationMode === \"Css\"\n ? `.${className}`\n : `:global(.${className})`,\n };\n }\n\n return styledComponents;\n}\n\nfunction objectToModuleExport(object: object) {\n return Object.fromEntries(\n Object.entries(object).map(([key, value]): [string, ModuleExport] => {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return [key, { type: \"constant\" as const, value }];\n } else if (value && (typeof value === \"object\" || Array.isArray(value))) {\n return [\n key,\n { type: \"record\" as const, value: objectToModuleExport(value) },\n ];\n } else {\n return [key, { type: \"unsupported\" as const, hint: String(value) }];\n }\n }),\n );\n}\n\nexport type ParseContext = {\n cache?: { parse?: Cache<ParsedModule> };\n transpilationMode?: \"Css\" | \"CssModule\";\n evaluateYakModule?: (\n modulePath: string,\n ) => Promise<Record<string, unknown>> | Record<string, unknown>;\n extractExports: (\n modulePath: string,\n ) => Promise<ModuleExports> | ModuleExports;\n getTransformed: (\n modulePath: string,\n ) => Promise<{ code: string; map?: string }> | { code: string; map?: string };\n};\n\nexport type ModuleExports = {\n importYak: boolean;\n named: Record<string, ModuleExport>;\n all: string[];\n};\n\nexport type ConstantExport = { type: \"constant\"; value: string | number };\nexport type RecordExport = {\n type: \"record\";\n value: Record<string, ModuleExport>;\n};\nexport type UnsupportedExport = { type: \"unsupported\"; hint?: string };\nexport type ReExport = { type: \"re-export\"; name: string; from: string };\nexport type NamespaceReExport = { type: \"namespace-re-export\"; from: string };\nexport type TagTemplateExport = { type: \"tag-template\" };\n\nexport type ModuleExport =\n | ConstantExport\n | TagTemplateExport\n | RecordExport\n | UnsupportedExport\n | ReExport\n | NamespaceReExport;\n\nexport type ParsedModule = {\n path: string;\n exports: ModuleExports;\n} & (\n | {\n type: \"regular\";\n js?: { code: string; map?: string };\n styledComponents?: Record<string, StyledComponent>;\n mixins?: Record<string, Mixin>;\n }\n | {\n type: \"yak\";\n }\n);\n\nexport type StyledComponent = {\n type: \"styled-component\";\n value: string;\n nameParts: string[];\n};\n\nexport type Mixin = { type: \"mixin\"; value: string; nameParts: string[] };\n","export class CauseError extends Error {\n circular?: boolean;\n constructor(message: string, options?: { cause?: unknown }) {\n super(\n `${message}${options?.cause ? `\\n Caused by: ${typeof options.cause === \"object\" && options.cause !== null && \"message\" in options.cause ? options.cause.message : String(options.cause)}` : \"\"}`,\n );\n\n if (options?.cause instanceof CauseError && options.cause.circular) {\n this.circular = true;\n }\n }\n}\n\nexport class ResolveError extends CauseError {}\n\nexport class CircularDependencyError extends CauseError {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.circular = true;\n }\n}\n","import type {\n ConstantExport,\n ModuleExport,\n ParsedModule,\n RecordExport,\n} from \"./parseModule.js\";\nimport { Cache } from \"./types.js\";\nimport { CauseError, CircularDependencyError, ResolveError } from \"./Errors.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\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 context: ResolveContext,\n filePath: string,\n css: string,\n): Promise<{ resolved: string; dependencies: string[] }> {\n const resolveCrossFileConstant = context.cache?.resolveCrossFileConstant;\n if (resolveCrossFileConstant === undefined) {\n return uncachedResolveCrossFileConstant(context, filePath, css);\n }\n\n const cacheKey = await sha1(filePath + \":\" + css);\n\n const cached = resolveCrossFileConstant.get(cacheKey);\n\n if (cached === undefined) {\n const resolvedCrossFilConstantPromise = uncachedResolveCrossFileConstant(\n context,\n filePath,\n css,\n );\n resolveCrossFileConstant.set(cacheKey, resolvedCrossFilConstantPromise);\n\n if (resolveCrossFileConstant.addDependency) {\n resolveCrossFileConstant.addDependency(cacheKey, filePath);\n resolvedCrossFilConstantPromise.then((value) => {\n for (const dep of value.dependencies) {\n resolveCrossFileConstant!.addDependency!(cacheKey, dep);\n }\n });\n }\n\n return resolvedCrossFilConstantPromise;\n }\n\n return cached;\n}\n\nexport async function uncachedResolveCrossFileConstant(\n context: ResolveContext,\n filePath: string,\n css: string,\n): Promise<{ resolved: string; dependencies: string[] }> {\n const yakImports = await parseYakCssImport(context, filePath, css);\n\n if (yakImports.length === 0) {\n return { resolved: css, dependencies: [] };\n }\n\n try {\n const dependencies = new Set<string>();\n\n const resolvedValues = await Promise.all(\n yakImports.map(async ({ moduleSpecifier, specifier }) => {\n const { resolved: resolvedModule } = await resolveModule(\n context,\n moduleSpecifier,\n );\n\n const resolvedValue = await resolveModuleSpecifierRecursively(\n context,\n resolvedModule,\n specifier,\n );\n\n for (const dependency of resolvedValue.from) {\n dependencies.add(dependency);\n }\n\n return resolvedValue;\n }),\n );\n\n // Replace the imports with the resolved values\n let result = css;\n for (let i = yakImports.length - 1; i >= 0; i--) {\n const { position, size, importKind, specifier, semicolon } =\n yakImports[i];\n const resolved = resolvedValues[i];\n\n let replacement: string;\n\n if (resolved.type === \"unresolved-tag\") {\n // tag that could not be resolved to styled-components or mixins are\n // interpolated to produce valid CSS with minimal impact (since we don't\n // know what the value should actually be). For mixins (CSS rules) we\n // interpolate an empty string, and for selectors we interpolate\n // \"undefined\" (a selector that would match nothing)\n replacement = importKind === \"mixin\" ? \"\" : \"undefined\";\n } else {\n if (importKind === \"selector\") {\n if (\n resolved.type !== \"styled-component\" &&\n resolved.type !== \"constant\"\n ) {\n throw new Error(\n `Found \"${\n resolved.type\n }\" but expected a selector - did you forget a semicolon after \"${specifier.join(\n \".\",\n )}\"?`,\n );\n }\n }\n\n replacement =\n resolved.type === \"styled-component\"\n ? resolved.value\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\n result =\n result.slice(0, position) +\n String(replacement) +\n result.slice(position + size);\n }\n\n return { resolved: result, dependencies: Array.from(dependencies) };\n } catch (error) {\n throw new CauseError(\n `Error while resolving cross-file selectors in file \"${filePath}\"`,\n { cause: error },\n );\n }\n}\n\n/**\n * Search for --yak-css-import: url(\"path/to/module\") in the css\n */\nasync function parseYakCssImport(\n context: ResolveContext,\n filePath: string,\n css: string,\n): Promise<YakCssImport[]> {\n const yakImports: YakCssImport[] = [];\n\n for (const match of css.matchAll(yakCssImportRegex)) {\n const [fullMatch, encodedArguments, importKind, semicolon] = match;\n const [moduleSpecifier, ...specifier] = encodedArguments\n .split(\":\")\n .map((entry) => decodeURIComponent(entry));\n\n yakImports.push({\n encodedArguments,\n moduleSpecifier: await context.resolve(moduleSpecifier, filePath),\n specifier,\n importKind: importKind as YakImportKind,\n semicolon,\n position: match.index,\n size: fullMatch.length,\n });\n }\n\n return yakImports;\n}\n\nasync function resolveModule(context: ResolveContext, filePath: string) {\n if (context.cache?.resolve === undefined) {\n return uncachedResolveModule(context, filePath);\n }\n\n const cached = context.cache.resolve.get(filePath);\n if (cached === undefined) {\n const resolvedPromise = uncachedResolveModule(context, filePath);\n context.cache.resolve.set(filePath, resolvedPromise);\n\n if (context.cache.resolve.addDependency) {\n context.cache.resolve.addDependency(filePath, filePath);\n resolvedPromise.then((value) => {\n for (const dep of value.dependencies) {\n context.cache!.resolve!.addDependency!(filePath, dep);\n }\n });\n }\n\n return resolvedPromise;\n }\n\n return cached;\n}\n\nasync function uncachedResolveModule(\n context: ResolveContext,\n filePath: string,\n): Promise<{ resolved: ResolvedModule; dependencies: string[] }> {\n const parsedModule = await context.parse(filePath);\n\n const exports = parsedModule.exports as ResolvedExports;\n\n if (parsedModule.type !== \"regular\") {\n return {\n resolved: {\n path: parsedModule.path,\n exports,\n },\n dependencies: [],\n };\n }\n\n const dependencies = new Set<string>();\n\n // Reconcile styled-component \"name\" structure with export structure\n if (parsedModule.styledComponents) {\n Object.values(parsedModule.styledComponents).map((styledComponent) => {\n if (styledComponent.nameParts.length === 1) {\n exports.named[styledComponent.nameParts[0]] = {\n type: \"styled-component\",\n className: styledComponent.value,\n };\n } else {\n let exportEntry = exports.named[styledComponent.nameParts[0]];\n\n if (!exportEntry) {\n exportEntry = { type: \"record\", value: {} };\n exports.named[styledComponent.nameParts[0]] = exportEntry;\n } else if (exportEntry.type !== \"record\") {\n throw new CauseError(`Error parsing file \"${parsedModule.path}\"`, {\n cause: `\"${styledComponent.nameParts[0]}\" is not a record`,\n });\n }\n\n let current = exportEntry.value;\n for (let i = 1; i < styledComponent.nameParts.length - 1; i++) {\n let next = current[styledComponent.nameParts[i]];\n if (!next) {\n next = { type: \"record\", value: {} };\n current[styledComponent.nameParts[i]] = next;\n } else if (next.type !== \"record\") {\n throw new CauseError(`Error parsing file \"${parsedModule.path}\"`, {\n cause: `\"${styledComponent.nameParts.slice(0, i + 1).join(\".\")}\" is not a record`,\n });\n }\n current = next.value;\n }\n current[\n styledComponent.nameParts[styledComponent.nameParts.length - 1]\n ] = {\n type: \"styled-component\",\n className: styledComponent.value,\n };\n }\n });\n }\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 if (parsedModule.mixins) {\n await Promise.all(\n Object.values(parsedModule.mixins).map(async (mixin) => {\n const { resolved, dependencies: deps } = await resolveCrossFileConstant(\n context,\n parsedModule.path,\n mixin.value,\n );\n\n for (const dep of deps) {\n dependencies.add(dep);\n }\n\n if (mixin.nameParts.length === 1) {\n exports.named[mixin.nameParts[0]] = {\n type: \"mixin\",\n value: resolved,\n };\n } else {\n let exportEntry = exports.named[mixin.nameParts[0]];\n\n if (!exportEntry) {\n exportEntry = { type: \"record\", value: {} };\n exports.named[mixin.nameParts[0]] = exportEntry;\n } else if (exportEntry.type !== \"record\") {\n throw new CauseError(`Error parsing file \"${parsedModule.path}\"`, {\n cause: `\"${mixin.nameParts[0]}\" is not a record`,\n });\n }\n\n let current = exportEntry.value;\n for (let i = 1; i < mixin.nameParts.length - 1; i++) {\n let next = current[mixin.nameParts[i]];\n if (!next) {\n next = { type: \"record\", value: {} };\n current[mixin.nameParts[i]] = next;\n } else if (next.type !== \"record\") {\n throw new CauseError(\n `Error parsing file \"${parsedModule.path}\"`,\n {\n cause: `\"${mixin.nameParts.slice(0, i + 1).join(\".\")}\" is not a record`,\n },\n );\n }\n current = next.value;\n }\n current[mixin.nameParts[mixin.nameParts.length - 1]] = {\n type: \"mixin\",\n value: resolved,\n };\n }\n }),\n );\n }\n return {\n resolved: {\n path: parsedModule.path,\n exports,\n },\n dependencies: Array.from(dependencies),\n };\n}\n\nasync function resolveModuleSpecifierRecursively(\n context: ResolveContext,\n resolvedModule: ResolvedModule,\n specifiers: string[],\n seen = new Set<string>(),\n): Promise<ResolvedCssImport> {\n const exportName = specifiers[0];\n const exportValue = resolvedModule.exports.named[exportName];\n if (exportValue !== undefined) {\n if (seen.has(resolvedModule.path + \":\" + exportName)) {\n throw new CircularDependencyError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in module \"${\n resolvedModule.path\n }\"`,\n { cause: \"Circular dependency detected\" },\n );\n }\n\n seen.add(resolvedModule.path + \":\" + exportName);\n return resolveModuleExport(\n context,\n resolvedModule.path,\n exportValue,\n specifiers,\n seen,\n );\n }\n\n let i = 1;\n for (const from of resolvedModule.exports.all) {\n if (context.exportAllLimit && i++ > context.exportAllLimit) {\n throw new ResolveError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in module \"${\n resolvedModule.path\n }\"`,\n {\n cause: `More than ${context.exportAllLimit} star exports are not supported for performance reasons`,\n },\n );\n }\n\n try {\n const resolved = await resolveModuleExport(\n context,\n resolvedModule.path,\n {\n type: \"re-export\",\n from,\n name: exportName,\n },\n specifiers,\n seen,\n );\n\n if (seen.has(resolvedModule.path + \":*\")) {\n throw new CircularDependencyError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in module \"${\n resolvedModule.path\n }\"`,\n { cause: \"Circular dependency detected\" },\n );\n }\n\n seen.add(resolvedModule.path + \":*\");\n\n return resolved;\n } catch (error) {\n // ignore resolve error, it means the specifier was not found in the\n // current module, we just have to continue the loop.\n if (!(error instanceof ResolveError)) {\n throw error;\n }\n // if the cause of the error is a circular dependency down the road do not\n // ignore the error\n if (error.circular) {\n throw error;\n }\n }\n }\n\n throw new ResolveError(`Unable to resolve \"${specifiers.join(\".\")}\"`, {\n cause: `no matching export found in module \"${resolvedModule.path}\"`,\n });\n}\n\nasync function resolveModuleExport(\n context: ResolveContext,\n filePath: string,\n moduleExport: ResolvedExport,\n specifiers: string[],\n seen: Set<string>,\n): Promise<ResolvedCssImport> {\n try {\n switch (moduleExport.type) {\n case \"re-export\": {\n const { resolved: reExportedModule } = await resolveModule(\n context,\n await context.resolve(moduleExport.from, filePath),\n );\n const resolved = await resolveModuleSpecifierRecursively(\n context,\n reExportedModule,\n [moduleExport.name, ...specifiers.slice(1)],\n seen,\n );\n if (resolved) {\n resolved.from.push(filePath);\n }\n return resolved;\n }\n case \"namespace-re-export\": {\n const { resolved: reExportedModule } = await resolveModule(\n context,\n await context.resolve(moduleExport.from, filePath),\n );\n const resolved = await resolveModuleSpecifierRecursively(\n context,\n reExportedModule,\n specifiers.slice(1),\n seen,\n );\n if (resolved) {\n resolved.from.push(filePath);\n }\n return resolved;\n }\n case \"styled-component\": {\n return {\n type: \"styled-component\",\n from: [filePath],\n source: filePath,\n name: specifiers[specifiers.length - 1],\n value: moduleExport.className,\n };\n }\n // usually at this point `tag-template` exports where already resolved to\n // styled-components if a matching styled-component comment was generated\n // by yak-swc. So resolving a value to a `tag-template` at this stage\n // would mean that the user tried to use the result of a call to a\n // different tag-template than yak's styled in a template. This is usually\n // invalid.\n //\n // But there is an issue with Nextjs. Next build in two passes, once for\n // the server bundle, once for the client bundle. During the server-side\n // build, each module with the `\"use client\"` directive is transformed to\n // throw errors if the exported symbol are used. This transformation\n // removes the comments generated by `yak-swc`, so instead of the expected\n // `styled-component`, calls to `styled` resolve to a `tag-template`\n // (because no classname was found in the now absent comments).\n //\n // To summarize, if a \"use client\" bundle exports a styled component that\n // is used in a \"standard\" module, the resolve logic would throw with\n // \"unknown type tag-template\".\n //\n // To avoid this error, the resolve logic must handle those `tag-template`\n // with a special type `unresolved-tag`. Those will be interpolated to\n // valid CSS with minimal effect (to avoid CSS syntax error in the case of\n // Nextjs server build)\n case \"tag-template\": {\n return {\n type: \"unresolved-tag\",\n from: [filePath],\n source: filePath,\n name: specifiers[specifiers.length - 1],\n };\n }\n case \"constant\": {\n return {\n type: \"constant\",\n from: [filePath],\n source: filePath,\n value: moduleExport.value,\n };\n }\n case \"record\": {\n const resolvedInRecord = resolveSpecifierInRecord(\n moduleExport,\n specifiers[0],\n specifiers.slice(1),\n );\n return resolveModuleExport(\n context,\n filePath,\n resolvedInRecord,\n specifiers,\n seen,\n );\n }\n case \"mixin\": {\n return {\n type: \"mixin\",\n from: [filePath],\n source: filePath,\n value: moduleExport.value,\n };\n }\n }\n } catch (error) {\n throw new ResolveError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in module \"${filePath}\"`,\n { cause: error },\n );\n }\n\n throw new ResolveError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in module \"${filePath}\"`,\n { cause: `unknown type \"${moduleExport.type}\"` },\n );\n}\n\nfunction resolveSpecifierInRecord(\n record: ExtendedRecordExport,\n name: string,\n specifiers: string[],\n): ConstantExport | ResolvedStyledComponent | ResolvedMixin {\n if (specifiers.length === 0) {\n throw new ResolveError(\"did not expect an object\");\n }\n let depth = 0;\n let current: ResolvedExport = record;\n while (current && current.type === \"record\" && depth < specifiers.length) {\n current = current.value[specifiers[depth]];\n depth += 1;\n }\n\n if (current === undefined || depth !== specifiers.length) {\n throw new ResolveError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in object/array \"${name}\"`,\n { cause: \"path not found\" },\n );\n }\n\n if (\n current.type === \"constant\" ||\n current.type === \"styled-component\" ||\n current.type === \"mixin\"\n ) {\n return current;\n }\n\n // mixins in .yak files are wrapped inside an object with a __yak key\n if (\n current.type === \"record\" &&\n \"__yak\" in current.value &&\n current.value.__yak.type === \"constant\"\n ) {\n return { type: \"mixin\", value: String(current.value.__yak.value) };\n }\n\n throw new ResolveError(\n `Unable to resolve \"${specifiers.join(\".\")}\" in object/array \"${name}\"`,\n { cause: \"only string and numbers are supported\" },\n );\n}\n\n/**\n * hex SHA-1 hash of a message using webcrypto\n * Keeps yak independent from node api (therefore executable in browser)\n */\nasync function sha1(message: string) {\n const resultBuffer = await globalThis.crypto.subtle.digest(\n \"SHA-1\",\n new TextEncoder().encode(message),\n );\n return Array.from(new Uint8Array(resultBuffer), (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n ).join(\"\");\n}\n\ntype ResolvedCssImport =\n | {\n type: \"styled-component\";\n source: string;\n from: string[];\n name: string;\n value: string;\n }\n | {\n type: \"unresolved-tag\";\n source: string;\n from: string[];\n name: string;\n }\n | { type: \"mixin\"; source: string; from: string[]; value: string | number }\n | {\n type: \"constant\";\n source: string;\n from: string[];\n value: string | number;\n };\n\nexport type ResolveContext = {\n parse: (modulePath: string) => Promise<ParsedModule> | ParsedModule;\n cache?: {\n resolve?: Cache<\n Promise<{ resolved: ResolvedModule; dependencies: string[] }>\n >;\n resolveCrossFileConstant?: Cache<\n Promise<{ resolved: string; dependencies: string[] }>\n >;\n };\n exportAllLimit?: number;\n resolve: (specifier: string, importer: string) => Promise<string> | string;\n};\n\ntype YakImportKind = \"mixin\" | \"selector\";\n\ntype YakCssImport = {\n encodedArguments: string;\n moduleSpecifier: string;\n specifier: string[];\n importKind: YakImportKind;\n semicolon: string;\n position: number;\n size: number;\n};\n\nexport type ExtendedRecordExport = {\n type: \"record\";\n value: Record<string, ResolvedExport>;\n};\n\nexport type ResolvedMixin = { type: \"mixin\"; value: string };\nexport type ResolvedStyledComponent = {\n type: \"styled-component\";\n className: string;\n};\n\nexport type ResolvedExport =\n | Exclude<ModuleExport, RecordExport>\n | ExtendedRecordExport\n | ResolvedStyledComponent\n | ResolvedMixin;\n\nexport type ResolvedExports = {\n named: Record<string, ResolvedExport>;\n all: string[];\n};\n\nexport type ResolvedModule = {\n path: string;\n exports: ResolvedExports;\n};\n","import { relative } from \"path\";\nimport type { LoaderContext } from \"webpack\";\nimport type { YakConfigOptions } from \"../../withYak/index.js\";\n\n/**\n * Creates a debug logger function that conditionally logs messages\n * based on debug options and file paths.\n */\nexport function createDebugLogger(\n loaderContext: LoaderContext<unknown>,\n debugOptions: Required<YakConfigOptions>[\"experiments\"][\"debug\"],\n) {\n if (!debugOptions) {\n return () => {};\n }\n const currentPath = loaderContext._compiler\n ? relative(loaderContext._compiler.context, loaderContext.resourcePath)\n : loaderContext.resourcePath;\n return (\n messageType: \"ts\" | \"css\" | \"css-resolved\",\n message: string | Buffer<ArrayBufferLike> | undefined,\n ) => {\n // the path contains already the extension for the ts{x} file\n const pathWithExtension =\n messageType !== \"ts\" ? currentPath + `.${messageType}` : currentPath;\n if (\n debugOptions === true ||\n new RegExp(debugOptions).test(pathWithExtension)\n ) {\n console.log(\"🐮 Yak\", pathWithExtension, \"\\n\\n\", message);\n }\n };\n}\n","import { YakConfigOptions } from \"../../withYak/index.js\";\n\n/**\n * Extracts CSS content from code that contains YAK-generated CSS comments.\n * Parses the input code and returns the extracted CSS, optionally adding\n * a cssmodules directive based on the transpilation mode.\n */\nexport function extractCss(\n code: string | Buffer<ArrayBufferLike>,\n transpilationMode: NonNullable<\n YakConfigOptions[\"experiments\"]\n >[\"transpilationMode\"],\n): string {\n let codeString: string;\n\n if (typeof code === \"string\") {\n codeString = code;\n } else if (code instanceof Buffer) {\n codeString = code.toString(\"utf-8\");\n } else if (code instanceof ArrayBuffer) {\n codeString = new TextDecoder(\"utf-8\").decode(code);\n } else {\n throw new Error(\n \"Invalid input type: code must be string, Buffer, or ArrayBuffer\",\n );\n }\n\n const codeParts = codeString.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 if (result && transpilationMode !== \"Css\") {\n result = \"/* cssmodules-pure-no-check */\\n\" + result;\n }\n\n return result;\n}\n","import { parse } from \"@babel/parser\";\nimport traverse from \"@babel/traverse\";\nimport type { Compilation, LoaderContext } from \"webpack\";\nimport {\n ModuleExport,\n ModuleExports,\n ParseContext,\n ParsedModule,\n parseModule,\n} from \"../../cross-file-resolver/parseModule.js\";\nimport {\n ResolveContext,\n resolveCrossFileConstant as genericResolveCrossFileConstant,\n} from \"../../cross-file-resolver/resolveCrossFileConstant.js\";\nimport { YakConfigOptions } from \"../../withYak/index.js\";\n\nconst compilationCache = new WeakMap<\n Compilation,\n {\n parsedFiles: Map<string, ParsedModule>;\n }\n>();\n\nexport async function resolveCrossFileConstant(\n loader: LoaderContext<{}>,\n pathContext: string,\n css: string,\n): Promise<string> {\n const { resolved } = await genericResolveCrossFileConstant(\n getResolveContext(loader),\n loader.resourcePath,\n css,\n );\n return resolved;\n}\n\nfunction getCompilationCache(loader: LoaderContext<YakConfigOptions>) {\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 = {\n parsedFiles: new Map(),\n };\n compilationCache.set(compilation, cache);\n }\n return cache;\n}\n\nfunction getParseContext(\n loader: LoaderContext<YakConfigOptions>,\n): ParseContext {\n return {\n cache: { parse: getCompilationCache(loader).parsedFiles },\n async extractExports(modulePath) {\n const sourceContents = new Promise<string>((resolve, reject) =>\n loader.fs.readFile(modulePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n resolve(result || \"\");\n }),\n );\n return parseExports(await sourceContents);\n },\n async getTransformed(modulePath) {\n const transformedSource = new Promise<string>((resolve, reject) => {\n loader.loadModule(modulePath, (err, source) => {\n if (err) return reject(err);\n let sourceString: string;\n if (typeof source === \"string\") {\n sourceString = source;\n } else if (source instanceof Buffer) {\n sourceString = source.toString(\"utf-8\");\n } else if (source instanceof ArrayBuffer) {\n sourceString = new TextDecoder(\"utf-8\").decode(source);\n } else {\n throw new Error(\n \"Invalid input type: code must be string, Buffer, or ArrayBuffer\",\n );\n }\n resolve(sourceString || \"\");\n });\n });\n return { code: await transformedSource };\n },\n async evaluateYakModule(modulePath) {\n return loader.importModule(modulePath);\n },\n transpilationMode: loader.getOptions().experiments?.transpilationMode,\n };\n}\n\nfunction getResolveContext(\n loader: LoaderContext<YakConfigOptions>,\n): ResolveContext {\n const parseContext = getParseContext(loader);\n return {\n parse: (modulePath) => parseModule(parseContext, modulePath),\n resolve: async (specifier, importer) => {\n return resolveModule(loader, specifier, dirname(importer));\n },\n };\n}\n\n/**\n * Resolves a module by wrapping loader.resolve in a promise\n */\nexport async function resolveModule(\n loader: LoaderContext<{}>,\n moduleSpecifier: string,\n context: string,\n): Promise<string> {\n return 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}\n\nexport async function parseExports(\n sourceContents: string,\n): Promise<ModuleExports> {\n const moduleExports: ModuleExports = {\n importYak: true,\n named: {},\n all: [],\n };\n\n // Track variable declarations for lookup\n const variableDeclarations: Record<string, babel.types.Expression> = {};\n\n // Track default export identifier if present\n let defaultIdentifier: string | null = null;\n\n try {\n const ast = parse(sourceContents, {\n sourceType: \"module\",\n plugins: [\"jsx\", \"typescript\"] as const,\n });\n\n traverse.default(ast, {\n // Track all variable declarations in the file\n VariableDeclarator({ node }) {\n if (node.id.type === \"Identifier\" && node.init) {\n variableDeclarations[node.id.name] = node.init;\n }\n },\n\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 moduleExports.named[specifier.exported.name] = {\n type: \"re-export\",\n from: node.source!.value,\n name: specifier.local.name,\n };\n }\n });\n } else if (node.declaration?.type === \"VariableDeclaration\") {\n node.declaration.declarations.forEach((declaration) => {\n if (declaration.id.type === \"Identifier\" && declaration.init) {\n const parsed = parseExportValueExpression(declaration.init);\n if (parsed) {\n moduleExports.named[declaration.id.name] = parsed;\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 moduleExports.named[specifier.exported.name] = {\n type: \"namespace-re-export\",\n from: source.value,\n };\n }\n });\n }\n },\n ExportDefaultDeclaration({ node }) {\n if (node.declaration.type === \"Identifier\") {\n // e.g. export default variableName;\n // Save the identifier name to look up later\n defaultIdentifier = node.declaration.name;\n } else if (\n node.declaration.type === \"FunctionDeclaration\" ||\n node.declaration.type === \"ClassDeclaration\"\n ) {\n // e.g. export default function() {...} or export default class {...}\n moduleExports.named[\"default\"] = {\n type: \"unsupported\",\n hint: node.declaration.type,\n };\n } else {\n // e.g. export default { ... } or export default \"value\"\n moduleExports.named[\"default\"] = parseExportValueExpression(\n node.declaration as babel.types.Expression,\n );\n }\n },\n ExportAllDeclaration({ node }) {\n moduleExports.all.push(node.source.value);\n },\n });\n // If we found a default export that's an identifier, look up its value\n if (defaultIdentifier && variableDeclarations[defaultIdentifier]) {\n moduleExports.named[\"default\"] = parseExportValueExpression(\n variableDeclarations[defaultIdentifier],\n );\n }\n\n return moduleExports;\n } catch (error) {\n throw new Error(`Error parsing exports: ${(error as Error).message}`);\n }\n}\n\n/**\n * Unpacks a TSAsExpression to its expression value\n */\nfunction unpackTSAsExpression(\n node: babel.types.TSAsExpression | babel.types.Expression,\n): babel.types.Expression {\n if (node.type === \"TSAsExpression\") {\n return unpackTSAsExpression(node.expression);\n }\n return node;\n}\n\nfunction parseExportValueExpression(\n node: babel.types.Expression,\n): ModuleExport {\n // ignores `as` casts so it doesn't interfere with the ast node type detection\n const expression = unpackTSAsExpression(node);\n if (\n expression.type === \"CallExpression\" ||\n expression.type === \"TaggedTemplateExpression\"\n ) {\n return { type: \"tag-template\" };\n } else if (\n expression.type === \"StringLiteral\" ||\n expression.type === \"NumericLiteral\"\n ) {\n return { type: \"constant\", value: expression.value };\n } else if (\n expression.type === \"UnaryExpression\" &&\n expression.operator === \"-\" &&\n expression.argument.type === \"NumericLiteral\"\n ) {\n return { type: \"constant\", value: -expression.argument.value };\n } else if (\n expression.type === \"TemplateLiteral\" &&\n expression.quasis.length === 1\n ) {\n return { type: \"constant\", value: expression.quasis[0].value.raw };\n } else if (expression.type === \"ObjectExpression\") {\n return { type: \"record\", value: parseObjectExpression(expression) };\n }\n return { type: \"unsupported\", hint: expression.type };\n}\n\nfunction parseObjectExpression(\n node: babel.types.ObjectExpression,\n): Record<string, ModuleExport> {\n let result: Record<string, ModuleExport> = {};\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 const parsed = parseExportValueExpression(\n property.value as babel.types.Expression,\n );\n if (parsed) {\n result[key] = parsed;\n }\n }\n }\n return result;\n}\n\nconst DIRNAME_POSIX_REGEX =\n /^((?:\\.(?![^\\/]))|(?:(?:\\/?|)(?:[\\s\\S]*?)))(?:\\/+?|)(?:(?:\\.{1,2}|[^\\/]+?|)(?:\\.[^.\\/]*|))(?:[\\/]*)$/;\nconst DIRNAME_WIN32_REGEX =\n /^((?:\\.(?![^\\\\]))|(?:(?:\\\\?|)(?:[\\s\\S]*?)))(?:\\\\+?|)(?:(?:\\.{1,2}|[^\\\\]+?|)(?:\\.[^.\\\\]*|))(?:[\\\\]*)$/;\n\n/**\n * Polyfill for `node:path` method dirname.\n * Keeps yak independent from node api (therefore executable in browser)\n */\nfunction dirname(path: string) {\n let dirname = DIRNAME_POSIX_REGEX.exec(path)?.[1];\n\n if (!dirname) {\n dirname = DIRNAME_WIN32_REGEX.exec(path)?.[1];\n }\n\n if (!dirname) {\n throw new Error(`Can't extract dirname from ${path}`);\n }\n\n return dirname;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0C;AAC1C,yBAA8B;AAC9B,uBAAwB;AACxB,qBAA4C;;;ACD5C,eAAsB,YACpB,SACA,YACuB;AACvB,MAAI;AACF,UAAM,QACJ,WAAW,SAAS,SAAS,KAC7B,WAAW,SAAS,UAAU,KAC9B,WAAW,SAAS,SAAS,KAC7B,WAAW,SAAS,UAAU;AAKhC,QAAI,SAAS,QAAQ,mBAAmB;AACtC,YAAM,YAAY,MAAM,QAAQ,kBAAkB,UAAU;AAC5D,YAAM,aAAa,qBAAqB,SAAS;AAEjD,aAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS,EAAE,WAAW,OAAO,OAAO,YAAY,KAAK,CAAC,EAAE;AAAA,QACxD,MAAM;AAAA,MACR;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AAAA,EACF;AAEA,QAAM,UAAU,OAAO,KACpB,MAAM,IAAI,EACV,KAAK,CAAC,SAAS,KAAK,SAAS,sBAAsB,CAAC;AAEvD,QAAM,4BAA4B,OAAO,KAAK;AAAA,IAC5C;AAAA,IACA,gCAAgC,OAAO,KAAK,QAAQ,EAAE,SAAS,QAAQ,CAAC;AAAA,EAC1E;AAEA,WAAS,gBAAgB,QAAQ;AACjC,SAAO,SAAS,MAAM,2BAA2B,OAAO,GAAG;AAC7D;AAEA,SAAS,gBAAgB,kBAAuBG,mBAA0B;AACxE,SAAO,CACL,MACA,YACA,UACA;AAAA;AAAA,QAGA,YAAAD,WAAa,MAAM;AAAA,MACjB,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,KAAK;AAAA,QACH,cAAc;AAAA,UACZ,SAAS,CAAC,CAACC,mBAAkB,gBAAgB,CAAC;AAAA,QAChD;AAAA,QACA,WAAW;AAAA,UACT,OAAO;AAAA,YACL,SAAS;AAAA,UACX;AAAA,QACF;AAAA,QACA,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,QAAQ;AAAA,UACN,UAAU;AAAA,UACV,QAAQ;AAAA,QACV;AAAA,QACA,qBAAqB;AAAA,MACvB;AAAA,MACA,QAAQ;AAAA,MACR,UAAU;AAAA,IACZ,CAAC;AAAA;AACL;","names":["exports","resolveCrossFileConstant","exports","traverse","result","modulePath","code","swcTransform","yakSwcPluginPath"]}
@@ -1,11 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // loaders/webpack-loader.ts
31
+ var webpack_loader_exports = {};
32
+ __export(webpack_loader_exports, {
33
+ default: () => cssExtractLoader
34
+ });
35
+ module.exports = __toCommonJS(webpack_loader_exports);
36
+
1
37
  // loaders/lib/debugLogger.ts
2
- import { relative } from "path";
38
+ var import_path = require("path");
3
39
  function createDebugLogger(loaderContext, debugOptions) {
4
40
  if (!debugOptions) {
5
41
  return () => {
6
42
  };
7
43
  }
8
- const currentPath = loaderContext._compiler ? relative(loaderContext._compiler.context, loaderContext.resourcePath) : loaderContext.resourcePath;
44
+ const currentPath = loaderContext._compiler ? (0, import_path.relative)(loaderContext._compiler.context, loaderContext.resourcePath) : loaderContext.resourcePath;
9
45
  return (messageType, message) => {
10
46
  const pathWithExtension = messageType !== "ts" ? currentPath + `.${messageType}` : currentPath;
11
47
  if (debugOptions === true || new RegExp(debugOptions).test(pathWithExtension)) {
@@ -41,8 +77,8 @@ function extractCss(code, transpilationMode) {
41
77
  }
42
78
 
43
79
  // loaders/lib/resolveCrossFileSelectors.ts
44
- import { parse } from "@babel/parser";
45
- import traverse from "@babel/traverse";
80
+ var import_parser = require("@babel/parser");
81
+ var import_traverse = __toESM(require("@babel/traverse"), 1);
46
82
 
47
83
  // cross-file-resolver/parseModule.ts
48
84
  async function parseModule(context, modulePath) {
@@ -77,12 +113,12 @@ async function parseModule(context, modulePath) {
77
113
  }
78
114
  }
79
115
  async function uncachedParseModule(context, modulePath) {
80
- const exports = await context.extractExports(modulePath);
81
- if (!exports.importYak) {
116
+ const exports2 = await context.extractExports(modulePath);
117
+ if (!exports2.importYak) {
82
118
  return {
83
119
  type: "regular",
84
120
  path: modulePath,
85
- exports
121
+ exports: exports2
86
122
  };
87
123
  }
88
124
  const transformed = await context.getTransformed(modulePath);
@@ -95,7 +131,7 @@ async function uncachedParseModule(context, modulePath) {
95
131
  type: "regular",
96
132
  path: modulePath,
97
133
  js: transformed,
98
- exports,
134
+ exports: exports2,
99
135
  styledComponents,
100
136
  mixins
101
137
  };
@@ -298,12 +334,12 @@ async function resolveModule(context, filePath) {
298
334
  }
299
335
  async function uncachedResolveModule(context, filePath) {
300
336
  const parsedModule = await context.parse(filePath);
301
- const exports = parsedModule.exports;
337
+ const exports2 = parsedModule.exports;
302
338
  if (parsedModule.type !== "regular") {
303
339
  return {
304
340
  resolved: {
305
341
  path: parsedModule.path,
306
- exports
342
+ exports: exports2
307
343
  },
308
344
  dependencies: []
309
345
  };
@@ -312,15 +348,15 @@ async function uncachedResolveModule(context, filePath) {
312
348
  if (parsedModule.styledComponents) {
313
349
  Object.values(parsedModule.styledComponents).map((styledComponent) => {
314
350
  if (styledComponent.nameParts.length === 1) {
315
- exports.named[styledComponent.nameParts[0]] = {
351
+ exports2.named[styledComponent.nameParts[0]] = {
316
352
  type: "styled-component",
317
353
  className: styledComponent.value
318
354
  };
319
355
  } else {
320
- let exportEntry = exports.named[styledComponent.nameParts[0]];
356
+ let exportEntry = exports2.named[styledComponent.nameParts[0]];
321
357
  if (!exportEntry) {
322
358
  exportEntry = { type: "record", value: {} };
323
- exports.named[styledComponent.nameParts[0]] = exportEntry;
359
+ exports2.named[styledComponent.nameParts[0]] = exportEntry;
324
360
  } else if (exportEntry.type !== "record") {
325
361
  throw new CauseError(`Error parsing file "${parsedModule.path}"`, {
326
362
  cause: `"${styledComponent.nameParts[0]}" is not a record`
@@ -358,15 +394,15 @@ async function uncachedResolveModule(context, filePath) {
358
394
  dependencies.add(dep);
359
395
  }
360
396
  if (mixin.nameParts.length === 1) {
361
- exports.named[mixin.nameParts[0]] = {
397
+ exports2.named[mixin.nameParts[0]] = {
362
398
  type: "mixin",
363
399
  value: resolved
364
400
  };
365
401
  } else {
366
- let exportEntry = exports.named[mixin.nameParts[0]];
402
+ let exportEntry = exports2.named[mixin.nameParts[0]];
367
403
  if (!exportEntry) {
368
404
  exportEntry = { type: "record", value: {} };
369
- exports.named[mixin.nameParts[0]] = exportEntry;
405
+ exports2.named[mixin.nameParts[0]] = exportEntry;
370
406
  } else if (exportEntry.type !== "record") {
371
407
  throw new CauseError(`Error parsing file "${parsedModule.path}"`, {
372
408
  cause: `"${mixin.nameParts[0]}" is not a record`
@@ -399,7 +435,7 @@ async function uncachedResolveModule(context, filePath) {
399
435
  return {
400
436
  resolved: {
401
437
  path: parsedModule.path,
402
- exports
438
+ exports: exports2
403
439
  },
404
440
  dependencies: Array.from(dependencies)
405
441
  };
@@ -712,11 +748,11 @@ async function parseExports(sourceContents) {
712
748
  const variableDeclarations = {};
713
749
  let defaultIdentifier = null;
714
750
  try {
715
- const ast = parse(sourceContents, {
751
+ const ast = (0, import_parser.parse)(sourceContents, {
716
752
  sourceType: "module",
717
753
  plugins: ["jsx", "typescript"]
718
754
  });
719
- traverse.default(ast, {
755
+ import_traverse.default.default(ast, {
720
756
  // Track all variable declarations in the file
721
757
  VariableDeclarator({ node }) {
722
758
  if (node.id.type === "Identifier" && node.init) {
@@ -858,7 +894,4 @@ async function cssExtractLoader(_code, sourceMap) {
858
894
  }, callback);
859
895
  });
860
896
  }
861
- export {
862
- cssExtractLoader as default
863
- };
864
- //# sourceMappingURL=webpack-loader.js.map
897
+ //# sourceMappingURL=webpack-loader.cjs.map