next-yak 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/loaders/{css-loader.cjs → css-loader.js} +82 -109
- package/dist/loaders/css-loader.js.map +1 -0
- package/dist/withYak/index.cjs +1 -1
- package/dist/withYak/index.cjs.map +1 -1
- package/dist/withYak/index.js +1 -1
- package/dist/withYak/index.js.map +1 -1
- package/loaders/css-loader.ts +1 -1
- package/loaders/lib/resolveCrossFileSelectors.ts +63 -49
- package/package.json +4 -6
- package/withYak/index.ts +1 -1
- package/dist/loaders/css-loader.cjs.map +0 -1
- /package/dist/loaders/{css-loader.d.cts → css-loader.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
| next-yak | Next.js | react | swc_core |
|
|
25
25
|
|------------------|-----------------|------------------|------------------|
|
|
26
|
+
| 5.x | >= 15.2.1 | 19.x | 16.0.0 |
|
|
26
27
|
| 4.x | >= 15.0.4 | 19.x | 5.0.1 |
|
|
27
28
|
| 3.x | 15.x | 18.x / 19.x | 3.0.2 |
|
|
28
29
|
| 2.x | 14.x | 18.x / 19.x | 0.279.0 |
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
## Installation
|
|
31
32
|
|
|
32
33
|
```bash
|
|
33
|
-
# For Next.js >= 15.
|
|
34
|
-
npm install next-yak
|
|
34
|
+
# For Next.js >= 15.2.1
|
|
35
|
+
npm install next-yak
|
|
35
36
|
|
|
36
37
|
# For Next.js 14.x
|
|
37
38
|
npm install next-yak@2
|
|
@@ -1,50 +1,30 @@
|
|
|
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
1
|
// loaders/css-loader.ts
|
|
31
|
-
|
|
32
|
-
__export(css_loader_exports, {
|
|
33
|
-
default: () => cssExtractLoader
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(css_loader_exports);
|
|
36
|
-
var import_path2 = require("path");
|
|
2
|
+
import { relative } from "path";
|
|
37
3
|
|
|
38
4
|
// loaders/lib/resolveCrossFileSelectors.ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
5
|
+
import babel from "@babel/core";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import babelPlugin from "@babel/plugin-syntax-typescript";
|
|
8
|
+
import { getCssModuleLocalIdent } from "next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js";
|
|
43
9
|
var yakCssImportRegex = (
|
|
44
10
|
// Make mixin and selector non optional once we dropped support for the babel plugin
|
|
45
11
|
/--yak-css-import\:\s*url\("([^"]+)",?(|mixin|selector)\)(;?)/g
|
|
46
12
|
);
|
|
47
13
|
var compilationCache = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var getCompilationCache = (loader) => {
|
|
15
|
+
const compilation = loader._compilation;
|
|
16
|
+
if (!compilation) {
|
|
17
|
+
throw new Error("Webpack compilation object not available");
|
|
18
|
+
}
|
|
19
|
+
let cache = compilationCache.get(compilation);
|
|
20
|
+
if (!cache) {
|
|
21
|
+
cache = {
|
|
22
|
+
parsedFiles: /* @__PURE__ */ new Map()
|
|
23
|
+
};
|
|
24
|
+
compilationCache.set(compilation, cache);
|
|
25
|
+
}
|
|
26
|
+
return cache;
|
|
27
|
+
};
|
|
48
28
|
async function resolveCrossFileConstant(loader, pathContext, css) {
|
|
49
29
|
const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {
|
|
50
30
|
const [fullMatch, encodedArguments, importKind, semicolon] = match;
|
|
@@ -61,20 +41,18 @@ async function resolveCrossFileConstant(loader, pathContext, css) {
|
|
|
61
41
|
});
|
|
62
42
|
if (matches.length === 0) return css;
|
|
63
43
|
try {
|
|
64
|
-
const exportCache = /* @__PURE__ */ new Map();
|
|
65
44
|
const resolvedValues = await Promise.all(
|
|
66
|
-
matches.map(({ moduleSpecifier, specifier
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
matches.map(async ({ moduleSpecifier, specifier }) => {
|
|
46
|
+
const parsedModule = await parseModule(
|
|
47
|
+
loader,
|
|
48
|
+
moduleSpecifier,
|
|
49
|
+
pathContext
|
|
50
|
+
);
|
|
51
|
+
const resolvedValue = await resolveModuleSpecifierRecursively(
|
|
52
|
+
loader,
|
|
53
|
+
parsedModule,
|
|
54
|
+
specifier
|
|
74
55
|
);
|
|
75
|
-
if (!resolvedFromCache) {
|
|
76
|
-
exportCache.set(encodedArguments, resolvedValue);
|
|
77
|
-
}
|
|
78
56
|
return resolvedValue;
|
|
79
57
|
})
|
|
80
58
|
);
|
|
@@ -91,7 +69,7 @@ async function resolveCrossFileConstant(loader, pathContext, css) {
|
|
|
91
69
|
);
|
|
92
70
|
}
|
|
93
71
|
}
|
|
94
|
-
const replacement = resolved.type === "styled-component" ? `:global(.${
|
|
72
|
+
const replacement = resolved.type === "styled-component" ? `:global(.${getCssModuleLocalIdent(
|
|
95
73
|
{
|
|
96
74
|
rootContext: loader.rootContext,
|
|
97
75
|
resourcePath: resolved.from
|
|
@@ -117,43 +95,35 @@ File: ${loader.resourcePath}`
|
|
|
117
95
|
);
|
|
118
96
|
}
|
|
119
97
|
}
|
|
98
|
+
async function resolveModule(loader, moduleSpecifier, context) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
loader.resolve(context, moduleSpecifier, (err, result) => {
|
|
101
|
+
if (err) return reject(err);
|
|
102
|
+
if (!result)
|
|
103
|
+
return reject(new Error(`Could not resolve ${moduleSpecifier}`));
|
|
104
|
+
resolve(result);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
120
108
|
async function parseModule(loader, moduleSpecifier, context) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
const cache = getCompilationCache(loader).parsedFiles;
|
|
110
|
+
const resolvedModule = await resolveModule(loader, moduleSpecifier, context);
|
|
111
|
+
let parsedFile = cache.get(resolvedModule);
|
|
112
|
+
if (!parsedFile) {
|
|
113
|
+
parsedFile = await parseFile(loader, resolvedModule);
|
|
114
|
+
cache.set(resolvedModule, parsedFile);
|
|
124
115
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
cache = /* @__PURE__ */ new Map();
|
|
128
|
-
compilationCache.set(compilation, cache);
|
|
129
|
-
}
|
|
130
|
-
const cacheKey = import_path.default.resolve(context, moduleSpecifier);
|
|
131
|
-
let filePromise = cache.get(cacheKey);
|
|
132
|
-
if (!filePromise) {
|
|
133
|
-
filePromise = (async () => {
|
|
134
|
-
const resolved = await new Promise((resolve, reject) => {
|
|
135
|
-
loader.resolve(context, moduleSpecifier, (err, result) => {
|
|
136
|
-
if (err) return reject(err);
|
|
137
|
-
if (!result)
|
|
138
|
-
return reject(new Error(`Could not resolve ${moduleSpecifier}`));
|
|
139
|
-
resolve(result);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
return parseFile(loader, resolved);
|
|
143
|
-
})();
|
|
144
|
-
cache.set(cacheKey, filePromise);
|
|
145
|
-
}
|
|
146
|
-
loader.addDependency((await filePromise).filePath);
|
|
147
|
-
return filePromise;
|
|
116
|
+
loader.addDependency(parsedFile.filePath);
|
|
117
|
+
return parsedFile;
|
|
148
118
|
}
|
|
149
119
|
async function parseFile(loader, filePath) {
|
|
150
120
|
const isYak = filePath.endsWith(".yak.ts") || filePath.endsWith(".yak.tsx") || filePath.endsWith(".yak.js") || filePath.endsWith(".yak.jsx");
|
|
151
121
|
const isTSX = filePath.endsWith(".tsx");
|
|
152
122
|
try {
|
|
153
123
|
if (isYak) {
|
|
154
|
-
const
|
|
124
|
+
const module = await loader.importModule(filePath);
|
|
155
125
|
const mappedModule = Object.fromEntries(
|
|
156
|
-
Object.entries(
|
|
126
|
+
Object.entries(module).map(([key, value]) => {
|
|
157
127
|
if (typeof value === "string" || typeof value === "number") {
|
|
158
128
|
return [key, { type: "constant", value }];
|
|
159
129
|
} else if (value && (typeof value === "object" || Array.isArray(value))) {
|
|
@@ -189,22 +159,22 @@ async function parseFile(loader, filePath) {
|
|
|
189
159
|
resolve(sourceString || "");
|
|
190
160
|
});
|
|
191
161
|
});
|
|
192
|
-
const
|
|
162
|
+
const exports = await parseExports(await sourceContents, isTSX);
|
|
193
163
|
const mixins = parseMixins(await tranformedSource);
|
|
194
164
|
await Promise.all(
|
|
195
165
|
Object.entries(mixins).map(async ([name, { value, nameParts }]) => {
|
|
196
166
|
const resolvedValue = await resolveCrossFileConstant(
|
|
197
167
|
loader,
|
|
198
|
-
|
|
168
|
+
path.dirname(filePath),
|
|
199
169
|
value
|
|
200
170
|
);
|
|
201
171
|
if (nameParts.length === 1) {
|
|
202
|
-
|
|
172
|
+
exports[name] = { type: "mixin", value: resolvedValue };
|
|
203
173
|
} else {
|
|
204
|
-
let exportEntry =
|
|
174
|
+
let exportEntry = exports[nameParts[0]];
|
|
205
175
|
if (!exportEntry) {
|
|
206
176
|
exportEntry = { type: "record", value: {} };
|
|
207
|
-
|
|
177
|
+
exports[nameParts[0]] = exportEntry;
|
|
208
178
|
} else if (exportEntry.type !== "record") {
|
|
209
179
|
throw new Error(
|
|
210
180
|
`Error parsing file ${filePath}: ${nameParts[0]} is not a record`
|
|
@@ -232,7 +202,7 @@ async function parseFile(loader, filePath) {
|
|
|
232
202
|
);
|
|
233
203
|
return {
|
|
234
204
|
type: "regular",
|
|
235
|
-
exports
|
|
205
|
+
exports,
|
|
236
206
|
filePath
|
|
237
207
|
};
|
|
238
208
|
} catch (error) {
|
|
@@ -242,12 +212,12 @@ async function parseFile(loader, filePath) {
|
|
|
242
212
|
}
|
|
243
213
|
}
|
|
244
214
|
async function parseExports(sourceContents, isTSX) {
|
|
245
|
-
let
|
|
215
|
+
let exports = {};
|
|
246
216
|
try {
|
|
247
|
-
|
|
217
|
+
babel.transformSync(sourceContents, {
|
|
248
218
|
configFile: false,
|
|
249
219
|
plugins: [
|
|
250
|
-
[
|
|
220
|
+
[babelPlugin, { isTSX }],
|
|
251
221
|
[
|
|
252
222
|
() => ({
|
|
253
223
|
visitor: {
|
|
@@ -255,7 +225,7 @@ async function parseExports(sourceContents, isTSX) {
|
|
|
255
225
|
if (node.source) {
|
|
256
226
|
node.specifiers.forEach((specifier) => {
|
|
257
227
|
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.local.type === "Identifier") {
|
|
258
|
-
|
|
228
|
+
exports[specifier.exported.name] = {
|
|
259
229
|
type: "re-export",
|
|
260
230
|
from: node.source.value,
|
|
261
231
|
imported: specifier.local.name
|
|
@@ -265,7 +235,7 @@ async function parseExports(sourceContents, isTSX) {
|
|
|
265
235
|
} else if (node.declaration?.type === "VariableDeclaration") {
|
|
266
236
|
node.declaration.declarations.forEach((declaration) => {
|
|
267
237
|
if (declaration.id.type === "Identifier" && declaration.init) {
|
|
268
|
-
|
|
238
|
+
exports[declaration.id.name] = parseExportValueExpression(
|
|
269
239
|
declaration.init
|
|
270
240
|
);
|
|
271
241
|
}
|
|
@@ -277,7 +247,7 @@ async function parseExports(sourceContents, isTSX) {
|
|
|
277
247
|
const { specifiers, source } = node;
|
|
278
248
|
specifiers.forEach((specifier) => {
|
|
279
249
|
if (specifier.type === "ExportNamespaceSpecifier" && specifier.exported.type === "Identifier") {
|
|
280
|
-
|
|
250
|
+
exports[specifier.exported.name] = {
|
|
281
251
|
type: "star-export",
|
|
282
252
|
from: [source.value]
|
|
283
253
|
};
|
|
@@ -286,15 +256,15 @@ async function parseExports(sourceContents, isTSX) {
|
|
|
286
256
|
}
|
|
287
257
|
},
|
|
288
258
|
ExportAllDeclaration({ node }) {
|
|
289
|
-
if (Object.keys(
|
|
290
|
-
|
|
259
|
+
if (Object.keys(exports).length === 0) {
|
|
260
|
+
exports["*"] ||= {
|
|
291
261
|
type: "star-export",
|
|
292
262
|
from: []
|
|
293
263
|
};
|
|
294
|
-
if (
|
|
264
|
+
if (exports["*"].type !== "star-export") {
|
|
295
265
|
throw new Error("Invalid star export state");
|
|
296
266
|
}
|
|
297
|
-
|
|
267
|
+
exports["*"].from.push(node.source.value);
|
|
298
268
|
}
|
|
299
269
|
}
|
|
300
270
|
}
|
|
@@ -302,7 +272,7 @@ async function parseExports(sourceContents, isTSX) {
|
|
|
302
272
|
]
|
|
303
273
|
]
|
|
304
274
|
});
|
|
305
|
-
return
|
|
275
|
+
return exports;
|
|
306
276
|
} catch (error) {
|
|
307
277
|
throw new Error(`Error parsing exports: ${error.message}`);
|
|
308
278
|
}
|
|
@@ -356,16 +326,16 @@ function parseObjectExpression(node) {
|
|
|
356
326
|
}
|
|
357
327
|
return result;
|
|
358
328
|
}
|
|
359
|
-
async function resolveModuleSpecifierRecursively(loader,
|
|
329
|
+
async function resolveModuleSpecifierRecursively(loader, module, specifier) {
|
|
360
330
|
try {
|
|
361
331
|
const exportName = specifier[0];
|
|
362
|
-
let exportValue =
|
|
332
|
+
let exportValue = module.exports[exportName];
|
|
363
333
|
if (exportValue === void 0) {
|
|
364
|
-
const starExport =
|
|
334
|
+
const starExport = module.exports["*"];
|
|
365
335
|
if (starExport?.type === "star-export") {
|
|
366
336
|
if (starExport.from.length > 1) {
|
|
367
337
|
throw new Error(
|
|
368
|
-
`Could not resolve ${specifier.join(".")} in module ${
|
|
338
|
+
`Could not resolve ${specifier.join(".")} in module ${module.filePath} - Multiple star exports are not supported for performance reasons`
|
|
369
339
|
);
|
|
370
340
|
}
|
|
371
341
|
exportValue = {
|
|
@@ -375,7 +345,7 @@ async function resolveModuleSpecifierRecursively(loader, module2, specifier) {
|
|
|
375
345
|
};
|
|
376
346
|
} else {
|
|
377
347
|
throw new Error(
|
|
378
|
-
`Could not resolve "${specifier.join(".")}" in module ${
|
|
348
|
+
`Could not resolve "${specifier.join(".")}" in module ${module.filePath}`
|
|
379
349
|
);
|
|
380
350
|
}
|
|
381
351
|
}
|
|
@@ -383,7 +353,7 @@ async function resolveModuleSpecifierRecursively(loader, module2, specifier) {
|
|
|
383
353
|
const importedModule = await parseModule(
|
|
384
354
|
loader,
|
|
385
355
|
exportValue.from,
|
|
386
|
-
|
|
356
|
+
path.dirname(module.filePath)
|
|
387
357
|
);
|
|
388
358
|
return resolveModuleSpecifierRecursively(loader, importedModule, [
|
|
389
359
|
exportValue.imported,
|
|
@@ -393,7 +363,7 @@ async function resolveModuleSpecifierRecursively(loader, module2, specifier) {
|
|
|
393
363
|
const importedModule = await parseModule(
|
|
394
364
|
loader,
|
|
395
365
|
exportValue.from[0],
|
|
396
|
-
|
|
366
|
+
path.dirname(module.filePath)
|
|
397
367
|
);
|
|
398
368
|
return resolveModuleSpecifierRecursively(
|
|
399
369
|
loader,
|
|
@@ -404,7 +374,7 @@ async function resolveModuleSpecifierRecursively(loader, module2, specifier) {
|
|
|
404
374
|
if (exportValue.type === "styled-component") {
|
|
405
375
|
return {
|
|
406
376
|
type: "styled-component",
|
|
407
|
-
from:
|
|
377
|
+
from: module.filePath,
|
|
408
378
|
name: specifier[specifier.length - 1]
|
|
409
379
|
};
|
|
410
380
|
} else if (exportValue.type === "constant") {
|
|
@@ -449,8 +419,8 @@ Key "${specifier[depth]}" was of type "${typeof current}" but only String and Nu
|
|
|
449
419
|
);
|
|
450
420
|
} catch (error) {
|
|
451
421
|
throw new Error(
|
|
452
|
-
`Error resolving from module ${
|
|
453
|
-
Extracted values: ${JSON.stringify(
|
|
422
|
+
`Error resolving from module ${module.filePath}: ${error.message}
|
|
423
|
+
Extracted values: ${JSON.stringify(module.exports, null, 2)}`
|
|
454
424
|
);
|
|
455
425
|
}
|
|
456
426
|
}
|
|
@@ -511,7 +481,7 @@ function createDebugLogger(loaderContext, debugOptions) {
|
|
|
511
481
|
"\u{1F42E} Yak",
|
|
512
482
|
messageType,
|
|
513
483
|
"\n",
|
|
514
|
-
loaderContext._compiler ?
|
|
484
|
+
loaderContext._compiler ? relative(
|
|
515
485
|
loaderContext._compiler.context,
|
|
516
486
|
loaderContext.resourcePath
|
|
517
487
|
) : loaderContext.resourcePath,
|
|
@@ -521,4 +491,7 @@ function createDebugLogger(loaderContext, debugOptions) {
|
|
|
521
491
|
}
|
|
522
492
|
};
|
|
523
493
|
}
|
|
524
|
-
|
|
494
|
+
export {
|
|
495
|
+
cssExtractLoader as default
|
|
496
|
+
};
|
|
497
|
+
//# sourceMappingURL=css-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../loaders/css-loader.ts","../../loaders/lib/resolveCrossFileSelectors.ts"],"sourcesContent":["import { relative } from \"path\";\nimport type { LoaderContext } from \"webpack\";\nimport type { YakConfigOptions } from \"../withYak/index.js\";\nimport { resolveCrossFileConstant } from \"./lib/resolveCrossFileSelectors.js\";\n\n/**\n * Transform typescript to css\n *\n * This loader takes the cached result from the yak tsloader\n * and extracts the css from the generated comments\n */\nexport default async function cssExtractLoader(\n this: LoaderContext<YakConfigOptions>,\n // Instead of the source code, we receive the extracted css\n // from the yak-swc transformation\n _code: string,\n sourceMap: string | undefined,\n): Promise<string | void> {\n const callback = this.async();\n // Load the module from the original typescript request (without !=! and the query)\n return this.loadModule(this.resourcePath, (err, source) => {\n if (err) {\n return callback(err);\n }\n if (!source) {\n return callback(\n new Error(`Source code for ${this.resourcePath} is empty`),\n );\n }\n const { experiments } = this.getOptions();\n const debugLog = createDebugLogger(this, experiments?.debug);\n\n debugLog(\"ts\", source);\n const css = extractCss(source);\n debugLog(\"css\", css);\n\n return resolveCrossFileConstant(this, this.context, css).then((result) => {\n debugLog(\"css resolved\", css);\n return callback(null, result, sourceMap);\n }, callback);\n });\n}\n\nfunction extractCss(code: string | Buffer<ArrayBufferLike>): 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 return result;\n}\n\nfunction createDebugLogger(\n loaderContext: LoaderContext<YakConfigOptions>,\n debugOptions: Required<YakConfigOptions>[\"experiments\"][\"debug\"],\n) {\n if (\n !debugOptions ||\n (debugOptions !== true &&\n debugOptions.filter &&\n !debugOptions.filter(loaderContext.resourcePath))\n ) {\n return () => {};\n }\n const debugType = debugOptions === true ? \"ts\" : debugOptions.type;\n return (\n messageType: \"ts\" | \"css\" | \"css resolved\",\n message: string | Buffer<ArrayBufferLike> | undefined,\n ) => {\n if (messageType === debugType || debugType === \"all\") {\n console.log(\n \"🐮 Yak\",\n messageType,\n \"\\n\",\n loaderContext._compiler\n ? relative(\n loaderContext._compiler.context,\n loaderContext.resourcePath,\n )\n : loaderContext.resourcePath,\n \"\\n\\n\",\n message,\n );\n }\n };\n}\n","import babel from \"@babel/core\";\nimport path from \"path\";\n// @ts-expect-error - this is used by babel directly so we ignore that it is not typed\nimport babelPlugin from \"@babel/plugin-syntax-typescript\";\nimport { getCssModuleLocalIdent } from \"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js\";\nimport type { Compilation, LoaderContext } from \"webpack\";\n\nconst yakCssImportRegex =\n // Make mixin and selector non optional once we dropped support for the babel plugin\n /--yak-css-import\\:\\s*url\\(\"([^\"]+)\",?(|mixin|selector)\\)(;?)/g;\n\nconst compilationCache = new WeakMap<\n Compilation,\n {\n parsedFiles: Map<string, ParsedFile>;\n }\n>();\n\nconst getCompilationCache = (loader: LoaderContext<{}>) => {\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\n/**\n * Resolves cross-file selectors in css files\n *\n * e.g.:\n * theme.ts:\n * ```ts\n * export const colors = {\n * primary: \"#ff0000\",\n * secondary: \"#00ff00\",\n * };\n * ```\n *\n * styles.ts:\n * ```ts\n * import { colors } from \"./theme\";\n * export const button = css`\n * background-color: ${colors.primary};\n * `;\n */\nexport async function resolveCrossFileConstant(\n loader: LoaderContext<{}>,\n pathContext: string,\n css: string,\n): Promise<string> {\n // Search for --yak-css-import: url(\"path/to/module\") in the css\n const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {\n const [fullMatch, encodedArguments, importKind, semicolon] = match;\n const [moduleSpecifier, ...specifier] = encodedArguments\n .split(\":\")\n .map((entry) => decodeURIComponent(entry));\n return {\n encodedArguments,\n moduleSpecifier,\n specifier,\n importKind,\n semicolon,\n position: match.index!,\n size: fullMatch.length,\n };\n });\n if (matches.length === 0) return css;\n\n try {\n // Resolve all imports concurrently\n const resolvedValues = await Promise.all(\n matches.map(async ({ moduleSpecifier, specifier }) => {\n const parsedModule = await parseModule(\n loader,\n moduleSpecifier,\n pathContext,\n );\n\n const resolvedValue = await resolveModuleSpecifierRecursively(\n loader,\n parsedModule,\n specifier,\n );\n\n return resolvedValue;\n }),\n );\n\n // Replace the imports with the resolved values\n let result = css;\n for (let i = matches.length - 1; i >= 0; i--) {\n const { position, size, importKind, specifier, semicolon } = matches[i];\n const resolved = resolvedValues[i];\n\n if (importKind === \"selector\") {\n if (resolved.type === \"mixin\") {\n throw new Error(\n `Found mixin but expected a selector - did you forget a semicolon after \\`${specifier.join(\n \".\",\n )}\\`?`,\n );\n }\n }\n\n const replacement =\n resolved.type === \"styled-component\"\n ? `:global(.${getCssModuleLocalIdent(\n {\n rootContext: loader.rootContext,\n resourcePath: resolved.from,\n },\n null,\n resolved.name,\n {},\n )})`\n : resolved.value +\n // resolved.value can be of two different types:\n // - mixin:\n // ${mixinName};\n // - constant:\n // color: ${value};\n // For mixins the semicolon is already included in the value\n // but for constants it has to be added manually\n ([\"}\", \";\"].includes(String(resolved.value).trimEnd().slice(-1))\n ? \"\"\n : semicolon);\n\n result =\n result.slice(0, position) +\n String(replacement) +\n result.slice(position + size);\n }\n\n return result;\n } catch (error) {\n throw new Error(\n `Error resolving cross-file selectors: ${\n (error as Error).message\n }\\nFile: ${loader.resourcePath}`,\n );\n }\n}\n\n/**\n * Resolves a module 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\n/**\n * Resolves a module specifier to a parsed file\n *\n * e.g.:\n * ```\n * parseModule(loader, \"./theme\", \"/path/to/styles.ts\")\n * // -> { type: 'regular', secondary: { type: 'constant', value: '#00ff00' } } }, filePath: '/path/to/theme.ts' }\n * ```\n */\nasync function parseModule(\n loader: LoaderContext<{}>,\n moduleSpecifier: string,\n context: string,\n): Promise<ParsedFile> {\n const cache = getCompilationCache(loader).parsedFiles;\n\n // The cache key is valid for the entire project so it can be reused\n // for different source files\n const resolvedModule = await resolveModule(loader, moduleSpecifier, context);\n\n let parsedFile = cache.get(resolvedModule);\n if (!parsedFile) {\n parsedFile = await parseFile(loader, resolvedModule);\n\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 cache.set(resolvedModule, parsedFile);\n }\n // on file change, invalidate the cache\n loader.addDependency(parsedFile.filePath);\n return parsedFile;\n}\n\nasync function parseFile(\n loader: LoaderContext<{}>,\n filePath: string,\n): Promise<ParsedFile> {\n const isYak =\n filePath.endsWith(\".yak.ts\") ||\n filePath.endsWith(\".yak.tsx\") ||\n filePath.endsWith(\".yak.js\") ||\n filePath.endsWith(\".yak.jsx\");\n const isTSX = filePath.endsWith(\".tsx\");\n\n try {\n if (isYak) {\n const module: Record<string, unknown> =\n await loader.importModule(filePath);\n const mappedModule = Object.fromEntries(\n Object.entries(module).map(([key, value]): [string, ParsedExport] => {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return [key, { type: \"constant\" as const, value }];\n } else if (\n value &&\n (typeof value === \"object\" || Array.isArray(value))\n ) {\n return [key, { type: \"record\" as const, value }];\n } else {\n return [key, { type: \"unsupported\" as const, hint: String(value) }];\n }\n }),\n );\n return { type: \"yak\", exports: mappedModule, filePath };\n }\n const sourceContents = new Promise<string>((resolve, reject) =>\n loader.fs.readFile(filePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n resolve(result || \"\");\n }),\n );\n\n const tranformedSource = new Promise<string>((resolve, reject) => {\n loader.loadModule(filePath, (err, source) => {\n if (err) return reject(err);\n 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\n const exports = await parseExports(await sourceContents, isTSX);\n const mixins = parseMixins(await tranformedSource);\n\n // Recursively resolve cross-file constants in mixins\n // e.g. cross file mixins inside a cross file mixin\n // or a cross file selector inside a cross file mixin\n await Promise.all(\n Object.entries(mixins).map(async ([name, { value, nameParts }]) => {\n const resolvedValue = await resolveCrossFileConstant(\n loader,\n path.dirname(filePath),\n value,\n );\n if (nameParts.length === 1) {\n exports[name] = { type: \"mixin\", value: resolvedValue };\n } else {\n let exportEntry: undefined | ParsedExport = exports[nameParts[0]];\n if (!exportEntry) {\n exportEntry = { type: \"record\", value: {} };\n exports[nameParts[0]] = exportEntry;\n } else if (exportEntry.type !== \"record\") {\n throw new Error(\n `Error parsing file ${filePath}: ${nameParts[0]} is not a record`,\n );\n }\n let current = exportEntry.value as Record<any, ParsedExport>;\n for (let i = 1; i < nameParts.length - 1; i++) {\n let next = current[nameParts[i]];\n if (!next) {\n next = { type: \"record\", value: {} };\n current[nameParts[i]] = next;\n } else if (next.type !== \"record\") {\n throw new Error(\n `Error parsing file ${filePath}: ${nameParts[i]} is not a record`,\n );\n }\n current = next.value;\n }\n current[nameParts[nameParts.length - 1]] = {\n type: \"mixin\",\n value: resolvedValue,\n };\n }\n }),\n );\n\n return {\n type: \"regular\",\n exports,\n filePath,\n };\n } catch (error) {\n throw new Error(\n `Error parsing file ${filePath}: ${(error as Error).message}`,\n );\n }\n}\n\nasync function parseExports(\n sourceContents: string,\n isTSX: boolean,\n): Promise<Record<string, ParsedExport>> {\n let exports: Record<string, ParsedExport> = {};\n\n try {\n babel.transformSync(sourceContents, {\n configFile: false,\n plugins: [\n [babelPlugin, { isTSX }],\n [\n (): babel.PluginObj => ({\n visitor: {\n ExportNamedDeclaration({ node }) {\n if (node.source) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === \"ExportSpecifier\" &&\n specifier.exported.type === \"Identifier\" &&\n specifier.local.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"re-export\",\n from: node.source!.value,\n imported: specifier.local.name,\n };\n }\n });\n } else if (node.declaration?.type === \"VariableDeclaration\") {\n node.declaration.declarations.forEach((declaration) => {\n if (\n declaration.id.type === \"Identifier\" &&\n declaration.init\n ) {\n exports[declaration.id.name] = parseExportValueExpression(\n declaration.init,\n );\n }\n });\n }\n },\n ExportDeclaration({ node }) {\n if (\"specifiers\" in node && node.source) {\n const { specifiers, source } = node;\n specifiers.forEach((specifier) => {\n // export * as color from \"./colors\";\n if (\n specifier.type === \"ExportNamespaceSpecifier\" &&\n specifier.exported.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"star-export\",\n from: [source.value],\n };\n }\n });\n }\n },\n ExportAllDeclaration({ node }) {\n if (Object.keys(exports).length === 0) {\n exports[\"*\"] ||= {\n type: \"star-export\",\n from: [],\n };\n if (exports[\"*\"].type !== \"star-export\") {\n throw new Error(\"Invalid star export state\");\n }\n exports[\"*\"].from.push(node.source.value);\n }\n },\n },\n }),\n ],\n ],\n });\n\n return exports;\n } catch (error) {\n throw new Error(`Error parsing exports: ${(error as Error).message}`);\n }\n}\n\nfunction parseMixins(\n sourceContents: string,\n): Record<string, { type: \"mixin\"; value: string; nameParts: string[] }> {\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\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): ParsedExport {\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: \"styled-component\" };\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, ParsedExport> {\n let result: Record<string, ParsedExport> = {};\n for (const property of node.properties) {\n if (\n property.type === \"ObjectProperty\" &&\n property.key.type === \"Identifier\"\n ) {\n const key = property.key.name;\n result[key] = parseExportValueExpression(\n property.value as babel.types.Expression,\n );\n }\n }\n return result;\n}\n\n/**\n * Follows a specifier recursively until it finds its constant value\n * for example here it follows \"colors.primary\"\n *\n * ```\n * resolveModuleSpecifierRecursively(loader, \"@/theme\", [\"colors\", \"primary\"], \"colors:primary\")`\n * // -> { type: 'constant', value: '#ff0000' }\n * ```\n *\n * example structure:\n *\n * styles.ts:\n * ```\n * import { colors } from \"@/theme\";\n * export const button = css`color: ${colors.primary}`;\n * ```\n *\n * theme.ts:\n * ```\n * export { colors } from \"./colors\";\n * ```\n *\n * colors.ts:\n * ```\n * export const colors = { primary: \"#ff0000\" };\n * ```\n *\n */\nasync function resolveModuleSpecifierRecursively(\n loader: LoaderContext<{}>,\n module: ParsedFile,\n specifier: string[],\n): Promise<ResolvedExport> {\n try {\n const exportName = specifier[0];\n let exportValue = module.exports[exportName];\n // Follow star exports if there is only a single one\n // and the export does not exist in the current module\n if (exportValue === undefined) {\n const starExport = module.exports[\"*\"];\n if (starExport?.type === \"star-export\") {\n if (starExport.from.length > 1) {\n throw new Error(\n `Could not resolve ${specifier.join(\".\")} in module ${\n module.filePath\n } - Multiple star exports are not supported for performance reasons`,\n );\n }\n exportValue = {\n type: \"re-export\" as const,\n from: starExport.from[0],\n imported: exportName,\n };\n } else {\n throw new Error(\n `Could not resolve \"${specifier.join(\".\")}\" in module ${\n module.filePath\n }`,\n );\n }\n }\n // Follow reexport\n // e.g. export { colors as primaryColors } from \"./colors\";\n if (exportValue.type === \"re-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from,\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(loader, importedModule, [\n exportValue.imported,\n ...specifier.slice(1),\n ]);\n }\n // Namespace export\n // e.g. export * as colors from \"./colors\";\n else if (exportValue.type === \"star-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from[0],\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(\n loader,\n importedModule,\n specifier.slice(1),\n );\n }\n\n if (exportValue.type === \"styled-component\") {\n return {\n type: \"styled-component\",\n from: module.filePath,\n name: specifier[specifier.length - 1],\n };\n } else if (exportValue.type === \"constant\") {\n return { type: \"constant\", value: exportValue.value };\n } else if (exportValue.type === \"record\") {\n let current: any = exportValue.value;\n let depth = 0;\n /// Drill down the specifier e.g. colors.primary\n do {\n if (typeof current === \"string\" || typeof current === \"number\") {\n return {\n type: \"constant\" as const,\n value: current,\n };\n } else if (\n !current ||\n (typeof current !== \"object\" && !Array.isArray(current))\n ) {\n throw new Error(\n `Error unpacking Record/Array \"${exportName}\".\\nKey \"${\n specifier[depth]\n }\" was of type \"${typeof current}\" but only String and Number are supported`,\n );\n }\n depth++;\n // mixins in .yak files are wrapped inside an object with a __yak key\n if (depth === specifier.length && \"__yak\" in current) {\n return { type: \"mixin\", value: current[\"__yak\"] };\n } else if (depth === specifier.length && \"value\" in current) {\n return { type: \"constant\", value: current[\"value\"] };\n } else {\n current = current[specifier[depth]];\n }\n } while (current);\n if (specifier[depth] === undefined) {\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${specifier\n .slice(0, depth)\n .join(\".\")}\\` is not a string or number`,\n );\n }\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${\n specifier[depth]\n }\\` from \\`${specifier.slice(0, depth).join(\".\")}\\``,\n );\n } else if (exportValue.type === \"mixin\") {\n return { type: \"mixin\", value: exportValue.value };\n }\n throw new Error(\n `Error unpacking Record/Array - unexpected exportValue \"${\n exportValue.type\n }\" for specifier \"${specifier.join(\".\")}\"`,\n );\n } catch (error) {\n throw new Error(\n `Error resolving from module ${module.filePath}: ${\n (error as Error).message\n }\\nExtracted values: ${JSON.stringify(module.exports, null, 2)}`,\n );\n }\n}\n\ntype ParsedFile =\n | { type: \"regular\"; exports: Record<string, ParsedExport>; filePath: string }\n | { type: \"yak\"; exports: Record<string, ParsedExport>; filePath: string };\n\ntype ParsedExport =\n | { type: \"styled-component\" }\n | { type: \"mixin\"; value: string }\n | { type: \"constant\"; value: string | number }\n | { type: \"record\"; value: Record<any, ParsedExport> | {} }\n | { type: \"unsupported\"; hint?: string }\n | { type: \"re-export\"; from: string; imported: string }\n | { type: \"star-export\"; from: string[] };\n\ntype ResolvedExport =\n | { type: \"styled-component\"; from: string; name: string }\n | { type: \"mixin\"; value: string | number }\n | { type: \"constant\"; value: string | number };\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACAzB,OAAO,WAAW;AAClB,OAAO,UAAU;AAEjB,OAAO,iBAAiB;AACxB,SAAS,8BAA8B;AAGvC,IAAM;AAAA;AAAA,EAEJ;AAAA;AAEF,IAAM,mBAAmB,oBAAI,QAK3B;AAEF,IAAM,sBAAsB,CAAC,WAA8B;AACzD,QAAM,cAAc,OAAO;AAC3B,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACA,MAAI,QAAQ,iBAAiB,IAAI,WAAW;AAC5C,MAAI,CAAC,OAAO;AACV,YAAQ;AAAA,MACN,aAAa,oBAAI,IAAI;AAAA,IACvB;AACA,qBAAiB,IAAI,aAAa,KAAK;AAAA,EACzC;AACA,SAAO;AACT;AAqBA,eAAsB,yBACpB,QACA,aACA,KACiB;AAEjB,QAAM,UAAU,CAAC,GAAG,IAAI,SAAS,iBAAiB,CAAC,EAAE,IAAI,CAAC,UAAU;AAClE,UAAM,CAAC,WAAW,kBAAkB,YAAY,SAAS,IAAI;AAC7D,UAAM,CAAC,iBAAiB,GAAG,SAAS,IAAI,iBACrC,MAAM,GAAG,EACT,IAAI,CAAC,UAAU,mBAAmB,KAAK,CAAC;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,MAAM,UAAU;AAAA,IAClB;AAAA,EACF,CAAC;AACD,MAAI,QAAQ,WAAW,EAAG,QAAO;AAEjC,MAAI;AAEF,UAA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,MAAgD;AAClE,MAAI;AAEJ,MAAI,OAAO,SAAS,UAAU;AAC5B,iBAAa;AAAA,EACf,WAAW,gBAAgB,QAAQ;AACjC,iBAAa,KAAK,SAAS,OAAO;AAAA,EACpC,WAAW,gBAAgB,aAAa;AACtC,iBAAa,IAAI,YAAY,OAAO,EAAE,OAAO,IAAI;AAAA,EACnD,OAAO;AACL,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,WAAW,MAAM,wBAAwB;AAC3D,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAM,eAAe,UAAU,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;AAC/C,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAEA,SAAS,kBACP,eACA,cACA;AACA,MACE,CAAC,gBACA,iBAAiB,QAChB,aAAa,UACb,CAAC,aAAa,OAAO,cAAc,YAAY,GACjD;AACA,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,YAAY,iBAAiB,OAAO,OAAO,aAAa;AAC9D,SAAO,CACL,aACA,YACG;AACH,QAAI,gBAAgB,aAAa,cAAc,OAAO;AACpD,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,YACV;AAAA,UACE,cAAc,UAAU;AAAA,UACxB,cAAc;AAAA,QAChB,IACA,cAAc;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/withYak/index.cjs
CHANGED
|
@@ -59,7 +59,7 @@ var addYak = (yakOptions, nextConfig) => {
|
|
|
59
59
|
}
|
|
60
60
|
webpackConfig.module.rules.push({
|
|
61
61
|
test: /\.yak\.module\.css$/,
|
|
62
|
-
loader: import_node_path.default.join(currentDir, "../loaders/css-loader.
|
|
62
|
+
loader: import_node_path.default.join(currentDir, "../loaders/css-loader.js"),
|
|
63
63
|
options: yakOptions
|
|
64
64
|
});
|
|
65
65
|
const yakContext = resolveYakContext(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../withYak/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { NextConfig } from \"../../example/node_modules/next/dist/server/config.js\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { createRequire } from \"module\";\n\nconst currentDir =\n typeof __dirname !== \"undefined\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst { resolve } = createRequire(currentDir + \"/index.js\");\n\nexport type YakConfigOptions = {\n contextPath?: string;\n /**\n * Optional prefix for generated CSS identifiers.\n * This can be used to ensure unique class names across different applications\n * or to add organization-specific prefixes.\n */\n prefix?: string;\n experiments?: {\n debug?:\n | boolean\n | {\n filter?: (path: string) => boolean;\n type: \"all\" | \"ts\" | \"css\" | \"css resolved\";\n };\n };\n};\n\nconst addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {\n const previousConfig = nextConfig.webpack;\n\n nextConfig.experimental ||= {};\n nextConfig.experimental.swcPlugins ||= [];\n nextConfig.experimental.swcPlugins.push([\n resolve(\"yak-swc\"),\n {\n devMode: process.env.NODE_ENV !== \"production\",\n basePath: currentDir,\n prefix: yakOptions.prefix,\n },\n ]);\n\n nextConfig.webpack = (webpackConfig, options) => {\n if (previousConfig) {\n webpackConfig = previousConfig(webpackConfig, options);\n }\n\n webpackConfig.module.rules.push({\n test: /\\.yak\\.module\\.css$/,\n loader: path.join(currentDir, \"../loaders/css-loader.
|
|
1
|
+
{"version":3,"sources":["../../withYak/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { NextConfig } from \"../../example/node_modules/next/dist/server/config.js\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { createRequire } from \"module\";\n\nconst currentDir =\n typeof __dirname !== \"undefined\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst { resolve } = createRequire(currentDir + \"/index.js\");\n\nexport type YakConfigOptions = {\n contextPath?: string;\n /**\n * Optional prefix for generated CSS identifiers.\n * This can be used to ensure unique class names across different applications\n * or to add organization-specific prefixes.\n */\n prefix?: string;\n experiments?: {\n debug?:\n | boolean\n | {\n filter?: (path: string) => boolean;\n type: \"all\" | \"ts\" | \"css\" | \"css resolved\";\n };\n };\n};\n\nconst addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {\n const previousConfig = nextConfig.webpack;\n\n nextConfig.experimental ||= {};\n nextConfig.experimental.swcPlugins ||= [];\n nextConfig.experimental.swcPlugins.push([\n resolve(\"yak-swc\"),\n {\n devMode: process.env.NODE_ENV !== \"production\",\n basePath: currentDir,\n prefix: yakOptions.prefix,\n },\n ]);\n\n nextConfig.webpack = (webpackConfig, options) => {\n if (previousConfig) {\n webpackConfig = previousConfig(webpackConfig, options);\n }\n\n webpackConfig.module.rules.push({\n test: /\\.yak\\.module\\.css$/,\n loader: path.join(currentDir, \"../loaders/css-loader.js\"),\n options: yakOptions,\n });\n\n // With the following alias the internal next-yak code\n // is able to import a context which works for server components\n const yakContext = resolveYakContext(\n yakOptions.contextPath,\n webpackConfig.context || process.cwd(),\n );\n if (yakContext) {\n webpackConfig.resolve.alias[\"next-yak/context/baseContext\"] = yakContext;\n }\n\n return webpackConfig;\n };\n return nextConfig;\n};\n\n/**\n * Try to resolve yak\n */\nfunction resolveYakContext(contextPath: string | undefined, cwd: string) {\n const yakContext = contextPath\n ? path.resolve(cwd, contextPath)\n : path.resolve(cwd, \"yak.context\");\n const extensions = [\"\", \".ts\", \".tsx\", \".js\", \".jsx\"];\n for (const extension in extensions) {\n const fileName = yakContext + extensions[extension];\n if (existsSync(fileName)) {\n return fileName;\n }\n }\n if (contextPath) {\n throw new Error(`Could not find yak context file at ${yakContext}`);\n }\n}\n\n// Wrapper to allow sync, async, and function configuration of Next.js\n/**\n * Add Yak to your Next.js app\n *\n * @usage\n *\n * ```ts\n * // next.config.js\n * const { withYak } = require(\"next-yak/withYak\");\n * const nextConfig = {\n * // your next config here\n * };\n * module.exports = withYak(nextConfig);\n * ```\n *\n * With a custom yakConfig\n *\n * ```ts\n * // next.config.js\n * const { withYak } = require(\"next-yak/withYak\");\n * const nextConfig = {\n * // your next config here\n * };\n * const yakConfig = {\n * // Optional prefix for generated CSS identifiers\n * prefix: \"my-app\",\n * // Other yak config options...\n * };\n * module.exports = withYak(yakConfig, nextConfig);\n * ```\n */\nexport const withYak: {\n <\n T extends\n | Record<string, any>\n | ((...args: any[]) => Record<string, any>)\n | ((...args: any[]) => Promise<Record<string, any>>),\n >(\n yakOptions: YakConfigOptions,\n nextConfig: T,\n ): T;\n // no yakConfig\n <\n T extends\n | Record<string, any>\n | ((...args: any[]) => Record<string, any>)\n | ((...args: any[]) => Promise<Record<string, any>>),\n >(\n nextConfig: T,\n _?: undefined,\n ): T;\n} = (maybeYakOptions, nextConfig) => {\n if (nextConfig === undefined) {\n return withYak({}, maybeYakOptions);\n }\n // If the second parameter is present the first parameter must be a YakConfigOptions\n const yakOptions = maybeYakOptions as YakConfigOptions;\n if (typeof nextConfig === \"function\") {\n /**\n * A NextConfig can be a sync or async function\n * https://nextjs.org/docs/pages/api-reference/next-config-js\n * @param {any[]} args\n */\n return (...args) => {\n /** Dynamic Next Configs can be async or sync */\n const config = nextConfig(...args) as NextConfig | Promise<NextConfig>;\n return config instanceof Promise\n ? config.then((config) => addYak(yakOptions, config))\n : addYak(yakOptions, config);\n };\n }\n return addYak(yakOptions, nextConfig);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAiB;AACjB,sBAA8B;AAC9B,qBAA2B;AAC3B,IAAAA,oBAAwB;AACxB,oBAA8B;AAN9B;AAQA,IAAM,aACJ,OAAO,cAAc,cACjB,gBACA,+BAAQ,+BAAc,YAAY,GAAG,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Ae,QAAW;AAC5B,WAAO,QAAQ,CAAC,GAAG,eAAe;AAAA,EACpC;AAEA,QAAM,aAAa;AACnB,MAAI,OAAO,eAAe,YAAY;AAMpC,WAAO,IAAI,SAAS;AAElB,YAAM,SAAS,WAAW,GAAG,IAAI;AACjC,aAAO,kBAAkB,UACrB,OAAO,KAAK,CAACC,YAAW,OAAO,YAAYA,OAAM,CAAC,IAClD,OAAO,YAAY,MAAM;AAAA,IAC/B;AAAA,EACF;AACA,SAAO,OAAO,YAAY,UAAU;AACtC;","names":["import_node_path","path","config"]}
|
package/dist/withYak/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var addYak = (yakOptions, nextConfig) => {
|
|
|
24
24
|
}
|
|
25
25
|
webpackConfig.module.rules.push({
|
|
26
26
|
test: /\.yak\.module\.css$/,
|
|
27
|
-
loader: path.join(currentDir, "../loaders/css-loader.
|
|
27
|
+
loader: path.join(currentDir, "../loaders/css-loader.js"),
|
|
28
28
|
options: yakOptions
|
|
29
29
|
});
|
|
30
30
|
const yakContext = resolveYakContext(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../withYak/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { NextConfig } from \"../../example/node_modules/next/dist/server/config.js\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { createRequire } from \"module\";\n\nconst currentDir =\n typeof __dirname !== \"undefined\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst { resolve } = createRequire(currentDir + \"/index.js\");\n\nexport type YakConfigOptions = {\n contextPath?: string;\n /**\n * Optional prefix for generated CSS identifiers.\n * This can be used to ensure unique class names across different applications\n * or to add organization-specific prefixes.\n */\n prefix?: string;\n experiments?: {\n debug?:\n | boolean\n | {\n filter?: (path: string) => boolean;\n type: \"all\" | \"ts\" | \"css\" | \"css resolved\";\n };\n };\n};\n\nconst addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {\n const previousConfig = nextConfig.webpack;\n\n nextConfig.experimental ||= {};\n nextConfig.experimental.swcPlugins ||= [];\n nextConfig.experimental.swcPlugins.push([\n resolve(\"yak-swc\"),\n {\n devMode: process.env.NODE_ENV !== \"production\",\n basePath: currentDir,\n prefix: yakOptions.prefix,\n },\n ]);\n\n nextConfig.webpack = (webpackConfig, options) => {\n if (previousConfig) {\n webpackConfig = previousConfig(webpackConfig, options);\n }\n\n webpackConfig.module.rules.push({\n test: /\\.yak\\.module\\.css$/,\n loader: path.join(currentDir, \"../loaders/css-loader.
|
|
1
|
+
{"version":3,"sources":["../../withYak/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { NextConfig } from \"../../example/node_modules/next/dist/server/config.js\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { createRequire } from \"module\";\n\nconst currentDir =\n typeof __dirname !== \"undefined\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst { resolve } = createRequire(currentDir + \"/index.js\");\n\nexport type YakConfigOptions = {\n contextPath?: string;\n /**\n * Optional prefix for generated CSS identifiers.\n * This can be used to ensure unique class names across different applications\n * or to add organization-specific prefixes.\n */\n prefix?: string;\n experiments?: {\n debug?:\n | boolean\n | {\n filter?: (path: string) => boolean;\n type: \"all\" | \"ts\" | \"css\" | \"css resolved\";\n };\n };\n};\n\nconst addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {\n const previousConfig = nextConfig.webpack;\n\n nextConfig.experimental ||= {};\n nextConfig.experimental.swcPlugins ||= [];\n nextConfig.experimental.swcPlugins.push([\n resolve(\"yak-swc\"),\n {\n devMode: process.env.NODE_ENV !== \"production\",\n basePath: currentDir,\n prefix: yakOptions.prefix,\n },\n ]);\n\n nextConfig.webpack = (webpackConfig, options) => {\n if (previousConfig) {\n webpackConfig = previousConfig(webpackConfig, options);\n }\n\n webpackConfig.module.rules.push({\n test: /\\.yak\\.module\\.css$/,\n loader: path.join(currentDir, \"../loaders/css-loader.js\"),\n options: yakOptions,\n });\n\n // With the following alias the internal next-yak code\n // is able to import a context which works for server components\n const yakContext = resolveYakContext(\n yakOptions.contextPath,\n webpackConfig.context || process.cwd(),\n );\n if (yakContext) {\n webpackConfig.resolve.alias[\"next-yak/context/baseContext\"] = yakContext;\n }\n\n return webpackConfig;\n };\n return nextConfig;\n};\n\n/**\n * Try to resolve yak\n */\nfunction resolveYakContext(contextPath: string | undefined, cwd: string) {\n const yakContext = contextPath\n ? path.resolve(cwd, contextPath)\n : path.resolve(cwd, \"yak.context\");\n const extensions = [\"\", \".ts\", \".tsx\", \".js\", \".jsx\"];\n for (const extension in extensions) {\n const fileName = yakContext + extensions[extension];\n if (existsSync(fileName)) {\n return fileName;\n }\n }\n if (contextPath) {\n throw new Error(`Could not find yak context file at ${yakContext}`);\n }\n}\n\n// Wrapper to allow sync, async, and function configuration of Next.js\n/**\n * Add Yak to your Next.js app\n *\n * @usage\n *\n * ```ts\n * // next.config.js\n * const { withYak } = require(\"next-yak/withYak\");\n * const nextConfig = {\n * // your next config here\n * };\n * module.exports = withYak(nextConfig);\n * ```\n *\n * With a custom yakConfig\n *\n * ```ts\n * // next.config.js\n * const { withYak } = require(\"next-yak/withYak\");\n * const nextConfig = {\n * // your next config here\n * };\n * const yakConfig = {\n * // Optional prefix for generated CSS identifiers\n * prefix: \"my-app\",\n * // Other yak config options...\n * };\n * module.exports = withYak(yakConfig, nextConfig);\n * ```\n */\nexport const withYak: {\n <\n T extends\n | Record<string, any>\n | ((...args: any[]) => Record<string, any>)\n | ((...args: any[]) => Promise<Record<string, any>>),\n >(\n yakOptions: YakConfigOptions,\n nextConfig: T,\n ): T;\n // no yakConfig\n <\n T extends\n | Record<string, any>\n | ((...args: any[]) => Record<string, any>)\n | ((...args: any[]) => Promise<Record<string, any>>),\n >(\n nextConfig: T,\n _?: undefined,\n ): T;\n} = (maybeYakOptions, nextConfig) => {\n if (nextConfig === undefined) {\n return withYak({}, maybeYakOptions);\n }\n // If the second parameter is present the first parameter must be a YakConfigOptions\n const yakOptions = maybeYakOptions as YakConfigOptions;\n if (typeof nextConfig === \"function\") {\n /**\n * A NextConfig can be a sync or async function\n * https://nextjs.org/docs/pages/api-reference/next-config-js\n * @param {any[]} args\n */\n return (...args) => {\n /** Dynamic Next Configs can be async or sync */\n const config = nextConfig(...args) as NextConfig | Promise<NextConfig>;\n return config instanceof Promise\n ? config.then((config) => addYak(yakOptions, config))\n : addYak(yakOptions, config);\n };\n }\n return addYak(yakOptions, nextConfig);\n};\n"],"mappings":";AAEA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAE9B,IAAM,aACJ,OAAO,cAAc,cACjB,YACA,QAAQ,cAAc,YAAY,GAAG,CAAC;AAE5C,IAAM,EAAE,QAAQ,IAAI,cAAc,aAAa,WAAW;AAoB1D,IAAM,SAAS,CAAC,YAA8B,eAA2B;AACvE,QAAM,iBAAiB,WAAW;AAElC,aAAW,iBAAiB,CAAC;AAC7B,aAAW,aAAa,eAAe,CAAC;AACxC,aAAW,aAAa,WAAW,KAAK;AAAA,IACtC,QAAQ,SAAS;AAAA,IACjB;AAAA,MACE,SAAS,QAAQ,IAAI,aAAa;AAAA,MAClC,UAAU;AAAA,MACV,QAAQ,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAED,aAAW,UAAU,CAAC,eAAe,YAAY;AAC/C,QAAI,gBAAgB;AAClB,sBAAgB,eAAe,eAAe,OAAO;AAAA,IACvD;AAEA,kBAAc,OAAO,MAAM,KAAK;AAAA,MAC9B,MAAM;AAAA,MACN,QAAQ,KAAK,KAAK,YAAY,0BAA0B;AAAA,MACxD,SAAS;AAAA,IACX,CAAC;AAID,UAAM,aAAa;AAAA,MACjB,WAAW;AAAA,MACX,cAAc,WAAW,QAAQ,IAAI;AAAA,IACvC;AACA,QAAI,YAAY;AACd,oBAAc,QAAQ,MAAM,8BAA8B,IAAI;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAKA,SAAS,kBAAkB,aAAiC,KAAa;AACvE,QAAM,aAAa,cACf,KAAK,QAAQ,KAAK,WAAW,IAC7B,KAAK,QAAQ,KAAK,aAAa;AACnC,QAAM,aAAa,CAAC,IAAI,OAAO,QAAQ,OAAO,MAAM;AACpD,aAAW,aAAa,YAAY;AAClC,UAAM,WAAW,aAAa,WAAW,SAAS;AAClD,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACA,MAAI,aAAa;AACf,UAAM,IAAI,MAAM,sCAAsC,UAAU,EAAE;AAAA,EACpE;AACF;AAiCO,IAAM,UAoBT,CAAC,iBAAiB,eAAe;AACnC,MAAI,eAAe,QAAW;AAC5B,WAAO,QAAQ,CAAC,GAAG,eAAe;AAAA,EACpC;AAEA,QAAM,aAAa;AACnB,MAAI,OAAO,eAAe,YAAY;AAMpC,WAAO,IAAI,SAAS;AAElB,YAAM,SAAS,WAAW,GAAG,IAAI;AACjC,aAAO,kBAAkB,UACrB,OAAO,KAAK,CAACA,YAAW,OAAO,YAAYA,OAAM,CAAC,IAClD,OAAO,YAAY,MAAM;AAAA,IAC/B;AAAA,EACF;AACA,SAAO,OAAO,YAAY,UAAU;AACtC;","names":["config"]}
|
package/loaders/css-loader.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { resolveCrossFileConstant } from "./lib/resolveCrossFileSelectors.js";
|
|
|
12
12
|
export default async function cssExtractLoader(
|
|
13
13
|
this: LoaderContext<YakConfigOptions>,
|
|
14
14
|
// Instead of the source code, we receive the extracted css
|
|
15
|
-
// from the
|
|
15
|
+
// from the yak-swc transformation
|
|
16
16
|
_code: string,
|
|
17
17
|
sourceMap: string | undefined,
|
|
18
18
|
): Promise<string | void> {
|
|
@@ -11,9 +11,26 @@ const yakCssImportRegex =
|
|
|
11
11
|
|
|
12
12
|
const compilationCache = new WeakMap<
|
|
13
13
|
Compilation,
|
|
14
|
-
|
|
14
|
+
{
|
|
15
|
+
parsedFiles: Map<string, ParsedFile>;
|
|
16
|
+
}
|
|
15
17
|
>();
|
|
16
18
|
|
|
19
|
+
const getCompilationCache = (loader: LoaderContext<{}>) => {
|
|
20
|
+
const compilation = loader._compilation;
|
|
21
|
+
if (!compilation) {
|
|
22
|
+
throw new Error("Webpack compilation object not available");
|
|
23
|
+
}
|
|
24
|
+
let cache = compilationCache.get(compilation);
|
|
25
|
+
if (!cache) {
|
|
26
|
+
cache = {
|
|
27
|
+
parsedFiles: new Map(),
|
|
28
|
+
};
|
|
29
|
+
compilationCache.set(compilation, cache);
|
|
30
|
+
}
|
|
31
|
+
return cache;
|
|
32
|
+
};
|
|
33
|
+
|
|
17
34
|
/**
|
|
18
35
|
* Resolves cross-file selectors in css files
|
|
19
36
|
*
|
|
@@ -58,29 +75,20 @@ export async function resolveCrossFileConstant(
|
|
|
58
75
|
|
|
59
76
|
try {
|
|
60
77
|
// Resolve all imports concurrently
|
|
61
|
-
const exportCache = new Map<string, Promise<ResolvedExport>>();
|
|
62
78
|
const resolvedValues = await Promise.all(
|
|
63
|
-
matches.map(({ moduleSpecifier, specifier
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
loader,
|
|
77
|
-
parsedModule,
|
|
78
|
-
specifier,
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
if (!resolvedFromCache) {
|
|
82
|
-
exportCache.set(encodedArguments, resolvedValue);
|
|
83
|
-
}
|
|
79
|
+
matches.map(async ({ moduleSpecifier, specifier }) => {
|
|
80
|
+
const parsedModule = await parseModule(
|
|
81
|
+
loader,
|
|
82
|
+
moduleSpecifier,
|
|
83
|
+
pathContext,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const resolvedValue = await resolveModuleSpecifierRecursively(
|
|
87
|
+
loader,
|
|
88
|
+
parsedModule,
|
|
89
|
+
specifier,
|
|
90
|
+
);
|
|
91
|
+
|
|
84
92
|
return resolvedValue;
|
|
85
93
|
}),
|
|
86
94
|
);
|
|
@@ -140,6 +148,24 @@ export async function resolveCrossFileConstant(
|
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Resolves a module by wrapping loader.resolve in a promise
|
|
153
|
+
*/
|
|
154
|
+
export async function resolveModule(
|
|
155
|
+
loader: LoaderContext<{}>,
|
|
156
|
+
moduleSpecifier: string,
|
|
157
|
+
context: string,
|
|
158
|
+
): Promise<string> {
|
|
159
|
+
return new Promise<string>((resolve, reject) => {
|
|
160
|
+
loader.resolve(context, moduleSpecifier, (err, result) => {
|
|
161
|
+
if (err) return reject(err);
|
|
162
|
+
if (!result)
|
|
163
|
+
return reject(new Error(`Could not resolve ${moduleSpecifier}`));
|
|
164
|
+
resolve(result);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
143
169
|
/**
|
|
144
170
|
* Resolves a module specifier to a parsed file
|
|
145
171
|
*
|
|
@@ -154,36 +180,24 @@ async function parseModule(
|
|
|
154
180
|
moduleSpecifier: string,
|
|
155
181
|
context: string,
|
|
156
182
|
): Promise<ParsedFile> {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
throw new Error("Webpack compilation object not available");
|
|
160
|
-
}
|
|
161
|
-
let cache = compilationCache.get(compilation);
|
|
162
|
-
if (!cache) {
|
|
163
|
-
cache = new Map();
|
|
164
|
-
compilationCache.set(compilation, cache);
|
|
165
|
-
}
|
|
183
|
+
const cache = getCompilationCache(loader).parsedFiles;
|
|
184
|
+
|
|
166
185
|
// The cache key is valid for the entire project so it can be reused
|
|
167
186
|
// for different source files
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
return parseFile(loader, resolved);
|
|
181
|
-
})();
|
|
182
|
-
cache.set(cacheKey, filePromise);
|
|
187
|
+
const resolvedModule = await resolveModule(loader, moduleSpecifier, context);
|
|
188
|
+
|
|
189
|
+
let parsedFile = cache.get(resolvedModule);
|
|
190
|
+
if (!parsedFile) {
|
|
191
|
+
parsedFile = await parseFile(loader, resolvedModule);
|
|
192
|
+
|
|
193
|
+
// We cache the parsed file to avoid re-parsing it.
|
|
194
|
+
// It's ok, that initial parallel requests to the same file will parse it multiple times.
|
|
195
|
+
// This avoid deadlocks do to the fact that we load multiple modules in the chain for cross file references.
|
|
196
|
+
cache.set(resolvedModule, parsedFile);
|
|
183
197
|
}
|
|
184
198
|
// on file change, invalidate the cache
|
|
185
|
-
loader.addDependency(
|
|
186
|
-
return
|
|
199
|
+
loader.addDependency(parsedFile.filePath);
|
|
200
|
+
return parsedFile;
|
|
187
201
|
}
|
|
188
202
|
|
|
189
203
|
async function parseFile(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-yak",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -60,14 +60,12 @@
|
|
|
60
60
|
"require": "./dist/jsx-dev-runtime.cjs",
|
|
61
61
|
"import": "./dist/jsx-dev-runtime.js"
|
|
62
62
|
},
|
|
63
|
-
"./loaders/css-loader":
|
|
64
|
-
"require": "./dist/loaders/css-loader.cjs"
|
|
65
|
-
}
|
|
63
|
+
"./loaders/css-loader": "./dist/loaders/css-loader.js"
|
|
66
64
|
},
|
|
67
65
|
"dependencies": {
|
|
68
66
|
"@babel/core": "7.26.0",
|
|
69
67
|
"@babel/plugin-syntax-typescript": "7.25.9",
|
|
70
|
-
"yak-swc": "
|
|
68
|
+
"yak-swc": "5.0.0"
|
|
71
69
|
},
|
|
72
70
|
"devDependencies": {
|
|
73
71
|
"@types/babel__core": "7.20.5",
|
|
@@ -81,7 +79,7 @@
|
|
|
81
79
|
"@types/react-dom": "19.0.2",
|
|
82
80
|
"fast-glob": "3.3.2",
|
|
83
81
|
"jsdom": "25.0.1",
|
|
84
|
-
"next": "15.1
|
|
82
|
+
"next": "15.2.1",
|
|
85
83
|
"react": "19.0.0",
|
|
86
84
|
"typescript": "5.7.2",
|
|
87
85
|
"vite": "6.0.6",
|
package/withYak/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ const addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {
|
|
|
52
52
|
|
|
53
53
|
webpackConfig.module.rules.push({
|
|
54
54
|
test: /\.yak\.module\.css$/,
|
|
55
|
-
loader: path.join(currentDir, "../loaders/css-loader.
|
|
55
|
+
loader: path.join(currentDir, "../loaders/css-loader.js"),
|
|
56
56
|
options: yakOptions,
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../loaders/css-loader.ts","../../loaders/lib/resolveCrossFileSelectors.ts"],"sourcesContent":["import { relative } from \"path\";\nimport type { LoaderContext } from \"webpack\";\nimport type { YakConfigOptions } from \"../withYak/index.js\";\nimport { resolveCrossFileConstant } from \"./lib/resolveCrossFileSelectors.js\";\n\n/**\n * Transform typescript to css\n *\n * This loader takes the cached result from the yak tsloader\n * and extracts the css from the generated comments\n */\nexport default async function cssExtractLoader(\n this: LoaderContext<YakConfigOptions>,\n // Instead of the source code, we receive the extracted css\n // from the ts-loader transformation\n _code: string,\n sourceMap: string | undefined,\n): Promise<string | void> {\n const callback = this.async();\n // Load the module from the original typescript request (without !=! and the query)\n return this.loadModule(this.resourcePath, (err, source) => {\n if (err) {\n return callback(err);\n }\n if (!source) {\n return callback(\n new Error(`Source code for ${this.resourcePath} is empty`),\n );\n }\n const { experiments } = this.getOptions();\n const debugLog = createDebugLogger(this, experiments?.debug);\n\n debugLog(\"ts\", source);\n const css = extractCss(source);\n debugLog(\"css\", css);\n\n return resolveCrossFileConstant(this, this.context, css).then((result) => {\n debugLog(\"css resolved\", css);\n return callback(null, result, sourceMap);\n }, callback);\n });\n}\n\nfunction extractCss(code: string | Buffer<ArrayBufferLike>): 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 return result;\n}\n\nfunction createDebugLogger(\n loaderContext: LoaderContext<YakConfigOptions>,\n debugOptions: Required<YakConfigOptions>[\"experiments\"][\"debug\"],\n) {\n if (\n !debugOptions ||\n (debugOptions !== true &&\n debugOptions.filter &&\n !debugOptions.filter(loaderContext.resourcePath))\n ) {\n return () => {};\n }\n const debugType = debugOptions === true ? \"ts\" : debugOptions.type;\n return (\n messageType: \"ts\" | \"css\" | \"css resolved\",\n message: string | Buffer<ArrayBufferLike> | undefined,\n ) => {\n if (messageType === debugType || debugType === \"all\") {\n console.log(\n \"🐮 Yak\",\n messageType,\n \"\\n\",\n loaderContext._compiler\n ? relative(\n loaderContext._compiler.context,\n loaderContext.resourcePath,\n )\n : loaderContext.resourcePath,\n \"\\n\\n\",\n message,\n );\n }\n };\n}\n","import babel from \"@babel/core\";\nimport path from \"path\";\n// @ts-expect-error - this is used by babel directly so we ignore that it is not typed\nimport babelPlugin from \"@babel/plugin-syntax-typescript\";\nimport { getCssModuleLocalIdent } from \"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js\";\nimport type { Compilation, LoaderContext } from \"webpack\";\n\nconst yakCssImportRegex =\n // Make mixin and selector non optional once we dropped support for the babel plugin\n /--yak-css-import\\:\\s*url\\(\"([^\"]+)\",?(|mixin|selector)\\)(;?)/g;\n\nconst compilationCache = new WeakMap<\n Compilation,\n Map<string, Promise<ParsedFile>>\n>();\n\n/**\n * Resolves cross-file selectors in css files\n *\n * e.g.:\n * theme.ts:\n * ```ts\n * export const colors = {\n * primary: \"#ff0000\",\n * secondary: \"#00ff00\",\n * };\n * ```\n *\n * styles.ts:\n * ```ts\n * import { colors } from \"./theme\";\n * export const button = css`\n * background-color: ${colors.primary};\n * `;\n */\nexport async function resolveCrossFileConstant(\n loader: LoaderContext<{}>,\n pathContext: string,\n css: string,\n): Promise<string> {\n // Search for --yak-css-import: url(\"path/to/module\") in the css\n const matches = [...css.matchAll(yakCssImportRegex)].map((match) => {\n const [fullMatch, encodedArguments, importKind, semicolon] = match;\n const [moduleSpecifier, ...specifier] = encodedArguments\n .split(\":\")\n .map((entry) => decodeURIComponent(entry));\n return {\n encodedArguments,\n moduleSpecifier,\n specifier,\n importKind,\n semicolon,\n position: match.index!,\n size: fullMatch.length,\n };\n });\n if (matches.length === 0) return css;\n\n try {\n // Resolve all imports concurrently\n const exportCache = new Map<string, Promise<ResolvedExport>>();\n const resolvedValues = await Promise.all(\n matches.map(({ moduleSpecifier, specifier, encodedArguments }) => {\n // The cache prevents resolving the same specifier multiple times\n // e.g.:\n // const a = css`\n // color: ${colors.primary};\n // border-color: ${colors.primary};\n // `;\n const resolvedFromCache = exportCache.get(encodedArguments);\n const resolvedValue =\n resolvedFromCache ||\n parseModule(loader, moduleSpecifier, pathContext).then(\n (parsedModule) =>\n resolveModuleSpecifierRecursively(\n loader,\n parsedModule,\n specifier,\n ),\n );\n if (!resolvedFromCache) {\n exportCache.set(encodedArguments, resolvedValue);\n }\n return resolvedValue;\n }),\n );\n\n // Replace the imports with the resolved values\n let result = css;\n for (let i = matches.length - 1; i >= 0; i--) {\n const { position, size, importKind, specifier, semicolon } = matches[i];\n const resolved = resolvedValues[i];\n\n if (importKind === \"selector\") {\n if (resolved.type === \"mixin\") {\n throw new Error(\n `Found mixin but expected a selector - did you forget a semicolon after \\`${specifier.join(\n \".\",\n )}\\`?`,\n );\n }\n }\n\n const replacement =\n resolved.type === \"styled-component\"\n ? `:global(.${getCssModuleLocalIdent(\n {\n rootContext: loader.rootContext,\n resourcePath: resolved.from,\n },\n null,\n resolved.name,\n {},\n )})`\n : resolved.value +\n // resolved.value can be of two different types:\n // - mixin:\n // ${mixinName};\n // - constant:\n // color: ${value};\n // For mixins the semicolon is already included in the value\n // but for constants it has to be added manually\n ([\"}\", \";\"].includes(String(resolved.value).trimEnd().slice(-1))\n ? \"\"\n : semicolon);\n\n result =\n result.slice(0, position) +\n String(replacement) +\n result.slice(position + size);\n }\n\n return result;\n } catch (error) {\n throw new Error(\n `Error resolving cross-file selectors: ${\n (error as Error).message\n }\\nFile: ${loader.resourcePath}`,\n );\n }\n}\n\n/**\n * Resolves a module specifier to a parsed file\n *\n * e.g.:\n * ```\n * parseModule(loader, \"./theme\", \"/path/to/styles.ts\")\n * // -> { type: 'regular', secondary: { type: 'constant', value: '#00ff00' } } }, filePath: '/path/to/theme.ts' }\n * ```\n */\nasync function parseModule(\n loader: LoaderContext<{}>,\n moduleSpecifier: string,\n context: string,\n): Promise<ParsedFile> {\n const compilation = loader._compilation;\n if (!compilation) {\n throw new Error(\"Webpack compilation object not available\");\n }\n let cache = compilationCache.get(compilation);\n if (!cache) {\n cache = new Map();\n compilationCache.set(compilation, cache);\n }\n // The cache key is valid for the entire project so it can be reused\n // for different source files\n const cacheKey = path.resolve(context, moduleSpecifier);\n let filePromise = cache.get(cacheKey);\n if (!filePromise) {\n filePromise = (async () => {\n const resolved = await new Promise<string>((resolve, reject) => {\n loader.resolve(context, moduleSpecifier, (err, result) => {\n if (err) return reject(err);\n if (!result)\n return reject(new Error(`Could not resolve ${moduleSpecifier}`));\n resolve(result);\n });\n });\n return parseFile(loader, resolved);\n })();\n cache.set(cacheKey, filePromise);\n }\n // on file change, invalidate the cache\n loader.addDependency((await filePromise).filePath);\n return filePromise;\n}\n\nasync function parseFile(\n loader: LoaderContext<{}>,\n filePath: string,\n): Promise<ParsedFile> {\n const isYak =\n filePath.endsWith(\".yak.ts\") ||\n filePath.endsWith(\".yak.tsx\") ||\n filePath.endsWith(\".yak.js\") ||\n filePath.endsWith(\".yak.jsx\");\n const isTSX = filePath.endsWith(\".tsx\");\n\n try {\n if (isYak) {\n const module: Record<string, unknown> =\n await loader.importModule(filePath);\n const mappedModule = Object.fromEntries(\n Object.entries(module).map(([key, value]): [string, ParsedExport] => {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return [key, { type: \"constant\" as const, value }];\n } else if (\n value &&\n (typeof value === \"object\" || Array.isArray(value))\n ) {\n return [key, { type: \"record\" as const, value }];\n } else {\n return [key, { type: \"unsupported\" as const, hint: String(value) }];\n }\n }),\n );\n return { type: \"yak\", exports: mappedModule, filePath };\n }\n const sourceContents = new Promise<string>((resolve, reject) =>\n loader.fs.readFile(filePath, \"utf-8\", (err, result) => {\n if (err) return reject(err);\n resolve(result || \"\");\n }),\n );\n\n const tranformedSource = new Promise<string>((resolve, reject) => {\n loader.loadModule(filePath, (err, source) => {\n if (err) return reject(err);\n 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\n const exports = await parseExports(await sourceContents, isTSX);\n const mixins = parseMixins(await tranformedSource);\n\n // Recursively resolve cross-file constants in mixins\n // e.g. cross file mixins inside a cross file mixin\n // or a cross file selector inside a cross file mixin\n await Promise.all(\n Object.entries(mixins).map(async ([name, { value, nameParts }]) => {\n const resolvedValue = await resolveCrossFileConstant(\n loader,\n path.dirname(filePath),\n value,\n );\n if (nameParts.length === 1) {\n exports[name] = { type: \"mixin\", value: resolvedValue };\n } else {\n let exportEntry: undefined | ParsedExport = exports[nameParts[0]];\n if (!exportEntry) {\n exportEntry = { type: \"record\", value: {} };\n exports[nameParts[0]] = exportEntry;\n } else if (exportEntry.type !== \"record\") {\n throw new Error(\n `Error parsing file ${filePath}: ${nameParts[0]} is not a record`,\n );\n }\n let current = exportEntry.value as Record<any, ParsedExport>;\n for (let i = 1; i < nameParts.length - 1; i++) {\n let next = current[nameParts[i]];\n if (!next) {\n next = { type: \"record\", value: {} };\n current[nameParts[i]] = next;\n } else if (next.type !== \"record\") {\n throw new Error(\n `Error parsing file ${filePath}: ${nameParts[i]} is not a record`,\n );\n }\n current = next.value;\n }\n current[nameParts[nameParts.length - 1]] = {\n type: \"mixin\",\n value: resolvedValue,\n };\n }\n }),\n );\n\n return {\n type: \"regular\",\n exports,\n filePath,\n };\n } catch (error) {\n throw new Error(\n `Error parsing file ${filePath}: ${(error as Error).message}`,\n );\n }\n}\n\nasync function parseExports(\n sourceContents: string,\n isTSX: boolean,\n): Promise<Record<string, ParsedExport>> {\n let exports: Record<string, ParsedExport> = {};\n\n try {\n babel.transformSync(sourceContents, {\n configFile: false,\n plugins: [\n [babelPlugin, { isTSX }],\n [\n (): babel.PluginObj => ({\n visitor: {\n ExportNamedDeclaration({ node }) {\n if (node.source) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === \"ExportSpecifier\" &&\n specifier.exported.type === \"Identifier\" &&\n specifier.local.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"re-export\",\n from: node.source!.value,\n imported: specifier.local.name,\n };\n }\n });\n } else if (node.declaration?.type === \"VariableDeclaration\") {\n node.declaration.declarations.forEach((declaration) => {\n if (\n declaration.id.type === \"Identifier\" &&\n declaration.init\n ) {\n exports[declaration.id.name] = parseExportValueExpression(\n declaration.init,\n );\n }\n });\n }\n },\n ExportDeclaration({ node }) {\n if (\"specifiers\" in node && node.source) {\n const { specifiers, source } = node;\n specifiers.forEach((specifier) => {\n // export * as color from \"./colors\";\n if (\n specifier.type === \"ExportNamespaceSpecifier\" &&\n specifier.exported.type === \"Identifier\"\n ) {\n exports[specifier.exported.name] = {\n type: \"star-export\",\n from: [source.value],\n };\n }\n });\n }\n },\n ExportAllDeclaration({ node }) {\n if (Object.keys(exports).length === 0) {\n exports[\"*\"] ||= {\n type: \"star-export\",\n from: [],\n };\n if (exports[\"*\"].type !== \"star-export\") {\n throw new Error(\"Invalid star export state\");\n }\n exports[\"*\"].from.push(node.source.value);\n }\n },\n },\n }),\n ],\n ],\n });\n\n return exports;\n } catch (error) {\n throw new Error(`Error parsing exports: ${(error as Error).message}`);\n }\n}\n\nfunction parseMixins(\n sourceContents: string,\n): Record<string, { type: \"mixin\"; value: string; nameParts: string[] }> {\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\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): ParsedExport {\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: \"styled-component\" };\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, ParsedExport> {\n let result: Record<string, ParsedExport> = {};\n for (const property of node.properties) {\n if (\n property.type === \"ObjectProperty\" &&\n property.key.type === \"Identifier\"\n ) {\n const key = property.key.name;\n result[key] = parseExportValueExpression(\n property.value as babel.types.Expression,\n );\n }\n }\n return result;\n}\n\n/**\n * Follows a specifier recursively until it finds its constant value\n * for example here it follows \"colors.primary\"\n *\n * ```\n * resolveModuleSpecifierRecursively(loader, \"@/theme\", [\"colors\", \"primary\"], \"colors:primary\")`\n * // -> { type: 'constant', value: '#ff0000' }\n * ```\n *\n * example structure:\n *\n * styles.ts:\n * ```\n * import { colors } from \"@/theme\";\n * export const button = css`color: ${colors.primary}`;\n * ```\n *\n * theme.ts:\n * ```\n * export { colors } from \"./colors\";\n * ```\n *\n * colors.ts:\n * ```\n * export const colors = { primary: \"#ff0000\" };\n * ```\n *\n */\nasync function resolveModuleSpecifierRecursively(\n loader: LoaderContext<{}>,\n module: ParsedFile,\n specifier: string[],\n): Promise<ResolvedExport> {\n try {\n const exportName = specifier[0];\n let exportValue = module.exports[exportName];\n // Follow star exports if there is only a single one\n // and the export does not exist in the current module\n if (exportValue === undefined) {\n const starExport = module.exports[\"*\"];\n if (starExport?.type === \"star-export\") {\n if (starExport.from.length > 1) {\n throw new Error(\n `Could not resolve ${specifier.join(\".\")} in module ${\n module.filePath\n } - Multiple star exports are not supported for performance reasons`,\n );\n }\n exportValue = {\n type: \"re-export\" as const,\n from: starExport.from[0],\n imported: exportName,\n };\n } else {\n throw new Error(\n `Could not resolve \"${specifier.join(\".\")}\" in module ${\n module.filePath\n }`,\n );\n }\n }\n // Follow reexport\n // e.g. export { colors as primaryColors } from \"./colors\";\n if (exportValue.type === \"re-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from,\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(loader, importedModule, [\n exportValue.imported,\n ...specifier.slice(1),\n ]);\n }\n // Namespace export\n // e.g. export * as colors from \"./colors\";\n else if (exportValue.type === \"star-export\") {\n const importedModule = await parseModule(\n loader,\n exportValue.from[0],\n path.dirname(module.filePath),\n );\n return resolveModuleSpecifierRecursively(\n loader,\n importedModule,\n specifier.slice(1),\n );\n }\n\n if (exportValue.type === \"styled-component\") {\n return {\n type: \"styled-component\",\n from: module.filePath,\n name: specifier[specifier.length - 1],\n };\n } else if (exportValue.type === \"constant\") {\n return { type: \"constant\", value: exportValue.value };\n } else if (exportValue.type === \"record\") {\n let current: any = exportValue.value;\n let depth = 0;\n /// Drill down the specifier e.g. colors.primary\n do {\n if (typeof current === \"string\" || typeof current === \"number\") {\n return {\n type: \"constant\" as const,\n value: current,\n };\n } else if (\n !current ||\n (typeof current !== \"object\" && !Array.isArray(current))\n ) {\n throw new Error(\n `Error unpacking Record/Array \"${exportName}\".\\nKey \"${\n specifier[depth]\n }\" was of type \"${typeof current}\" but only String and Number are supported`,\n );\n }\n depth++;\n // mixins in .yak files are wrapped inside an object with a __yak key\n if (depth === specifier.length && \"__yak\" in current) {\n return { type: \"mixin\", value: current[\"__yak\"] };\n } else if (depth === specifier.length && \"value\" in current) {\n return { type: \"constant\", value: current[\"value\"] };\n } else {\n current = current[specifier[depth]];\n }\n } while (current);\n if (specifier[depth] === undefined) {\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${specifier\n .slice(0, depth)\n .join(\".\")}\\` is not a string or number`,\n );\n }\n throw new Error(\n `Error unpacking Record/Array - could not extract \\`${\n specifier[depth]\n }\\` from \\`${specifier.slice(0, depth).join(\".\")}\\``,\n );\n } else if (exportValue.type === \"mixin\") {\n return { type: \"mixin\", value: exportValue.value };\n }\n throw new Error(\n `Error unpacking Record/Array - unexpected exportValue \"${\n exportValue.type\n }\" for specifier \"${specifier.join(\".\")}\"`,\n );\n } catch (error) {\n throw new Error(\n `Error resolving from module ${module.filePath}: ${\n (error as Error).message\n }\\nExtracted values: ${JSON.stringify(module.exports, null, 2)}`,\n );\n }\n}\n\ntype ParsedFile =\n | { type: \"regular\"; exports: Record<string, ParsedExport>; filePath: string }\n | { type: \"yak\"; exports: Record<string, ParsedExport>; filePath: string };\n\ntype ParsedExport =\n | { type: \"styled-component\" }\n | { type: \"mixin\"; value: string }\n | { type: \"constant\"; value: string | number }\n | { type: \"record\"; value: Record<any, ParsedExport> | {} }\n | { type: \"unsupported\"; hint?: string }\n | { type: \"re-export\"; from: string; imported: string }\n | { type: \"star-export\"; from: string[] };\n\ntype ResolvedExport =\n | { type: \"styled-component\"; from: string; name: string }\n | { type: \"mixin\"; value: string | number }\n | { type: \"constant\"; value: string | number };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAyB;;;ACAzB,kBAAkB;AAClB,kBAAiB;AAEjB,sCAAwB;AACxB,oCAAuC;AAGvC,IAAM;AAAA;AAAA,EAEJ;AAAA;AAEF,IAAM,mBAAmB,oBAAI,QAG3B;AAqBF,eAAsB,yBACpB,QACA,aACA,KACiB;AAEjB,QAAM,UAAU,CAAC,GAAG,IAAI,SAAS,iBAAiB,CAAC,EAAE,IAAI,CAAC,UAAU;AAClE,UAAM,CAAC,W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AAE,CAAC;AAC/C,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAEA,SAAS,kBACP,eACA,cACA;AACA,MACE,CAAC,gBACA,iBAAiB,QAChB,aAAa,UACb,CAAC,aAAa,OAAO,cAAc,YAAY,GACjD;AACA,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,YAAY,iBAAiB,OAAO,OAAO,aAAa;AAC9D,SAAO,CACL,aACA,YACG;AACH,QAAI,gBAAgB,aAAa,cAAc,OAAO;AACpD,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,gBACV;AAAA,UACE,cAAc,UAAU;AAAA,UACxB,cAAc;AAAA,QAChB,IACA,cAAc;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_path","path","module","exports","babel","babelPlugin"]}
|
|
File without changes
|