Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5e5c59d
Add isolated-source-eval package for bundler-agnostic module evaluati…
jantimon Feb 1, 2026
96afe49
Fix Windows path separator in test assertions
jantimon Feb 1, 2026
f1bde9b
changeset
jantimon Feb 1, 2026
bc19520
Bump Node.js requirement from 22 to 24 across the repo
jantimon Feb 1, 2026
600f06c
Add .prettierignore for intentional syntax error fixture
jantimon Feb 1, 2026
a6efe23
Track in-flight staleness instead of keeping stale reverseDeps
jantimon Feb 2, 2026
ccb316b
fix CSS HMR for Vite virtual modules (#477)
jantimon Feb 2, 2026
9fbf107
improve build - test yak files
jantimon Feb 2, 2026
cac954d
Merge branch 'main' into feat/isolated-source-eval
jantimon Feb 2, 2026
df7e702
Merge branch 'main' into feat/isolated-source-eval
jantimon Feb 6, 2026
b48b16c
[autofix.ci] apply automated fixes
autofix-ci[bot] Feb 6, 2026
ada8266
fix inflight race condition
jantimon Feb 6, 2026
81e5b8d
recover from module scope errors
jantimon Feb 6, 2026
436eccf
e2e tests
jantimon Feb 9, 2026
fe0f732
add e2e tests
jantimon Feb 9, 2026
16c6730
replace cross-file-tests with e2e browser tests
jantimon Feb 9, 2026
f825807
changeset
jantimon Feb 9, 2026
b081709
Merge branch 'features/e2e-testing' into feat/isolated-source-eval
jantimon Feb 9, 2026
b68308f
add vite8
jantimon Feb 9, 2026
2bfef4b
allow nodejs based css literal call
jantimon Feb 9, 2026
27ae4d8
move isolated-soruce-eval into next-yak
jantimon Feb 9, 2026
8c2783d
change to node 22.18+ so it is not a breaking change
jantimon Feb 10, 2026
5189503
Merge remote-tracking branch 'origin/main' into feat/isolated-source-…
jantimon Feb 10, 2026
17a4833
Merge remote-tracking branch 'origin/main' into feat/isolated-source-…
jantimon Feb 10, 2026
ef2fe16
migrate webpack away from importModule for consistent bundler behaviour
jantimon Feb 9, 2026
72316fa
Merge remote-tracking branch 'origin/main' into feat/webpack-isolated…
jantimon Feb 12, 2026
b12a522
Allow Evaluator.invalidate() to accept rest arguments
jantimon Feb 12, 2026
1808840
empty changeset
jantimon Feb 12, 2026
e869842
Merge remote-tracking branch 'origin/feat/invalidate-rest-args' into …
jantimon Feb 12, 2026
6495774
invalidate all
jantimon Feb 12, 2026
516097e
Merge branch 'main' into feat/webpack-isolated-source-eval
jantimon Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-lizards-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"next-yak": major
---

Stop compiling .yak.ts files for faster builds and consistent bundler behaviour
20 changes: 18 additions & 2 deletions packages/next-yak/loaders/lib/resolveCrossFileSelectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parse } from "@babel/parser";
import traverse from "@babel/traverse";
import type { Compilation, LoaderContext } from "webpack";
import type { Compilation, Compiler, LoaderContext } from "webpack";
import type { Evaluator } from "../../isolated-source-eval/index.js";
import {
ModuleExport,
ModuleExports,
Expand Down Expand Up @@ -110,7 +111,22 @@ function getParseContext(
return { code: await transformedSource };
},
async evaluateYakModule(modulePath) {
return loader.importModule(modulePath);
const evaluator = (
loader._compiler as Compiler & { yakEvaluator?: Evaluator }
)?.yakEvaluator;
if (!evaluator) {
throw new Error(
"YakEvaluatorPlugin is not configured. Add `new YakEvaluatorPlugin()` to your webpack plugins.",
);
}
const result = await evaluator.evaluate(modulePath);
if (!result.ok) throw new Error(result.error.message);
// Register all transitive dependencies so webpack re-processes
// when any dependency of the .yak module changes
for (const dep of result.dependencies) {
loader.addDependency(dep);
}
return result.value;
},
transpilationMode: loader.getOptions().experiments?.transpilationMode,
};
Expand Down
7 changes: 7 additions & 0 deletions packages/next-yak/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export default defineConfig([
sourcemap: true,
clean: false,
dts: true,
external: [
// all non relative imports must be load from node_modules
/^(?!\.)/,
// isolated-source-eval must not be bundled (worker path would break)
/\.\.\/isolated-source-eval\//,
],
noExternal: [],
target: "es2022",
outDir: "dist/withYak",
},
Expand Down
5 changes: 5 additions & 0 deletions packages/next-yak/withYak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { existsSync } from "node:fs";
import path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";

import { YakEvaluatorPlugin } from "./yakEvaluatorPlugin.js";
export { YakEvaluatorPlugin };

const currentDir =
typeof __dirname !== "undefined"
? __dirname
Expand Down Expand Up @@ -174,6 +177,8 @@ function addYakWebpack(
webpackConfig = previousConfig(webpackConfig, options);
}

webpackConfig.plugins.push(new YakEvaluatorPlugin());

webpackConfig.module.rules.push({
test:
yakOptions.experiments?.transpilationMode === "Css"
Expand Down
26 changes: 26 additions & 0 deletions packages/next-yak/withYak/yakEvaluatorPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Compiler } from "webpack";
import type { Evaluator } from "../isolated-source-eval/index.js";

export class YakEvaluatorPlugin {
apply(compiler: Compiler & { yakEvaluator?: Evaluator }) {
const evaluatorPromise = import("../isolated-source-eval/index.js").then(
({ createEvaluator }) => createEvaluator(),
);

compiler.hooks.beforeCompile.tapPromise("YakEvaluatorPlugin", async () => {
compiler.yakEvaluator = await evaluatorPromise;
});

compiler.hooks.watchRun.tapPromise("YakEvaluatorPlugin", async () => {
const evaluator = await evaluatorPromise;
if (compiler.modifiedFiles) {
evaluator.invalidate(...compiler.modifiedFiles);
}
});

compiler.hooks.shutdown.tapPromise("YakEvaluatorPlugin", async () => {
const evaluator = await evaluatorPromise;
await evaluator.dispose();
});
}
}
6 changes: 5 additions & 1 deletion packages/storybook-addon-yak/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveYakContext } from "next-yak/withYak";
import { resolveYakContext, YakEvaluatorPlugin } from "next-yak/withYak";
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
import path, { dirname } from "node:path";
Expand Down Expand Up @@ -203,6 +203,10 @@ export async function webpackFinal(config: any, options: StorybookOptions) {
processRule(rule);
}

// Add YakEvaluatorPlugin for cross-file constant resolution
config.plugins = config.plugins || [];
config.plugins.push(new YakEvaluatorPlugin());

// Set up context alias for theming
const yakContext = resolveYakContext(
yakOptions.contextPath,
Expand Down
Loading