@yak/react 0.0.0-stage → 10.0.0-rc.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.
Files changed (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -2
  3. package/dist/context/baseContext.cjs +9 -0
  4. package/dist/context/baseContext.cjs.map +1 -0
  5. package/dist/context/baseContext.d.cts +6 -0
  6. package/dist/context/baseContext.d.ts +6 -0
  7. package/dist/context/baseContext.js +8 -0
  8. package/dist/context/baseContext.js.map +1 -0
  9. package/dist/context/index.cjs +45 -0
  10. package/dist/context/index.cjs.map +1 -0
  11. package/dist/context/index.d.cts +21 -0
  12. package/dist/context/index.d.ts +21 -0
  13. package/dist/context/index.js +15 -0
  14. package/dist/context/index.js.map +1 -0
  15. package/dist/context/index.server.cjs +47 -0
  16. package/dist/context/index.server.cjs.map +1 -0
  17. package/dist/context/index.server.d.cts +10 -0
  18. package/dist/context/index.server.d.ts +10 -0
  19. package/dist/context/index.server.js +17 -0
  20. package/dist/context/index.server.js.map +1 -0
  21. package/dist/cross-file-resolver/index.d.ts +199 -0
  22. package/dist/cross-file-resolver/index.js +535 -0
  23. package/dist/cross-file-resolver/index.js.map +1 -0
  24. package/dist/index.cjs +2 -0
  25. package/dist/index.cjs.map +1 -0
  26. package/dist/index.d.cts +320 -0
  27. package/dist/index.d.ts +320 -0
  28. package/dist/index.js +2 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/internal.cjs +544 -0
  31. package/dist/internal.cjs.map +1 -0
  32. package/dist/internal.d.cts +452 -0
  33. package/dist/internal.d.ts +452 -0
  34. package/dist/internal.js +363 -0
  35. package/dist/internal.js.map +1 -0
  36. package/dist/isolated-source-eval/index.d.ts +30 -0
  37. package/dist/isolated-source-eval/index.js +317 -0
  38. package/dist/isolated-source-eval/index.js.map +1 -0
  39. package/dist/isolated-source-eval/worker.js +59 -0
  40. package/dist/isolated-source-eval/worker.js.map +1 -0
  41. package/dist/jsx-dev-runtime.cjs +2 -0
  42. package/dist/jsx-dev-runtime.cjs.map +1 -0
  43. package/dist/jsx-dev-runtime.d.cts +7 -0
  44. package/dist/jsx-dev-runtime.d.ts +7 -0
  45. package/dist/jsx-dev-runtime.js +2 -0
  46. package/dist/jsx-dev-runtime.js.map +1 -0
  47. package/dist/jsx-runtime.cjs +2 -0
  48. package/dist/jsx-runtime.cjs.map +1 -0
  49. package/dist/jsx-runtime.d.cts +38 -0
  50. package/dist/jsx-runtime.d.ts +38 -0
  51. package/dist/jsx-runtime.js +2 -0
  52. package/dist/jsx-runtime.js.map +1 -0
  53. package/dist/loaders/turbo-loader.cjs +803 -0
  54. package/dist/loaders/turbo-loader.cjs.map +1 -0
  55. package/dist/loaders/turbo-loader.d.cts +15 -0
  56. package/dist/loaders/vite-plugin.d.ts +111 -0
  57. package/dist/loaders/vite-plugin.js +878 -0
  58. package/dist/loaders/vite-plugin.js.map +1 -0
  59. package/dist/loaders/webpack-loader.cjs +697 -0
  60. package/dist/loaders/webpack-loader.cjs.map +1 -0
  61. package/dist/loaders/webpack-loader.d.cts +12 -0
  62. package/dist/rsbuild/index.d.ts +29 -0
  63. package/dist/rsbuild/index.js +52 -0
  64. package/dist/rsbuild/index.js.map +1 -0
  65. package/dist/static/chunk-DK3Fl9T5.js +1 -0
  66. package/dist/static/index.cjs +2 -0
  67. package/dist/static/index.cjs.map +1 -0
  68. package/dist/static/index.d.cts +28 -0
  69. package/dist/static/index.d.ts +28 -0
  70. package/dist/static/index.js +2 -0
  71. package/dist/static/index.js.map +1 -0
  72. package/dist/withYak/index.cjs +208 -0
  73. package/dist/withYak/index.cjs.map +1 -0
  74. package/dist/withYak/index.d.cts +121 -0
  75. package/dist/withYak/index.d.ts +121 -0
  76. package/dist/withYak/index.js +177 -0
  77. package/dist/withYak/index.js.map +1 -0
  78. package/loaders/lib/resolveCrossFileSelectors.ts +162 -0
  79. package/loaders/turbo-evaluator.ts +134 -0
  80. package/loaders/turbo-loader.ts +180 -0
  81. package/loaders/vite-plugin.ts +28 -0
  82. package/loaders/webpack-loader.ts +44 -0
  83. package/package.json +214 -3
  84. package/rsbuild/index.ts +92 -0
  85. package/runtime/__tests__/atoms.test.tsx +48 -0
  86. package/runtime/__tests__/attrs.test.tsx +490 -0
  87. package/runtime/__tests__/cssLiteral.test.tsx +503 -0
  88. package/runtime/__tests__/cssProp.test.tsx +392 -0
  89. package/runtime/__tests__/cssPropTest.tsx +227 -0
  90. package/runtime/__tests__/foldedJsxParity.test.tsx +117 -0
  91. package/runtime/__tests__/styled.test.tsx +653 -0
  92. package/runtime/__tests__/tsconfig.json +18 -0
  93. package/runtime/__tests__/typeTest.tsx +374 -0
  94. package/runtime/atoms.tsx +36 -0
  95. package/runtime/context/README.md +84 -0
  96. package/runtime/context/baseContext.tsx +5 -0
  97. package/runtime/context/index.server.tsx +22 -0
  98. package/runtime/context/index.tsx +36 -0
  99. package/runtime/cssLiteral.tsx +214 -0
  100. package/runtime/globalStyle.tsx +54 -0
  101. package/runtime/index.ts +37 -0
  102. package/runtime/internal.ts +42 -0
  103. package/runtime/internals/mergeClassNames.ts +23 -0
  104. package/runtime/internals/mergeCssProp.ts +69 -0
  105. package/runtime/internals/propMarkers.ts +20 -0
  106. package/runtime/internals/unitPostFix.ts +34 -0
  107. package/runtime/jsx-dev-runtime.ts +6 -0
  108. package/runtime/jsx-runtime.ts +48 -0
  109. package/runtime/keyframes.tsx +30 -0
  110. package/runtime/mocks/cssLiteral.ts +74 -0
  111. package/runtime/mocks/globalStyle.ts +14 -0
  112. package/runtime/mocks/keyframes.ts +29 -0
  113. package/runtime/mocks/styled.ts +8 -0
  114. package/runtime/publicStyledApi.ts +159 -0
  115. package/runtime/styled.tsx +372 -0
  116. package/runtime/styledDom.tsx +139 -0
  117. package/withYak/allow-global-css.ts +94 -0
  118. package/withYak/index.ts +282 -0
@@ -0,0 +1,878 @@
1
+ import { createRequire } from "node:module";
2
+ import { transform } from "@swc/core";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import path, { dirname, relative, resolve } from "node:path";
5
+ import { isFileLoadingAllowed, normalizePath } from "vite";
6
+ import { createEvaluator } from "../isolated-source-eval/index.js";
7
+ import { relative as relative$1 } from "path";
8
+ import { parse } from "@babel/parser";
9
+
10
+ //#region ../yak-internals/cross-file-resolver/parseModule.ts
11
+ async function parseModule(context, modulePath) {
12
+ try {
13
+ if ((modulePath.endsWith(".yak.ts") || modulePath.endsWith(".yak.tsx") || modulePath.endsWith(".yak.js") || modulePath.endsWith(".yak.jsx")) && context.evaluateYakModule) return {
14
+ type: "yak",
15
+ exports: {
16
+ importYak: false,
17
+ named: objectToModuleExport(await context.evaluateYakModule(modulePath)),
18
+ all: []
19
+ },
20
+ path: modulePath
21
+ };
22
+ if (context.cache?.parse === void 0) return await uncachedParseModule(context, modulePath);
23
+ const cached = context.cache.parse.get(modulePath);
24
+ if (cached === void 0) {
25
+ const parsedModule = await uncachedParseModule(context, modulePath);
26
+ context.cache.parse.set(modulePath, parsedModule);
27
+ if (context.cache.parse.addDependency) context.cache.parse.addDependency(modulePath, modulePath);
28
+ return parsedModule;
29
+ }
30
+ return cached;
31
+ } catch (error) {
32
+ const causeMessage = error instanceof Error ? error.message : String(error);
33
+ throw new Error(`Error parsing file "${modulePath}"\n Caused by: ${causeMessage}`);
34
+ }
35
+ }
36
+ async function uncachedParseModule(context, modulePath) {
37
+ const exports = await context.extractExports(modulePath);
38
+ if (!exports.importYak) return {
39
+ type: "regular",
40
+ path: modulePath,
41
+ exports
42
+ };
43
+ const transformed = await context.getTransformed(modulePath);
44
+ const mixins = parseMixins(transformed.code);
45
+ return {
46
+ type: "regular",
47
+ path: modulePath,
48
+ js: transformed,
49
+ exports,
50
+ styledComponents: parseStyledComponents(transformed.code, context.transpilationMode),
51
+ mixins
52
+ };
53
+ }
54
+ function parseMixins(sourceContents) {
55
+ const mixinParts = sourceContents.split("/*YAK EXPORTED MIXIN:");
56
+ let mixins = {};
57
+ for (let i = 1; i < mixinParts.length; i++) {
58
+ const [comment] = mixinParts[i].split("*/", 1);
59
+ const position = comment.indexOf("\n");
60
+ const name = comment.slice(0, position);
61
+ mixins[name] = {
62
+ type: "mixin",
63
+ value: comment.slice(position + 1),
64
+ nameParts: name.split(":").map((part) => decodeURIComponent(part))
65
+ };
66
+ }
67
+ return mixins;
68
+ }
69
+ function parseStyledComponents(sourceContents, transpilationMode) {
70
+ const styledParts = sourceContents.split("/*YAK EXPORTED STYLED:");
71
+ let styledComponents = {};
72
+ for (let i = 1; i < styledParts.length; i++) {
73
+ const [comment] = styledParts[i].split("*/", 1);
74
+ const [componentName, className] = comment.split(":");
75
+ styledComponents[componentName] = {
76
+ type: "styled-component",
77
+ nameParts: componentName.split("."),
78
+ value: transpilationMode === "Css" ? `.${className}` : `:global(.${className})`
79
+ };
80
+ }
81
+ return styledComponents;
82
+ }
83
+ function objectToModuleExport(object) {
84
+ return Object.fromEntries(Object.entries(object).map(([key, value]) => {
85
+ if (typeof value === "string" || typeof value === "number") return [key, {
86
+ type: "constant",
87
+ value
88
+ }];
89
+ else if (value && (typeof value === "object" || Array.isArray(value))) return [key, {
90
+ type: "record",
91
+ value: objectToModuleExport(value)
92
+ }];
93
+ else return [key, {
94
+ type: "unsupported",
95
+ hint: String(value)
96
+ }];
97
+ }));
98
+ }
99
+
100
+ //#endregion
101
+ //#region ../yak-internals/cross-file-resolver/Errors.ts
102
+ var CauseError = class CauseError extends Error {
103
+ constructor(message, options) {
104
+ super(`${message}${options?.cause ? `\n Caused by: ${typeof options.cause === "object" && options.cause !== null && "message" in options.cause ? options.cause.message : String(options.cause)}` : ""}`);
105
+ if (options?.cause instanceof CauseError && options.cause.circular) this.circular = true;
106
+ }
107
+ };
108
+ var ResolveError = class extends CauseError {};
109
+ var UnsupportedExportError = class extends ResolveError {};
110
+ var CircularDependencyError = class extends CauseError {
111
+ constructor(message, options) {
112
+ super(message, options);
113
+ this.circular = true;
114
+ }
115
+ };
116
+
117
+ //#endregion
118
+ //#region ../yak-internals/cross-file-resolver/resolveCrossFileConstant.ts
119
+ const yakCssImportRegex = /--yak-css-import:\s*url\("([^"]+)",?(|mixin|selector)\)(;?)/g;
120
+ async function resolveCrossFileConstant(context, filePath, css) {
121
+ const resolveCrossFileConstant = context.cache?.resolveCrossFileConstant;
122
+ if (resolveCrossFileConstant === void 0) return uncachedResolveCrossFileConstant(context, filePath, css);
123
+ const cacheKey = await sha1(filePath + ":" + css);
124
+ const cached = resolveCrossFileConstant.get(cacheKey);
125
+ if (cached === void 0) {
126
+ const resolvedCrossFilConstantPromise = uncachedResolveCrossFileConstant(context, filePath, css);
127
+ resolveCrossFileConstant.set(cacheKey, resolvedCrossFilConstantPromise);
128
+ if (resolveCrossFileConstant.addDependency) {
129
+ resolveCrossFileConstant.addDependency(cacheKey, filePath);
130
+ resolvedCrossFilConstantPromise.then((value) => {
131
+ for (const dep of value.dependencies) resolveCrossFileConstant.addDependency(cacheKey, dep);
132
+ });
133
+ }
134
+ return resolvedCrossFilConstantPromise;
135
+ }
136
+ return cached;
137
+ }
138
+ async function uncachedResolveCrossFileConstant(context, filePath, css) {
139
+ const yakImports = await parseYakCssImport(context, filePath, css);
140
+ if (yakImports.length === 0) return {
141
+ resolved: css,
142
+ dependencies: []
143
+ };
144
+ try {
145
+ const dependencies = /* @__PURE__ */ new Set();
146
+ const resolvedValues = await Promise.all(yakImports.map(async ({ moduleSpecifier, specifier }) => {
147
+ const { resolved: resolvedModule } = await resolveModule(context, moduleSpecifier);
148
+ const resolvedValue = await resolveModuleSpecifierRecursively(context, resolvedModule, specifier);
149
+ for (const dependency of resolvedValue.from) dependencies.add(dependency);
150
+ return resolvedValue;
151
+ }));
152
+ let result = css;
153
+ for (let i = yakImports.length - 1; i >= 0; i--) {
154
+ const { position, size, importKind, specifier, semicolon } = yakImports[i];
155
+ const resolved = resolvedValues[i];
156
+ let replacement;
157
+ if (resolved.type === "unresolved-tag") replacement = importKind === "mixin" ? "" : "undefined";
158
+ else {
159
+ if (importKind === "selector") {
160
+ if (resolved.type !== "styled-component" && resolved.type !== "constant") throw new Error(`Found "${resolved.type}" but expected a selector - did you forget a semicolon after "${specifier.join(".")}"?`);
161
+ }
162
+ replacement = resolved.type === "styled-component" ? resolved.value : resolved.value + (["}", ";"].includes(String(resolved.value).trimEnd().slice(-1)) ? "" : semicolon);
163
+ }
164
+ result = result.slice(0, position) + String(replacement) + result.slice(position + size);
165
+ }
166
+ return {
167
+ resolved: result,
168
+ dependencies: Array.from(dependencies)
169
+ };
170
+ } catch (error) {
171
+ throw new CauseError(`Error while resolving cross-file selectors in file "${filePath}"`, { cause: error });
172
+ }
173
+ }
174
+ async function parseYakCssImport(context, filePath, css) {
175
+ const yakImports = [];
176
+ for (const match of css.matchAll(yakCssImportRegex)) {
177
+ const [fullMatch, encodedArguments, importKind, semicolon] = match;
178
+ const [moduleSpecifier, ...specifier] = encodedArguments.split(":").map((entry) => decodeURIComponent(entry));
179
+ yakImports.push({
180
+ encodedArguments,
181
+ moduleSpecifier: await context.resolve(moduleSpecifier, filePath),
182
+ specifier,
183
+ importKind,
184
+ semicolon,
185
+ position: match.index,
186
+ size: fullMatch.length
187
+ });
188
+ }
189
+ return yakImports;
190
+ }
191
+ async function resolveModule(context, filePath) {
192
+ if (context.cache?.resolve === void 0) return uncachedResolveModule(context, filePath);
193
+ const cached = context.cache.resolve.get(filePath);
194
+ if (cached === void 0) {
195
+ const resolvedPromise = uncachedResolveModule(context, filePath);
196
+ context.cache.resolve.set(filePath, resolvedPromise);
197
+ if (context.cache.resolve.addDependency) {
198
+ context.cache.resolve.addDependency(filePath, filePath);
199
+ resolvedPromise.then((value) => {
200
+ for (const dep of value.dependencies) context.cache.resolve.addDependency(filePath, dep);
201
+ });
202
+ }
203
+ return resolvedPromise;
204
+ }
205
+ return cached;
206
+ }
207
+ async function uncachedResolveModule(context, filePath) {
208
+ const parsedModule = await context.parse(filePath);
209
+ const exports = parsedModule.exports;
210
+ if (parsedModule.type !== "regular") return {
211
+ resolved: {
212
+ path: parsedModule.path,
213
+ exports
214
+ },
215
+ dependencies: []
216
+ };
217
+ const dependencies = /* @__PURE__ */ new Set();
218
+ if (parsedModule.styledComponents) Object.values(parsedModule.styledComponents).map((styledComponent) => {
219
+ if (styledComponent.nameParts.length === 1) exports.named[styledComponent.nameParts[0]] = {
220
+ type: "styled-component",
221
+ className: styledComponent.value
222
+ };
223
+ else {
224
+ let exportEntry = exports.named[styledComponent.nameParts[0]];
225
+ if (!exportEntry) {
226
+ exportEntry = {
227
+ type: "record",
228
+ value: {}
229
+ };
230
+ exports.named[styledComponent.nameParts[0]] = exportEntry;
231
+ } else if (exportEntry.type !== "record") throw new CauseError(`Error parsing file "${parsedModule.path}"`, { cause: `"${styledComponent.nameParts[0]}" is not a record` });
232
+ let current = exportEntry.value;
233
+ for (let i = 1; i < styledComponent.nameParts.length - 1; i++) {
234
+ let next = current[styledComponent.nameParts[i]];
235
+ if (!next) {
236
+ next = {
237
+ type: "record",
238
+ value: {}
239
+ };
240
+ current[styledComponent.nameParts[i]] = next;
241
+ } else if (next.type !== "record") throw new CauseError(`Error parsing file "${parsedModule.path}"`, { cause: `"${styledComponent.nameParts.slice(0, i + 1).join(".")}" is not a record` });
242
+ current = next.value;
243
+ }
244
+ current[styledComponent.nameParts[styledComponent.nameParts.length - 1]] = {
245
+ type: "styled-component",
246
+ className: styledComponent.value
247
+ };
248
+ }
249
+ });
250
+ if (parsedModule.mixins) await Promise.all(Object.values(parsedModule.mixins).map(async (mixin) => {
251
+ const { resolved, dependencies: deps } = await resolveCrossFileConstant(context, parsedModule.path, mixin.value);
252
+ for (const dep of deps) dependencies.add(dep);
253
+ if (mixin.nameParts.length === 1) exports.named[mixin.nameParts[0]] = {
254
+ type: "mixin",
255
+ value: resolved
256
+ };
257
+ else {
258
+ let exportEntry = exports.named[mixin.nameParts[0]];
259
+ if (!exportEntry) {
260
+ exportEntry = {
261
+ type: "record",
262
+ value: {}
263
+ };
264
+ exports.named[mixin.nameParts[0]] = exportEntry;
265
+ } else if (exportEntry.type !== "record") throw new CauseError(`Error parsing file "${parsedModule.path}"`, { cause: `"${mixin.nameParts[0]}" is not a record` });
266
+ let current = exportEntry.value;
267
+ for (let i = 1; i < mixin.nameParts.length - 1; i++) {
268
+ let next = current[mixin.nameParts[i]];
269
+ if (!next) {
270
+ next = {
271
+ type: "record",
272
+ value: {}
273
+ };
274
+ current[mixin.nameParts[i]] = next;
275
+ } else if (next.type !== "record") throw new CauseError(`Error parsing file "${parsedModule.path}"`, { cause: `"${mixin.nameParts.slice(0, i + 1).join(".")}" is not a record` });
276
+ current = next.value;
277
+ }
278
+ current[mixin.nameParts[mixin.nameParts.length - 1]] = {
279
+ type: "mixin",
280
+ value: resolved
281
+ };
282
+ }
283
+ }));
284
+ return {
285
+ resolved: {
286
+ path: parsedModule.path,
287
+ exports
288
+ },
289
+ dependencies: Array.from(dependencies)
290
+ };
291
+ }
292
+ async function resolveModuleSpecifierRecursively(context, resolvedModule, specifiers, seen = /* @__PURE__ */ new Set()) {
293
+ const exportName = specifiers[0];
294
+ const exportValue = resolvedModule.exports.named[exportName];
295
+ if (exportValue !== void 0) {
296
+ if (seen.has(resolvedModule.path + ":" + exportName)) throw new CircularDependencyError(`Unable to resolve "${specifiers.join(".")}" in module "${resolvedModule.path}"`, { cause: "Circular dependency detected" });
297
+ seen.add(resolvedModule.path + ":" + exportName);
298
+ return resolveModuleExport(context, resolvedModule.path, exportValue, specifiers, seen);
299
+ }
300
+ let i = 1;
301
+ for (const from of resolvedModule.exports.all) {
302
+ if (context.exportAllLimit && i++ > context.exportAllLimit) throw new ResolveError(`Unable to resolve "${specifiers.join(".")}" in module "${resolvedModule.path}"`, { cause: `More than ${context.exportAllLimit} star exports are not supported for performance reasons` });
303
+ try {
304
+ const resolved = await resolveModuleExport(context, resolvedModule.path, {
305
+ type: "re-export",
306
+ from,
307
+ name: exportName
308
+ }, specifiers, seen);
309
+ if (seen.has(resolvedModule.path + ":*")) throw new CircularDependencyError(`Unable to resolve "${specifiers.join(".")}" in module "${resolvedModule.path}"`, { cause: "Circular dependency detected" });
310
+ seen.add(resolvedModule.path + ":*");
311
+ return resolved;
312
+ } catch (error) {
313
+ if (!(error instanceof ResolveError)) throw error;
314
+ if (error.circular) throw error;
315
+ }
316
+ }
317
+ throw new ResolveError(`Unable to resolve "${specifiers.join(".")}"`, { cause: `no matching export found in module "${resolvedModule.path}"` });
318
+ }
319
+ async function resolveModuleExport(context, filePath, moduleExport, specifiers, seen) {
320
+ const failureMessage = `Unable to resolve "${specifiers.join(".")}" in module "${filePath}"`;
321
+ try {
322
+ switch (moduleExport.type) {
323
+ case "re-export": {
324
+ const { resolved: reExportedModule } = await resolveModule(context, await context.resolve(moduleExport.from, filePath));
325
+ const resolved = await resolveModuleSpecifierRecursively(context, reExportedModule, [moduleExport.name, ...specifiers.slice(1)], seen);
326
+ if (resolved) resolved.from.push(filePath);
327
+ return resolved;
328
+ }
329
+ case "namespace-re-export": {
330
+ const { resolved: reExportedModule } = await resolveModule(context, await context.resolve(moduleExport.from, filePath));
331
+ const resolved = await resolveModuleSpecifierRecursively(context, reExportedModule, specifiers.slice(1), seen);
332
+ if (resolved) resolved.from.push(filePath);
333
+ return resolved;
334
+ }
335
+ case "styled-component": return {
336
+ type: "styled-component",
337
+ from: [filePath],
338
+ source: filePath,
339
+ name: specifiers[specifiers.length - 1],
340
+ value: moduleExport.className
341
+ };
342
+ case "tag-template": return {
343
+ type: "unresolved-tag",
344
+ from: [filePath],
345
+ source: filePath,
346
+ name: specifiers[specifiers.length - 1]
347
+ };
348
+ case "constant": return {
349
+ type: "constant",
350
+ from: [filePath],
351
+ source: filePath,
352
+ value: moduleExport.value
353
+ };
354
+ case "record": return resolveModuleExport(context, filePath, resolveSpecifierInRecord(moduleExport, specifiers[0], specifiers.slice(1)), specifiers, seen);
355
+ case "mixin": return {
356
+ type: "mixin",
357
+ from: [filePath],
358
+ source: filePath,
359
+ value: moduleExport.value
360
+ };
361
+ case "unsupported": throw new UnsupportedExportError(failureMessage, { cause: explainUnsupported(filePath, specifiers.join("."), moduleExport.hint, moduleExport.source) });
362
+ }
363
+ } catch (error) {
364
+ if (error instanceof UnsupportedExportError) throw error;
365
+ throw new ResolveError(failureMessage, { cause: error });
366
+ }
367
+ }
368
+ function explainUnsupported(filePath, specifier, hint, source) {
369
+ const isYakFile = /\.yak\.(?:ts|tsx|js|jsx)$/.test(filePath);
370
+ const docs = "https://yak.js.org/docs/migration-from-styled-components#move-some-code-to-yak-files";
371
+ const snippet = source ? renderSourceSnippet(filePath, source, hint ?? "") : void 0;
372
+ const lines = [];
373
+ if (isYakFile) {
374
+ const got = hint ? ` (got \`${hint}\`)` : "";
375
+ lines.push(`\`${specifier}\` evaluated to a value that cannot be inlined into CSS${got}.`);
376
+ if (snippet) lines.push(snippet);
377
+ lines.push(` help: replace it with a string, number, or plain object/array of those`, ` see: ${docs}`);
378
+ return lines.join("\n");
379
+ }
380
+ const got = hint ? ` (got a ${hint})` : "";
381
+ lines.push(`\`${specifier}\` is not a string or number literal${got}.`);
382
+ if (snippet) lines.push(snippet);
383
+ lines.push(` help: rename "${filePath}" to "${suggestYakFileName(filePath)}" so its exports run at build time`, ` (or replace \`${specifier}\` with a literal value)`, ` see: ${docs}`);
384
+ return lines.join("\n");
385
+ }
386
+ function suggestYakFileName(filePath) {
387
+ const match = filePath.match(/^(.*)\.(ts|tsx|js|jsx)$/);
388
+ if (!match) return filePath;
389
+ return `${match[1]}.yak.${match[2]}`;
390
+ }
391
+ function renderSourceSnippet(filePath, source, label) {
392
+ const startLine = source.start.line;
393
+ const startCol = source.start.column;
394
+ const caretLen = source.end.line === startLine ? Math.max(1, source.end.column - startCol) : Math.max(1, source.lineText.length - startCol);
395
+ const lineNumStr = String(startLine);
396
+ const gutterPad = " ".repeat(lineNumStr.length);
397
+ return [
398
+ ` --> ${filePath}:${startLine}:${startCol + 1}`,
399
+ ` ${gutterPad} |`,
400
+ ` ${lineNumStr} | ${source.lineText}`,
401
+ ` ${gutterPad} | ${" ".repeat(startCol)}${"^".repeat(caretLen)} ${label}`
402
+ ].join("\n");
403
+ }
404
+ function resolveSpecifierInRecord(record, name, specifiers) {
405
+ if (specifiers.length === 0) throw new ResolveError("did not expect an object");
406
+ let depth = 0;
407
+ let current = record;
408
+ while (current && current.type === "record" && depth < specifiers.length) {
409
+ current = current.value[specifiers[depth]];
410
+ depth += 1;
411
+ }
412
+ if (current === void 0 || depth !== specifiers.length) throw new ResolveError(`Unable to resolve "${specifiers.join(".")}" in object/array "${name}"`, { cause: "path not found" });
413
+ if (current.type === "constant" || current.type === "styled-component" || current.type === "mixin") return current;
414
+ if (current.type === "record" && "__yak" in current.value && current.value.__yak.type === "constant") return {
415
+ type: "mixin",
416
+ value: String(current.value.__yak.value)
417
+ };
418
+ throw new ResolveError(`Unable to resolve "${specifiers.join(".")}" in object/array "${name}"`, { cause: "only string and numbers are supported" });
419
+ }
420
+ async function sha1(message) {
421
+ const resultBuffer = await globalThis.crypto.subtle.digest("SHA-1", new TextEncoder().encode(message));
422
+ return Array.from(new Uint8Array(resultBuffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
423
+ }
424
+
425
+ //#endregion
426
+ //#region ../yak-internals/config.ts
427
+ function resolveYakContext(contextPath, cwd) {
428
+ const yakContext = contextPath ? path.resolve(cwd, contextPath) : path.resolve(cwd, "yak.context");
429
+ const extensions = [
430
+ "",
431
+ ".ts",
432
+ ".tsx",
433
+ ".js",
434
+ ".jsx"
435
+ ];
436
+ for (const extension in extensions) {
437
+ const fileName = yakContext + extensions[extension];
438
+ if (existsSync(fileName)) return fileName;
439
+ }
440
+ if (contextPath) throw new Error(`Could not find yak context file at ${yakContext}`);
441
+ }
442
+
443
+ //#endregion
444
+ //#region ../yak-internals/loaders/lib/debugLogger.ts
445
+ function createDebugLogger(debugOptions, rootPath) {
446
+ if (!debugOptions) return () => {};
447
+ throwOnDeprecatedDebugOptions(debugOptions);
448
+ const pattern = debugOptions === true ? void 0 : debugOptions.pattern;
449
+ const typesArray = debugOptions === true ? void 0 : debugOptions.types;
450
+ let compiledPattern = null;
451
+ if (pattern) try {
452
+ compiledPattern = new RegExp(pattern);
453
+ } catch (error) {
454
+ throw new Error(`Invalid debug pattern: "${pattern}" is not a valid regular expression. ${error instanceof Error ? error.message : ""}`);
455
+ }
456
+ const types = typesArray ? new Set(typesArray) : null;
457
+ return (messageType, message, filePath) => {
458
+ if (types && !types.has(messageType)) return;
459
+ const relativePath = relative$1(rootPath, filePath);
460
+ if (!compiledPattern || compiledPattern.test(relativePath)) console.log("🐮 Yak", `[${messageType}]`, relativePath, "\n\n", message);
461
+ };
462
+ }
463
+ function throwOnDeprecatedDebugOptions(debugOptions) {
464
+ if (typeof debugOptions === "string") {
465
+ const suggestion = suggestTypesForExtensionPattern(debugOptions) ?? `debug: { pattern: "${debugOptions}" }`;
466
+ throw new Error(`The debug option no longer accepts a string. Please update your config:\n Before: debug: "${debugOptions}"\n After: ${suggestion}`);
467
+ }
468
+ if (typeof debugOptions === "object" && "filter" in debugOptions) throw new Error("The debug option no longer accepts { filter, type }. Please update your config:\n Before: debug: { filter: ..., type: \"...\" }\n After: debug: { pattern: \"...\", types: [\"ts\", \"css\", \"css-resolved\"] }");
469
+ if (typeof debugOptions === "object" && debugOptions.pattern) {
470
+ const suggestion = suggestTypesForExtensionPattern(debugOptions.pattern);
471
+ if (suggestion) throw new Error(`The debug pattern "${debugOptions.pattern}" looks like it's filtering by output type using the old file extension convention.\nThe pattern now only matches file paths. Use the "types" option to filter by output type:\n Before: debug: { pattern: "${debugOptions.pattern}" }\n After: ${suggestion}`);
472
+ }
473
+ }
474
+ function suggestTypesForExtensionPattern(pattern) {
475
+ const extensionMatch = pattern.match(/\.\(?(?:css-resolved|css)\)?\$?$/);
476
+ if (!extensionMatch) return null;
477
+ const type = extensionMatch[0].includes("css-resolved") ? "css-resolved" : "css";
478
+ const remaining = pattern.slice(0, extensionMatch.index);
479
+ return remaining ? `debug: { pattern: "${remaining}", types: ["${type}"] }` : `debug: { types: ["${type}"] }`;
480
+ }
481
+
482
+ //#endregion
483
+ //#region ../yak-internals/loaders/lib/extractCss.ts
484
+ function extractCss(code, transpilationMode) {
485
+ let codeString;
486
+ if (typeof code === "string") codeString = code;
487
+ else if (code instanceof Buffer) codeString = code.toString("utf-8");
488
+ else if (code instanceof ArrayBuffer) codeString = new TextDecoder("utf-8").decode(code);
489
+ else throw new Error("Invalid input type: code must be string, Buffer, or ArrayBuffer");
490
+ const codeParts = codeString.split("/*YAK Extracted CSS:\n");
491
+ let result = "";
492
+ for (let i = 1; i < codeParts.length; i++) {
493
+ const codeUntilEnd = codeParts[i].split("*/")[0];
494
+ result += codeUntilEnd;
495
+ }
496
+ if (result && transpilationMode !== "Css") result = "/* cssmodules-pure-no-check */\n" + result;
497
+ return result;
498
+ }
499
+
500
+ //#endregion
501
+ //#region ../yak-internals/packageNames.ts
502
+ const yakPackageNames = ["@yak/react", "@yak/solid"];
503
+
504
+ //#endregion
505
+ //#region ../yak-internals/loaders/lib/parseExports.ts
506
+ async function parseExports(sourceContents) {
507
+ try {
508
+ const ast = parse(sourceContents, {
509
+ sourceType: "module",
510
+ plugins: ["jsx", "typescript"]
511
+ });
512
+ const moduleExports = {
513
+ importYak: ast.program.body.some((node) => node.type === "ImportDeclaration" && yakPackageNames.includes(node.source.value)),
514
+ named: {},
515
+ all: []
516
+ };
517
+ const variableDeclarations = {};
518
+ let defaultIdentifier = null;
519
+ for (const node of ast.program.body) {
520
+ if (node.type === "VariableDeclaration") {
521
+ for (const decl of node.declarations) if (decl.id.type === "Identifier" && decl.init) variableDeclarations[decl.id.name] = decl.init;
522
+ }
523
+ if (node.type === "ExportNamedDeclaration") {
524
+ if (node.source) for (const specifier of node.specifiers) {
525
+ if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.local.type === "Identifier") moduleExports.named[specifier.exported.name] = {
526
+ type: "re-export",
527
+ from: node.source.value,
528
+ name: specifier.local.name
529
+ };
530
+ if (specifier.type === "ExportNamespaceSpecifier" && specifier.exported.type === "Identifier") moduleExports.named[specifier.exported.name] = {
531
+ type: "namespace-re-export",
532
+ from: node.source.value
533
+ };
534
+ }
535
+ else if (node.declaration?.type === "VariableDeclaration") {
536
+ for (const declaration of node.declaration.declarations) if (declaration.id.type === "Identifier" && declaration.init) {
537
+ variableDeclarations[declaration.id.name] = declaration.init;
538
+ const parsed = parseExportValueExpression(declaration.init, sourceContents);
539
+ if (parsed) moduleExports.named[declaration.id.name] = parsed;
540
+ }
541
+ }
542
+ }
543
+ if (node.type === "ExportDefaultDeclaration") {
544
+ if (node.declaration.type === "Identifier") defaultIdentifier = node.declaration.name;
545
+ else if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") moduleExports.named["default"] = {
546
+ type: "unsupported",
547
+ hint: node.declaration.type,
548
+ source: extractUnsupportedSource(node.declaration.loc, sourceContents)
549
+ };
550
+ else moduleExports.named["default"] = parseExportValueExpression(node.declaration, sourceContents);
551
+ }
552
+ if (node.type === "ExportAllDeclaration") moduleExports.all.push(node.source.value);
553
+ }
554
+ if (defaultIdentifier && variableDeclarations[defaultIdentifier]) moduleExports.named["default"] = parseExportValueExpression(variableDeclarations[defaultIdentifier], sourceContents);
555
+ return moduleExports;
556
+ } catch (error) {
557
+ throw new Error(`Error parsing exports: ${error.message}`);
558
+ }
559
+ }
560
+ function unpackTSAsExpression(node) {
561
+ if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression") return unpackTSAsExpression(node.expression);
562
+ return node;
563
+ }
564
+ function parseExportValueExpression(node, code) {
565
+ const expression = unpackTSAsExpression(node);
566
+ if (expression.type === "CallExpression" || expression.type === "TaggedTemplateExpression") return { type: "tag-template" };
567
+ else if (expression.type === "StringLiteral" || expression.type === "NumericLiteral") return {
568
+ type: "constant",
569
+ value: expression.value
570
+ };
571
+ else if (expression.type === "UnaryExpression" && expression.operator === "-" && expression.argument.type === "NumericLiteral") return {
572
+ type: "constant",
573
+ value: -expression.argument.value
574
+ };
575
+ else if (expression.type === "TemplateLiteral" && expression.quasis.length === 1) return {
576
+ type: "constant",
577
+ value: expression.quasis[0].value.raw
578
+ };
579
+ else if (expression.type === "ObjectExpression") return {
580
+ type: "record",
581
+ value: parseObjectExpression(expression, code)
582
+ };
583
+ return {
584
+ type: "unsupported",
585
+ hint: expression.type,
586
+ source: extractUnsupportedSource(expression.loc, code)
587
+ };
588
+ }
589
+ function parseObjectExpression(node, code) {
590
+ let result = {};
591
+ for (const property of node.properties) if (property.type === "ObjectProperty" && property.key.type === "Identifier") {
592
+ const key = property.key.name;
593
+ const parsed = parseExportValueExpression(property.value, code);
594
+ if (parsed) result[key] = parsed;
595
+ }
596
+ return result;
597
+ }
598
+ function extractUnsupportedSource(loc, code) {
599
+ if (!loc || !code) return void 0;
600
+ const lineText = code.split(/\r?\n/)[loc.start.line - 1];
601
+ if (lineText === void 0) return void 0;
602
+ return {
603
+ start: {
604
+ line: loc.start.line,
605
+ column: loc.start.column
606
+ },
607
+ end: {
608
+ line: loc.end.line,
609
+ column: loc.end.column
610
+ },
611
+ lineText
612
+ };
613
+ }
614
+
615
+ //#endregion
616
+ //#region ../yak-internals/loaders/lib/swcParserOptions.ts
617
+ const typeScriptWithoutJsx = /\.[mc]?ts$/;
618
+ const typeScriptWithJsx = /\.tsx$/;
619
+ function getSwcParserOptions(filename) {
620
+ const [path] = filename.split("?");
621
+ if (typeScriptWithoutJsx.test(path)) return {
622
+ syntax: "typescript",
623
+ tsx: false,
624
+ dynamicImport: true
625
+ };
626
+ if (typeScriptWithJsx.test(path)) return {
627
+ syntax: "typescript",
628
+ tsx: true,
629
+ dynamicImport: true
630
+ };
631
+ return {
632
+ syntax: "ecmascript",
633
+ jsx: true,
634
+ dynamicImport: true
635
+ };
636
+ }
637
+
638
+ //#endregion
639
+ //#region ../yak-internals/loaders/vite-plugin-core.ts
640
+ const require = createRequire(import.meta.url);
641
+ const defaultSwcOptions = {
642
+ jsc: {
643
+ transform: { react: { runtime: "preserve" } },
644
+ target: "es2022",
645
+ loose: false,
646
+ minify: {
647
+ compress: false,
648
+ mangle: false
649
+ },
650
+ preserveAllComments: true
651
+ },
652
+ minify: false,
653
+ isModule: true
654
+ };
655
+ function createViteYakPlugin(library) {
656
+ return async function viteYakPlugin(userOptions = {}) {
657
+ return viteYakImpl(library, userOptions);
658
+ };
659
+ }
660
+ async function viteYakImpl(library, userOptions) {
661
+ const yakOptions = {
662
+ experiments: {
663
+ transpilationMode: "Css",
664
+ suppressDeprecationWarnings: false,
665
+ ...userOptions.experiments
666
+ },
667
+ minify: userOptions.minify ?? process.env.NODE_ENV === "production",
668
+ prefix: userOptions.prefix,
669
+ foldStatic: userOptions.foldStatic ?? library.foldStatic,
670
+ strictCssProp: userOptions.strictCssProp,
671
+ contextPath: userOptions.contextPath,
672
+ swcOptions: deepMerge(defaultSwcOptions, userOptions.swcOptions ?? {})
673
+ };
674
+ yakOptions.displayNames = userOptions.displayNames ?? yakOptions.displayNames ?? !yakOptions.minify;
675
+ let basePath = userOptions.basePath ?? "";
676
+ let hasWarnedAboutBasePath = false;
677
+ let debugLog = () => {};
678
+ let isServe = false;
679
+ const sourceFileRegex = /\.(tsx?|m?jsx?)\??/;
680
+ const virtualModuleRegex = /^virtual:yak-css:/;
681
+ const virtualCssModuleRegex = /^\0virtual:yak-css:/;
682
+ const yakSwcPath = await findYakSwcPlugin();
683
+ const evaluator = await createEvaluator();
684
+ function checkFileAccess(filePath, config) {
685
+ if (config.command !== "serve") return filePath;
686
+ const normalizedPath = normalizePath(resolve(filePath));
687
+ if (!isFileLoadingAllowed(config, normalizedPath)) throw new Error(`[${library.name}] Access to yak CSS source is denied`);
688
+ return normalizedPath;
689
+ }
690
+ return {
691
+ name: "vite-plugin-yak:css:pre",
692
+ enforce: "pre",
693
+ config: (config) => {
694
+ const context = resolveYakContext(yakOptions.contextPath, config.root ?? process.cwd());
695
+ if (!context) return;
696
+ config.resolve ||= {};
697
+ if (Array.isArray(config.resolve.alias)) config.resolve.alias.push({
698
+ find: `${library.name}/context/baseContext`,
699
+ replacement: context
700
+ });
701
+ else config.resolve.alias = {
702
+ ...config.resolve.alias,
703
+ [`${library.name}/context/baseContext`]: context
704
+ };
705
+ },
706
+ configResolved(config) {
707
+ basePath = basePath ? resolve(config.root, basePath) : config.root;
708
+ debugLog = createDebugLogger(yakOptions.experiments?.debug, basePath);
709
+ isServe = config.command === "serve";
710
+ },
711
+ resolveId: {
712
+ filter: { id: virtualModuleRegex },
713
+ handler(id) {
714
+ return "\0" + id;
715
+ }
716
+ },
717
+ load: {
718
+ filter: { id: virtualCssModuleRegex },
719
+ async handler(id) {
720
+ const config = this.environment.getTopLevelConfig();
721
+ const queryStringStart = id.indexOf("?");
722
+ const queryString = queryStringStart === -1 ? "" : id.slice(queryStringStart);
723
+ const idWithoutQuery = id.slice(0, id.length - queryString.length);
724
+ if (!idWithoutQuery.startsWith("\0virtual:yak-css:") || !idWithoutQuery.endsWith(".css")) this.error(`[${library.name}] Invalid yak CSS module`);
725
+ const relativeId = idWithoutQuery.slice(17, -4);
726
+ if (!relativeId) this.error(`[${library.name}] Invalid yak CSS module`);
727
+ const originalId = resolve(basePath, relativeId);
728
+ const readSource = async (filePath) => this.fs.readFile(checkFileAccess(filePath, config), { encoding: "utf8" });
729
+ const sourceContent = await readSource(originalId);
730
+ this.addWatchFile(originalId);
731
+ const code = await transform$1(sourceContent, originalId, basePath, yakSwcPath, yakOptions);
732
+ debugLog("ts", code.code, originalId);
733
+ const extractedCss = extractCss(code.code, "Css");
734
+ debugLog("css", extractedCss, originalId);
735
+ const { resolved } = await resolveCrossFileConstant({
736
+ parse: (modulePath) => {
737
+ return parseModule({
738
+ transpilationMode: "Css",
739
+ extractExports: async (modulePath) => {
740
+ const sourceContent = await readSource(modulePath);
741
+ this.addWatchFile(modulePath);
742
+ return parseExports(sourceContent);
743
+ },
744
+ getTransformed: async (modulePath) => {
745
+ return transform$1(await readSource(modulePath), modulePath, basePath, yakSwcPath, yakOptions);
746
+ },
747
+ evaluateYakModule: async (modulePath) => {
748
+ checkFileAccess(modulePath, config);
749
+ this.addWatchFile(modulePath);
750
+ const result = await evaluator.evaluate(modulePath);
751
+ if (!result.ok) throw new Error(result.error.message);
752
+ for (const dep of result.dependencies) this.addWatchFile(dep);
753
+ return result.value;
754
+ }
755
+ }, modulePath);
756
+ },
757
+ resolve: async (moduleSpecifier, context) => {
758
+ let importer = context;
759
+ const resolved = await this.resolve(moduleSpecifier, importer);
760
+ if (!resolved) throw new Error(`Could not resolve ${moduleSpecifier} from ${context}`);
761
+ return resolved.id;
762
+ }
763
+ }, originalId + queryString, extractedCss);
764
+ debugLog("css-resolved", resolved, originalId);
765
+ return resolved;
766
+ }
767
+ },
768
+ configureServer(server) {
769
+ server.watcher.on("change", (file) => {
770
+ evaluator.invalidate(file);
771
+ });
772
+ },
773
+ transform: {
774
+ filter: {
775
+ id: {
776
+ include: sourceFileRegex,
777
+ exclude: [library.excludePattern]
778
+ },
779
+ code: library.name
780
+ },
781
+ async handler(code, id) {
782
+ try {
783
+ const filePath = id.split("?")[0];
784
+ if (!hasWarnedAboutBasePath) {
785
+ if (relative(basePath, filePath).startsWith("..")) {
786
+ hasWarnedAboutBasePath = true;
787
+ console.warn(`[${library.name}] Source file "${filePath}" is outside the project root "${basePath}".\nThis may cause CSS resolution issues in monorepo setups.\nSet the "basePath" plugin option to your monorepo root:\n\n { basePath: "/absolute/path/to/monorepo/root" }\n`);
788
+ }
789
+ }
790
+ const result = await transform$1(code, filePath, basePath, yakSwcPath, yakOptions, isServe && library.reactRefreshReg, false);
791
+ return {
792
+ code: result.code,
793
+ map: result.map
794
+ };
795
+ } catch (error) {
796
+ this.error(`[YAK Plugin] Error transforming ${id}: ${error.message}`);
797
+ }
798
+ }
799
+ },
800
+ hotUpdate({ modules, file, type }) {
801
+ if (type !== "update" && type !== "create") return;
802
+ if (!sourceFileRegex.test(file)) return;
803
+ const virtualId = "\0virtual:yak-css:" + normalizePath(relative(basePath, file)) + ".css";
804
+ const mod = this.environment.moduleGraph.getModuleById(virtualId);
805
+ if (mod) {
806
+ this.environment.moduleGraph.invalidateModule(mod);
807
+ return [...modules, mod];
808
+ }
809
+ }
810
+ };
811
+ }
812
+ async function findYakSwcPlugin() {
813
+ try {
814
+ const packageJsonPath = require.resolve("@yak/swc/package.json");
815
+ const packageRoot = dirname(packageJsonPath);
816
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
817
+ return resolve(packageRoot, packageJson.main);
818
+ } catch (e) {
819
+ throw new Error(`Could not resolve yak-swc plugin: ${e}`);
820
+ }
821
+ }
822
+ function transform$1(data, modulePath, rootPath, yakSwcPath, yakOptions, reactRefreshReg, emitCssComments) {
823
+ return transform(data, {
824
+ filename: modulePath,
825
+ inputSourceMap: void 0,
826
+ sourceMaps: true,
827
+ sourceFileName: modulePath,
828
+ sourceRoot: rootPath,
829
+ ...yakOptions.swcOptions,
830
+ jsc: {
831
+ parser: getSwcParserOptions(modulePath),
832
+ ...yakOptions.swcOptions?.jsc,
833
+ experimental: {
834
+ keepImportAttributes: true,
835
+ ...yakOptions.swcOptions?.jsc?.experimental,
836
+ plugins: [[yakSwcPath, {
837
+ minify: yakOptions.minify,
838
+ basePath: rootPath,
839
+ prefix: yakOptions.prefix,
840
+ displayNames: yakOptions.displayNames,
841
+ foldStatic: yakOptions.foldStatic ?? true,
842
+ strictCssProp: yakOptions.strictCssProp ?? true,
843
+ suppressDeprecationWarnings: yakOptions.experiments?.suppressDeprecationWarnings,
844
+ ...reactRefreshReg ? { reactRefreshReg: true } : {},
845
+ ...emitCssComments === false ? { emitCssComments: false } : {},
846
+ importMode: {
847
+ value: "virtual:yak-css:{{__MODULE_PATH__}}.css",
848
+ transpilation: "Css",
849
+ encoding: "None"
850
+ }
851
+ }]]
852
+ }
853
+ }
854
+ });
855
+ }
856
+ function deepMerge(target, source) {
857
+ const result = { ...target };
858
+ for (const key of Object.keys(source)) {
859
+ const sourceValue = source[key];
860
+ const targetValue = target[key];
861
+ if (sourceValue !== void 0 && typeof sourceValue === "object" && sourceValue !== null && !Array.isArray(sourceValue) && typeof targetValue === "object" && targetValue !== null && !Array.isArray(targetValue)) result[key] = deepMerge(targetValue, sourceValue);
862
+ else if (sourceValue !== void 0) result[key] = sourceValue;
863
+ }
864
+ return result;
865
+ }
866
+
867
+ //#endregion
868
+ //#region loaders/vite-plugin.ts
869
+ const viteYak = createViteYakPlugin({
870
+ name: "@yak/react",
871
+ reactRefreshReg: true,
872
+ excludePattern: /packages\/yak-react/,
873
+ foldStatic: true
874
+ });
875
+
876
+ //#endregion
877
+ export { viteYak };
878
+ //# sourceMappingURL=vite-plugin.js.map