@yak/react 10.0.0-rc.0 → 10.0.0-rc.1
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 +12 -0
- package/dist/context/baseContext.d.ts +1 -2
- package/dist/context/index.d.ts +3 -4
- 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 +39 -5
- package/dist/cross-file-resolver/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- 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/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} +3 -3
- package/dist/loaders/{turbo-loader.cjs → turbo-loader.js} +60 -47
- package/dist/loaders/turbo-loader.js.map +1 -0
- package/dist/loaders/vite-plugin.d.ts +13 -21
- package/dist/loaders/vite-plugin.js +43 -36
- 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} +50 -37
- package/dist/loaders/webpack-loader.js.map +1 -0
- package/dist/rsbuild/index.d.ts +2 -2
- package/dist/rsbuild/index.js +1 -2
- 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 +7 -13
- package/dist/withYak/index.js.map +1 -1
- package/loaders/lib/resolveCrossFileSelectors.ts +0 -1
- package/loaders/turbo-loader.ts +11 -7
- package/loaders/webpack-loader.ts +3 -6
- package/package.json +45 -104
- package/rsbuild/index.ts +2 -3
- 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
|
@@ -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;
|
|
@@ -444,7 +444,6 @@ function resolveYakContext(contextPath, cwd) {
|
|
|
444
444
|
//#region ../yak-internals/loaders/lib/debugLogger.ts
|
|
445
445
|
function createDebugLogger(debugOptions, rootPath) {
|
|
446
446
|
if (!debugOptions) return () => {};
|
|
447
|
-
throwOnDeprecatedDebugOptions(debugOptions);
|
|
448
447
|
const pattern = debugOptions === true ? void 0 : debugOptions.pattern;
|
|
449
448
|
const typesArray = debugOptions === true ? void 0 : debugOptions.types;
|
|
450
449
|
let compiledPattern = null;
|
|
@@ -460,28 +459,10 @@ function createDebugLogger(debugOptions, rootPath) {
|
|
|
460
459
|
if (!compiledPattern || compiledPattern.test(relativePath)) console.log("🐮 Yak", `[${messageType}]`, relativePath, "\n\n", message);
|
|
461
460
|
};
|
|
462
461
|
}
|
|
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
462
|
|
|
482
463
|
//#endregion
|
|
483
464
|
//#region ../yak-internals/loaders/lib/extractCss.ts
|
|
484
|
-
function extractCss(code
|
|
465
|
+
function extractCss(code) {
|
|
485
466
|
let codeString;
|
|
486
467
|
if (typeof code === "string") codeString = code;
|
|
487
468
|
else if (code instanceof Buffer) codeString = code.toString("utf-8");
|
|
@@ -493,7 +474,6 @@ function extractCss(code, transpilationMode) {
|
|
|
493
474
|
const codeUntilEnd = codeParts[i].split("*/")[0];
|
|
494
475
|
result += codeUntilEnd;
|
|
495
476
|
}
|
|
496
|
-
if (result && transpilationMode !== "Css") result = "/* cssmodules-pure-no-check */\n" + result;
|
|
497
477
|
return result;
|
|
498
478
|
}
|
|
499
479
|
|
|
@@ -515,8 +495,26 @@ async function parseExports(sourceContents) {
|
|
|
515
495
|
all: []
|
|
516
496
|
};
|
|
517
497
|
const variableDeclarations = {};
|
|
498
|
+
const importBindings = {};
|
|
499
|
+
const localExportSpecifiers = [];
|
|
518
500
|
let defaultIdentifier = null;
|
|
519
501
|
for (const node of ast.program.body) {
|
|
502
|
+
if (node.type === "ImportDeclaration") {
|
|
503
|
+
for (const specifier of node.specifiers) if (specifier.type === "ImportSpecifier") importBindings[specifier.local.name] = {
|
|
504
|
+
type: "re-export",
|
|
505
|
+
from: node.source.value,
|
|
506
|
+
name: specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value
|
|
507
|
+
};
|
|
508
|
+
else if (specifier.type === "ImportDefaultSpecifier") importBindings[specifier.local.name] = {
|
|
509
|
+
type: "re-export",
|
|
510
|
+
from: node.source.value,
|
|
511
|
+
name: "default"
|
|
512
|
+
};
|
|
513
|
+
else if (specifier.type === "ImportNamespaceSpecifier") importBindings[specifier.local.name] = {
|
|
514
|
+
type: "namespace-re-export",
|
|
515
|
+
from: node.source.value
|
|
516
|
+
};
|
|
517
|
+
}
|
|
520
518
|
if (node.type === "VariableDeclaration") {
|
|
521
519
|
for (const decl of node.declarations) if (decl.id.type === "Identifier" && decl.init) variableDeclarations[decl.id.name] = decl.init;
|
|
522
520
|
}
|
|
@@ -532,7 +530,12 @@ async function parseExports(sourceContents) {
|
|
|
532
530
|
from: node.source.value
|
|
533
531
|
};
|
|
534
532
|
}
|
|
535
|
-
else if (node.declaration
|
|
533
|
+
else if (!node.declaration) {
|
|
534
|
+
for (const specifier of node.specifiers) if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.local.type === "Identifier") localExportSpecifiers.push({
|
|
535
|
+
local: specifier.local.name,
|
|
536
|
+
exported: specifier.exported.name
|
|
537
|
+
});
|
|
538
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
536
539
|
for (const declaration of node.declaration.declarations) if (declaration.id.type === "Identifier" && declaration.init) {
|
|
537
540
|
variableDeclarations[declaration.id.name] = declaration.init;
|
|
538
541
|
const parsed = parseExportValueExpression(declaration.init, sourceContents);
|
|
@@ -551,7 +554,18 @@ async function parseExports(sourceContents) {
|
|
|
551
554
|
}
|
|
552
555
|
if (node.type === "ExportAllDeclaration") moduleExports.all.push(node.source.value);
|
|
553
556
|
}
|
|
554
|
-
|
|
557
|
+
const resolveIdentifier = (name) => {
|
|
558
|
+
if (variableDeclarations[name]) return parseExportValueExpression(variableDeclarations[name], sourceContents);
|
|
559
|
+
return importBindings[name];
|
|
560
|
+
};
|
|
561
|
+
for (const { local, exported } of localExportSpecifiers) {
|
|
562
|
+
const resolved = resolveIdentifier(local);
|
|
563
|
+
if (resolved) moduleExports.named[exported] = resolved;
|
|
564
|
+
}
|
|
565
|
+
if (defaultIdentifier) {
|
|
566
|
+
const resolved = resolveIdentifier(defaultIdentifier);
|
|
567
|
+
if (resolved) moduleExports.named["default"] = resolved;
|
|
568
|
+
}
|
|
555
569
|
return moduleExports;
|
|
556
570
|
} catch (error) {
|
|
557
571
|
throw new Error(`Error parsing exports: ${error.message}`);
|
|
@@ -659,11 +673,7 @@ function createViteYakPlugin(library) {
|
|
|
659
673
|
}
|
|
660
674
|
async function viteYakImpl(library, userOptions) {
|
|
661
675
|
const yakOptions = {
|
|
662
|
-
|
|
663
|
-
transpilationMode: "Css",
|
|
664
|
-
suppressDeprecationWarnings: false,
|
|
665
|
-
...userOptions.experiments
|
|
666
|
-
},
|
|
676
|
+
debug: userOptions.debug,
|
|
667
677
|
minify: userOptions.minify ?? process.env.NODE_ENV === "production",
|
|
668
678
|
prefix: userOptions.prefix,
|
|
669
679
|
foldStatic: userOptions.foldStatic ?? library.foldStatic,
|
|
@@ -705,7 +715,7 @@ async function viteYakImpl(library, userOptions) {
|
|
|
705
715
|
},
|
|
706
716
|
configResolved(config) {
|
|
707
717
|
basePath = basePath ? resolve(config.root, basePath) : config.root;
|
|
708
|
-
debugLog = createDebugLogger(yakOptions.
|
|
718
|
+
debugLog = createDebugLogger(yakOptions.debug, basePath);
|
|
709
719
|
isServe = config.command === "serve";
|
|
710
720
|
},
|
|
711
721
|
resolveId: {
|
|
@@ -730,12 +740,11 @@ async function viteYakImpl(library, userOptions) {
|
|
|
730
740
|
this.addWatchFile(originalId);
|
|
731
741
|
const code = await transform$1(sourceContent, originalId, basePath, yakSwcPath, yakOptions);
|
|
732
742
|
debugLog("ts", code.code, originalId);
|
|
733
|
-
const extractedCss = extractCss(code.code
|
|
743
|
+
const extractedCss = extractCss(code.code);
|
|
734
744
|
debugLog("css", extractedCss, originalId);
|
|
735
745
|
const { resolved } = await resolveCrossFileConstant({
|
|
736
746
|
parse: (modulePath) => {
|
|
737
747
|
return parseModule({
|
|
738
|
-
transpilationMode: "Css",
|
|
739
748
|
extractExports: async (modulePath) => {
|
|
740
749
|
const sourceContent = await readSource(modulePath);
|
|
741
750
|
this.addWatchFile(modulePath);
|
|
@@ -840,12 +849,10 @@ function transform$1(data, modulePath, rootPath, yakSwcPath, yakOptions, reactRe
|
|
|
840
849
|
displayNames: yakOptions.displayNames,
|
|
841
850
|
foldStatic: yakOptions.foldStatic ?? true,
|
|
842
851
|
strictCssProp: yakOptions.strictCssProp ?? true,
|
|
843
|
-
suppressDeprecationWarnings: yakOptions.experiments?.suppressDeprecationWarnings,
|
|
844
852
|
...reactRefreshReg ? { reactRefreshReg: true } : {},
|
|
845
853
|
...emitCssComments === false ? { emitCssComments: false } : {},
|
|
846
854
|
importMode: {
|
|
847
855
|
value: "virtual:yak-css:{{__MODULE_PATH__}}.css",
|
|
848
|
-
transpilation: "Css",
|
|
849
856
|
encoding: "None"
|
|
850
857
|
}
|
|
851
858
|
}]]
|