@yak/react 10.0.0-rc.0 → 10.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/context/baseContext.d.ts +1 -2
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.server.d.ts +2 -3
- package/dist/cross-file-resolver/index.d.ts +12 -12
- package/dist/cross-file-resolver/index.js +58 -5
- package/dist/cross-file-resolver/index.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +139 -139
- package/dist/isolated-source-eval/index.d.ts +2 -2
- package/dist/isolated-source-eval/index.js +2 -2
- package/dist/isolated-source-eval/index.js.map +1 -1
- package/dist/isolated-source-eval/worker.js +4 -1
- package/dist/isolated-source-eval/worker.js.map +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/loaders/{turbo-loader.d.cts → turbo-loader.d.ts} +11 -3
- package/dist/loaders/{turbo-loader.cjs → turbo-loader.js} +81 -49
- package/dist/loaders/turbo-loader.js.map +1 -0
- package/dist/loaders/vite-plugin.d.ts +15 -25
- package/dist/loaders/vite-plugin.js +95 -67
- package/dist/loaders/vite-plugin.js.map +1 -1
- package/dist/loaders/{webpack-loader.d.cts → webpack-loader.d.ts} +3 -3
- package/dist/loaders/{webpack-loader.cjs → webpack-loader.js} +69 -37
- package/dist/loaders/webpack-loader.js.map +1 -0
- package/dist/rsbuild/index.d.ts +2 -2
- package/dist/rsbuild/index.js +3 -3
- package/dist/rsbuild/index.js.map +1 -1
- package/dist/static/index.js +1 -1
- package/dist/static/index.js.map +1 -1
- package/dist/withYak/index.d.ts +15 -24
- package/dist/withYak/index.js +8 -14
- package/dist/withYak/index.js.map +1 -1
- package/loaders/lib/resolveCrossFileSelectors.ts +0 -1
- package/loaders/turbo-loader.ts +32 -11
- package/loaders/webpack-loader.ts +3 -6
- package/package.json +47 -106
- package/rsbuild/index.ts +3 -4
- package/runtime/context/index.tsx +3 -3
- package/withYak/allow-global-css.ts +1 -1
- package/withYak/index.ts +7 -21
- package/dist/context/baseContext.cjs +0 -9
- package/dist/context/baseContext.cjs.map +0 -1
- package/dist/context/baseContext.d.cts +0 -6
- package/dist/context/index.cjs +0 -45
- package/dist/context/index.cjs.map +0 -1
- package/dist/context/index.d.cts +0 -21
- package/dist/context/index.server.cjs +0 -47
- package/dist/context/index.server.cjs.map +0 -1
- package/dist/context/index.server.d.cts +0 -10
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -320
- package/dist/internal.cjs +0 -544
- package/dist/internal.cjs.map +0 -1
- package/dist/internal.d.cts +0 -452
- package/dist/jsx-dev-runtime.cjs +0 -2
- package/dist/jsx-dev-runtime.cjs.map +0 -1
- package/dist/jsx-dev-runtime.d.cts +0 -7
- package/dist/jsx-runtime.cjs +0 -2
- package/dist/jsx-runtime.cjs.map +0 -1
- package/dist/jsx-runtime.d.cts +0 -38
- package/dist/loaders/turbo-loader.cjs.map +0 -1
- package/dist/loaders/webpack-loader.cjs.map +0 -1
- package/dist/static/index.cjs +0 -2
- package/dist/static/index.cjs.map +0 -1
- package/dist/static/index.d.cts +0 -28
- package/dist/withYak/index.cjs +0 -208
- package/dist/withYak/index.cjs.map +0 -1
- package/dist/withYak/index.d.cts +0 -121
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { transform } from "@swc/core";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
-
import path, { dirname,
|
|
4
|
+
import path, { basename, dirname, extname, posix, resolve, win32 } from "node:path";
|
|
5
5
|
import { isFileLoadingAllowed, normalizePath } from "vite";
|
|
6
6
|
import { createEvaluator } from "../isolated-source-eval/index.js";
|
|
7
|
-
import { relative
|
|
7
|
+
import { relative } from "path";
|
|
8
8
|
import { parse } from "@babel/parser";
|
|
9
9
|
|
|
10
10
|
//#region ../yak-internals/cross-file-resolver/parseModule.ts
|
|
@@ -47,7 +47,7 @@ async function uncachedParseModule(context, modulePath) {
|
|
|
47
47
|
path: modulePath,
|
|
48
48
|
js: transformed,
|
|
49
49
|
exports,
|
|
50
|
-
styledComponents: parseStyledComponents(transformed.code
|
|
50
|
+
styledComponents: parseStyledComponents(transformed.code),
|
|
51
51
|
mixins
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -66,7 +66,7 @@ function parseMixins(sourceContents) {
|
|
|
66
66
|
}
|
|
67
67
|
return mixins;
|
|
68
68
|
}
|
|
69
|
-
function parseStyledComponents(sourceContents
|
|
69
|
+
function parseStyledComponents(sourceContents) {
|
|
70
70
|
const styledParts = sourceContents.split("/*YAK EXPORTED STYLED:");
|
|
71
71
|
let styledComponents = {};
|
|
72
72
|
for (let i = 1; i < styledParts.length; i++) {
|
|
@@ -75,7 +75,7 @@ function parseStyledComponents(sourceContents, transpilationMode) {
|
|
|
75
75
|
styledComponents[componentName] = {
|
|
76
76
|
type: "styled-component",
|
|
77
77
|
nameParts: componentName.split("."),
|
|
78
|
-
value:
|
|
78
|
+
value: `.${className}`
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
return styledComponents;
|
|
@@ -97,6 +97,23 @@ function objectToModuleExport(object) {
|
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../yak-internals/cross-file-resolver/rewriteRelativeCssUrls.ts
|
|
102
|
+
function rewriteRelativeCssUrls(css, source, consumer) {
|
|
103
|
+
if (!css.includes("url(")) return css;
|
|
104
|
+
const path = /^[a-z]:[\\/]/i.test(consumer) ? win32 : posix;
|
|
105
|
+
const prefix = path.relative(path.dirname(consumer), path.dirname(source.split("?")[0]));
|
|
106
|
+
if (path.isAbsolute(prefix)) return css;
|
|
107
|
+
return css.replace(cssUrlRegex, (match, double, single, bare) => {
|
|
108
|
+
const url = double ?? single ?? bare ?? "";
|
|
109
|
+
if (!url.startsWith("./") && !url.startsWith("../")) return match;
|
|
110
|
+
const quote = double !== void 0 ? "\"" : single !== void 0 ? "'" : "";
|
|
111
|
+
const rewritten = path.join(prefix, url).replace(/\\/g, "/");
|
|
112
|
+
return `url(${quote}${rewritten.startsWith("../") ? "" : "./"}${rewritten}${quote})`;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const cssUrlRegex = /url\(\s*(?:"([^"*]*)"|'([^'*]*)'|([^'"()\s*]*))\s*\)/g;
|
|
116
|
+
|
|
100
117
|
//#endregion
|
|
101
118
|
//#region ../yak-internals/cross-file-resolver/Errors.ts
|
|
102
119
|
var CauseError = class CauseError extends Error {
|
|
@@ -161,6 +178,7 @@ async function uncachedResolveCrossFileConstant(context, filePath, css) {
|
|
|
161
178
|
}
|
|
162
179
|
replacement = resolved.type === "styled-component" ? resolved.value : resolved.value + (["}", ";"].includes(String(resolved.value).trimEnd().slice(-1)) ? "" : semicolon);
|
|
163
180
|
}
|
|
181
|
+
if (resolved.type !== "unresolved-tag" && resolved.source !== filePath) replacement = rewriteRelativeCssUrls(String(replacement), resolved.source, filePath);
|
|
164
182
|
result = result.slice(0, position) + String(replacement) + result.slice(position + size);
|
|
165
183
|
}
|
|
166
184
|
return {
|
|
@@ -444,7 +462,6 @@ function resolveYakContext(contextPath, cwd) {
|
|
|
444
462
|
//#region ../yak-internals/loaders/lib/debugLogger.ts
|
|
445
463
|
function createDebugLogger(debugOptions, rootPath) {
|
|
446
464
|
if (!debugOptions) return () => {};
|
|
447
|
-
throwOnDeprecatedDebugOptions(debugOptions);
|
|
448
465
|
const pattern = debugOptions === true ? void 0 : debugOptions.pattern;
|
|
449
466
|
const typesArray = debugOptions === true ? void 0 : debugOptions.types;
|
|
450
467
|
let compiledPattern = null;
|
|
@@ -456,32 +473,14 @@ function createDebugLogger(debugOptions, rootPath) {
|
|
|
456
473
|
const types = typesArray ? new Set(typesArray) : null;
|
|
457
474
|
return (messageType, message, filePath) => {
|
|
458
475
|
if (types && !types.has(messageType)) return;
|
|
459
|
-
const relativePath = relative
|
|
476
|
+
const relativePath = relative(rootPath, filePath);
|
|
460
477
|
if (!compiledPattern || compiledPattern.test(relativePath)) console.log("🐮 Yak", `[${messageType}]`, relativePath, "\n\n", message);
|
|
461
478
|
};
|
|
462
479
|
}
|
|
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
480
|
|
|
482
481
|
//#endregion
|
|
483
482
|
//#region ../yak-internals/loaders/lib/extractCss.ts
|
|
484
|
-
function extractCss(code
|
|
483
|
+
function extractCss(code) {
|
|
485
484
|
let codeString;
|
|
486
485
|
if (typeof code === "string") codeString = code;
|
|
487
486
|
else if (code instanceof Buffer) codeString = code.toString("utf-8");
|
|
@@ -493,7 +492,6 @@ function extractCss(code, transpilationMode) {
|
|
|
493
492
|
const codeUntilEnd = codeParts[i].split("*/")[0];
|
|
494
493
|
result += codeUntilEnd;
|
|
495
494
|
}
|
|
496
|
-
if (result && transpilationMode !== "Css") result = "/* cssmodules-pure-no-check */\n" + result;
|
|
497
495
|
return result;
|
|
498
496
|
}
|
|
499
497
|
|
|
@@ -515,8 +513,26 @@ async function parseExports(sourceContents) {
|
|
|
515
513
|
all: []
|
|
516
514
|
};
|
|
517
515
|
const variableDeclarations = {};
|
|
516
|
+
const importBindings = {};
|
|
517
|
+
const localExportSpecifiers = [];
|
|
518
518
|
let defaultIdentifier = null;
|
|
519
519
|
for (const node of ast.program.body) {
|
|
520
|
+
if (node.type === "ImportDeclaration") {
|
|
521
|
+
for (const specifier of node.specifiers) if (specifier.type === "ImportSpecifier") importBindings[specifier.local.name] = {
|
|
522
|
+
type: "re-export",
|
|
523
|
+
from: node.source.value,
|
|
524
|
+
name: specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value
|
|
525
|
+
};
|
|
526
|
+
else if (specifier.type === "ImportDefaultSpecifier") importBindings[specifier.local.name] = {
|
|
527
|
+
type: "re-export",
|
|
528
|
+
from: node.source.value,
|
|
529
|
+
name: "default"
|
|
530
|
+
};
|
|
531
|
+
else if (specifier.type === "ImportNamespaceSpecifier") importBindings[specifier.local.name] = {
|
|
532
|
+
type: "namespace-re-export",
|
|
533
|
+
from: node.source.value
|
|
534
|
+
};
|
|
535
|
+
}
|
|
520
536
|
if (node.type === "VariableDeclaration") {
|
|
521
537
|
for (const decl of node.declarations) if (decl.id.type === "Identifier" && decl.init) variableDeclarations[decl.id.name] = decl.init;
|
|
522
538
|
}
|
|
@@ -532,7 +548,12 @@ async function parseExports(sourceContents) {
|
|
|
532
548
|
from: node.source.value
|
|
533
549
|
};
|
|
534
550
|
}
|
|
535
|
-
else if (node.declaration
|
|
551
|
+
else if (!node.declaration) {
|
|
552
|
+
for (const specifier of node.specifiers) if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.local.type === "Identifier") localExportSpecifiers.push({
|
|
553
|
+
local: specifier.local.name,
|
|
554
|
+
exported: specifier.exported.name
|
|
555
|
+
});
|
|
556
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
536
557
|
for (const declaration of node.declaration.declarations) if (declaration.id.type === "Identifier" && declaration.init) {
|
|
537
558
|
variableDeclarations[declaration.id.name] = declaration.init;
|
|
538
559
|
const parsed = parseExportValueExpression(declaration.init, sourceContents);
|
|
@@ -551,7 +572,18 @@ async function parseExports(sourceContents) {
|
|
|
551
572
|
}
|
|
552
573
|
if (node.type === "ExportAllDeclaration") moduleExports.all.push(node.source.value);
|
|
553
574
|
}
|
|
554
|
-
|
|
575
|
+
const resolveIdentifier = (name) => {
|
|
576
|
+
if (variableDeclarations[name]) return parseExportValueExpression(variableDeclarations[name], sourceContents);
|
|
577
|
+
return importBindings[name];
|
|
578
|
+
};
|
|
579
|
+
for (const { local, exported } of localExportSpecifiers) {
|
|
580
|
+
const resolved = resolveIdentifier(local);
|
|
581
|
+
if (resolved) moduleExports.named[exported] = resolved;
|
|
582
|
+
}
|
|
583
|
+
if (defaultIdentifier) {
|
|
584
|
+
const resolved = resolveIdentifier(defaultIdentifier);
|
|
585
|
+
if (resolved) moduleExports.named["default"] = resolved;
|
|
586
|
+
}
|
|
555
587
|
return moduleExports;
|
|
556
588
|
} catch (error) {
|
|
557
589
|
throw new Error(`Error parsing exports: ${error.message}`);
|
|
@@ -659,11 +691,7 @@ function createViteYakPlugin(library) {
|
|
|
659
691
|
}
|
|
660
692
|
async function viteYakImpl(library, userOptions) {
|
|
661
693
|
const yakOptions = {
|
|
662
|
-
|
|
663
|
-
transpilationMode: "Css",
|
|
664
|
-
suppressDeprecationWarnings: false,
|
|
665
|
-
...userOptions.experiments
|
|
666
|
-
},
|
|
694
|
+
debug: userOptions.debug,
|
|
667
695
|
minify: userOptions.minify ?? process.env.NODE_ENV === "production",
|
|
668
696
|
prefix: userOptions.prefix,
|
|
669
697
|
foldStatic: userOptions.foldStatic ?? library.foldStatic,
|
|
@@ -673,12 +701,10 @@ async function viteYakImpl(library, userOptions) {
|
|
|
673
701
|
};
|
|
674
702
|
yakOptions.displayNames = userOptions.displayNames ?? yakOptions.displayNames ?? !yakOptions.minify;
|
|
675
703
|
let basePath = userOptions.basePath ?? "";
|
|
676
|
-
let hasWarnedAboutBasePath = false;
|
|
677
704
|
let debugLog = () => {};
|
|
678
705
|
let isServe = false;
|
|
679
706
|
const sourceFileRegex = /\.(tsx?|m?jsx?)\??/;
|
|
680
|
-
const
|
|
681
|
-
const virtualCssModuleRegex = /^\0virtual:yak-css:/;
|
|
707
|
+
const yakCssRegex = /\.yak\.css(?:\?|$)/;
|
|
682
708
|
const yakSwcPath = await findYakSwcPlugin();
|
|
683
709
|
const evaluator = await createEvaluator();
|
|
684
710
|
function checkFileAccess(filePath, config) {
|
|
@@ -705,37 +731,37 @@ async function viteYakImpl(library, userOptions) {
|
|
|
705
731
|
},
|
|
706
732
|
configResolved(config) {
|
|
707
733
|
basePath = basePath ? resolve(config.root, basePath) : config.root;
|
|
708
|
-
debugLog = createDebugLogger(yakOptions.
|
|
734
|
+
debugLog = createDebugLogger(yakOptions.debug, basePath);
|
|
709
735
|
isServe = config.command === "serve";
|
|
710
736
|
},
|
|
711
737
|
resolveId: {
|
|
712
|
-
filter: { id:
|
|
713
|
-
handler(id) {
|
|
714
|
-
|
|
738
|
+
filter: { id: yakCssRegex },
|
|
739
|
+
async handler(id, importer) {
|
|
740
|
+
const { path, query } = splitYakCssId(id);
|
|
741
|
+
if (importer && path.startsWith("./")) {
|
|
742
|
+
const source = importer.split("?")[0];
|
|
743
|
+
if (path === `./${basename(source, extname(source))}`) return source + ".yak.css" + query;
|
|
744
|
+
}
|
|
745
|
+
const resolved = await this.resolve(path, importer, { skipSelf: true });
|
|
746
|
+
return resolved && !resolved.external ? resolved.id + ".yak.css" + query : null;
|
|
715
747
|
}
|
|
716
748
|
},
|
|
717
749
|
load: {
|
|
718
|
-
filter: { id:
|
|
750
|
+
filter: { id: yakCssRegex },
|
|
719
751
|
async handler(id) {
|
|
720
752
|
const config = this.environment.getTopLevelConfig();
|
|
721
|
-
const
|
|
722
|
-
|
|
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);
|
|
753
|
+
const { path: originalId, query: queryString } = splitYakCssId(id);
|
|
754
|
+
if (!originalId) this.error(`[${library.name}] Invalid yak CSS module`);
|
|
728
755
|
const readSource = async (filePath) => this.fs.readFile(checkFileAccess(filePath, config), { encoding: "utf8" });
|
|
729
756
|
const sourceContent = await readSource(originalId);
|
|
730
757
|
this.addWatchFile(originalId);
|
|
731
758
|
const code = await transform$1(sourceContent, originalId, basePath, yakSwcPath, yakOptions);
|
|
732
759
|
debugLog("ts", code.code, originalId);
|
|
733
|
-
const extractedCss = extractCss(code.code
|
|
760
|
+
const extractedCss = extractCss(code.code);
|
|
734
761
|
debugLog("css", extractedCss, originalId);
|
|
735
762
|
const { resolved } = await resolveCrossFileConstant({
|
|
736
763
|
parse: (modulePath) => {
|
|
737
764
|
return parseModule({
|
|
738
|
-
transpilationMode: "Css",
|
|
739
765
|
extractExports: async (modulePath) => {
|
|
740
766
|
const sourceContent = await readSource(modulePath);
|
|
741
767
|
this.addWatchFile(modulePath);
|
|
@@ -774,19 +800,13 @@ async function viteYakImpl(library, userOptions) {
|
|
|
774
800
|
filter: {
|
|
775
801
|
id: {
|
|
776
802
|
include: sourceFileRegex,
|
|
777
|
-
exclude: [library.excludePattern]
|
|
803
|
+
exclude: [library.excludePattern, yakCssRegex]
|
|
778
804
|
},
|
|
779
805
|
code: library.name
|
|
780
806
|
},
|
|
781
807
|
async handler(code, id) {
|
|
782
808
|
try {
|
|
783
809
|
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
810
|
const result = await transform$1(code, filePath, basePath, yakSwcPath, yakOptions, isServe && library.reactRefreshReg, false);
|
|
791
811
|
return {
|
|
792
812
|
code: result.code,
|
|
@@ -799,16 +819,26 @@ async function viteYakImpl(library, userOptions) {
|
|
|
799
819
|
},
|
|
800
820
|
hotUpdate({ modules, file, type }) {
|
|
801
821
|
if (type !== "update" && type !== "create") return;
|
|
802
|
-
if (!sourceFileRegex.test(file)) return;
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
822
|
+
if (!sourceFileRegex.test(file) || yakCssRegex.test(file)) return;
|
|
823
|
+
const { moduleGraph } = this.environment;
|
|
824
|
+
const cssFiles = /* @__PURE__ */ new Set([normalizePath(file) + ".yak.css"]);
|
|
825
|
+
for (const mod of modules) for (const importer of mod.importers) if (importer.file && yakCssRegex.test(importer.file)) cssFiles.add(importer.file);
|
|
826
|
+
const cssModules = new Set([...cssFiles].flatMap((cssFile) => [...moduleGraph.getModulesByFile(cssFile) ?? []]));
|
|
827
|
+
if (cssModules.size) {
|
|
828
|
+
for (const mod of cssModules) moduleGraph.invalidateModule(mod);
|
|
829
|
+
return [.../* @__PURE__ */ new Set([...modules, ...cssModules])];
|
|
808
830
|
}
|
|
809
831
|
}
|
|
810
832
|
};
|
|
811
833
|
}
|
|
834
|
+
function splitYakCssId(id) {
|
|
835
|
+
const queryStart = id.indexOf("?");
|
|
836
|
+
const query = queryStart === -1 ? "" : id.slice(queryStart);
|
|
837
|
+
return {
|
|
838
|
+
path: id.slice(0, id.length - query.length).slice(0, -8),
|
|
839
|
+
query
|
|
840
|
+
};
|
|
841
|
+
}
|
|
812
842
|
async function findYakSwcPlugin() {
|
|
813
843
|
try {
|
|
814
844
|
const packageJsonPath = require.resolve("@yak/swc/package.json");
|
|
@@ -840,12 +870,10 @@ function transform$1(data, modulePath, rootPath, yakSwcPath, yakOptions, reactRe
|
|
|
840
870
|
displayNames: yakOptions.displayNames,
|
|
841
871
|
foldStatic: yakOptions.foldStatic ?? true,
|
|
842
872
|
strictCssProp: yakOptions.strictCssProp ?? true,
|
|
843
|
-
suppressDeprecationWarnings: yakOptions.experiments?.suppressDeprecationWarnings,
|
|
844
873
|
...reactRefreshReg ? { reactRefreshReg: true } : {},
|
|
845
874
|
...emitCssComments === false ? { emitCssComments: false } : {},
|
|
846
875
|
importMode: {
|
|
847
|
-
value: "
|
|
848
|
-
transpilation: "Css",
|
|
876
|
+
value: "./{{__BASE_NAME__}}.yak.css",
|
|
849
877
|
encoding: "None"
|
|
850
878
|
}
|
|
851
879
|
}]]
|