@stillwind/integration 0.8.0 → 0.10.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/CHANGELOG.md +190 -0
- package/dist/astro/development.d.ts +2 -0
- package/dist/astro/development.js +2 -0
- package/dist/astro/development.js.map +1 -1
- package/dist/astro/index.d.ts +1 -1
- package/dist/astro/index.js +8 -2
- package/dist/astro/index.js.map +1 -1
- package/dist/{emission-BVi5aRbb.js → emission-BpaN4Z4m.js} +212 -69
- package/dist/emission-BpaN4Z4m.js.map +1 -0
- package/dist/fresh/index.d.ts +1 -1
- package/dist/fresh/index.js +1 -1
- package/dist/{index-DFfbZxNT.d.ts → index-B6EtrWus.d.ts} +2 -2
- package/dist/loader-cache-DfOGY8AJ.js +231 -0
- package/dist/loader-cache-DfOGY8AJ.js.map +1 -0
- package/dist/next/css-loader.d.ts +5 -2
- package/dist/next/css-loader.js +7 -2
- package/dist/next/css-loader.js.map +1 -1
- package/dist/next/index.js +2 -0
- package/dist/next/index.js.map +1 -1
- package/dist/{node-loader-D-3Ynpy1.d.ts → node-loader-Bqg7E5zq.d.ts} +6 -3
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/nuxt/index.js +2 -1
- package/dist/nuxt/index.js.map +1 -1
- package/dist/{plugin-aV0zIIAe.d.ts → plugin-BAG0ZI1X.d.ts} +58 -6
- package/dist/{plugin-mPiBLdqa.js → plugin-D-45o54j.js} +5 -2
- package/dist/plugin-D-45o54j.js.map +1 -0
- package/dist/{plugin-ByYcpBcE.js → plugin-DQH8QlYh.js} +331 -36
- package/dist/plugin-DQH8QlYh.js.map +1 -0
- package/dist/{project-DUGu8g_L.d.ts → project-B_KFQist.d.ts} +2 -2
- package/dist/project-egWF2vWJ.js +428 -0
- package/dist/project-egWF2vWJ.js.map +1 -0
- package/dist/{project-BNw0nZBE.d.ts → project-mB7CODIs.d.ts} +46 -7
- package/dist/rsbuild/index.d.ts +4 -1
- package/dist/rsbuild/index.js +2 -2
- package/dist/rsbuild/index.js.map +1 -1
- package/dist/rspack/index.d.ts +1 -1
- package/dist/rspack/index.js +1 -1
- package/dist/session-Cxf4D6oQ.d.ts +163 -0
- package/dist/source-entries-J5azZ_-z.js +350 -0
- package/dist/source-entries-J5azZ_-z.js.map +1 -0
- package/dist/turbopack/css-loader.d.ts +5 -2
- package/dist/turbopack/css-loader.js +53 -17
- package/dist/turbopack/css-loader.js.map +1 -1
- package/dist/turbopack/index.d.ts +2 -2
- package/dist/turbopack/loader.d.ts +3 -2
- package/dist/turbopack/loader.js +10 -4
- package/dist/turbopack/loader.js.map +1 -1
- package/dist/turbopack/node-loader.d.ts +1 -1
- package/dist/turbopack/node-loader.js +1 -0
- package/dist/turbopack/node-loader.js.map +1 -1
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/dist/vite/runtime.d.ts +10 -3
- package/dist/vite/runtime.js +8 -1
- package/dist/vite/runtime.js.map +1 -1
- package/dist/webpack/css-loader.js +1 -1
- package/dist/webpack/document-loader.d.ts +4 -1
- package/dist/webpack/document-loader.js +5 -2
- package/dist/webpack/document-loader.js.map +1 -1
- package/dist/webpack/fragment-loader.d.ts +1 -0
- package/dist/webpack/fragment-loader.js +1 -0
- package/dist/webpack/fragment-loader.js.map +1 -1
- package/dist/webpack/index.d.ts +1 -1
- package/dist/webpack/index.js +1 -1
- package/dist/webpack/loader.js +15 -21
- package/dist/webpack/loader.js.map +1 -1
- package/dist/webpack/source-loader.d.ts +1 -0
- package/dist/webpack/source-loader.js +1 -0
- package/dist/webpack/source-loader.js.map +1 -1
- package/package.json +19 -17
- package/dist/binding-files-Ds5NpyVV.js +0 -45
- package/dist/binding-files-Ds5NpyVV.js.map +0 -1
- package/dist/emission-BVi5aRbb.js.map +0 -1
- package/dist/plugin-ByYcpBcE.js.map +0 -1
- package/dist/plugin-mPiBLdqa.js.map +0 -1
- package/dist/project-C3IH7geC.js +0 -182
- package/dist/project-C3IH7geC.js.map +0 -1
- package/dist/session-B9_rp9TH.d.ts +0 -72
- package/dist/session-DHUCQMG5.js +0 -117
- package/dist/session-DHUCQMG5.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./session-
|
|
1
|
+
import "./session-Cxf4D6oQ.js";
|
|
2
2
|
import { CssUpstreamMap, PluginRuntime } from "@stillwind/host";
|
|
3
3
|
import { NativeDesignSystemLoader, NativeStylesheetPlan } from "@stillwind/native";
|
|
4
4
|
import { Plugin } from "vite";
|
|
@@ -12,4 +12,4 @@ interface IntegrationConfig extends InlineConfig {
|
|
|
12
12
|
emission?: "single" | "split";
|
|
13
13
|
}
|
|
14
14
|
export { IntegrationConfig as t };
|
|
15
|
-
//# sourceMappingURL=project-
|
|
15
|
+
//# sourceMappingURL=project-B_KFQist.d.ts.map
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { n as recordInputs, r as nativeBindingFiles, t as LoaderCache } from "./loader-cache-DfOGY8AJ.js";
|
|
2
|
+
import { a as buildCompilerOptions, i as SharedTypeFacts, o as warnSkippedCss, r as IntegrationSession, t as buildSourceEntries } from "./source-entries-J5azZ_-z.js";
|
|
3
|
+
import { isBuiltin } from "node:module";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
import { CompilationFailure, cleanModuleId, cssEntrypoint, fileModuleDescriptor, loadCssGraph, nodePluginHost, resolveTypeFactsEnvironment, warnRejectedNames } from "@stillwind/host";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { scanSource } from "@stillwind/native";
|
|
10
|
+
import { watch } from "node:fs";
|
|
11
|
+
import { resolveIntegrationConfig } from "@stillwind/config/node";
|
|
12
|
+
// src/turbopack/project.ts
|
|
13
|
+
/**
|
|
14
|
+
* Evaluated configuration keyed by loader options and the application directory. It is evaluated
|
|
15
|
+
* again when one of its files changes.
|
|
16
|
+
*/
|
|
17
|
+
const configurations = new LoaderCache();
|
|
18
|
+
/**
|
|
19
|
+
* Design systems keyed by evaluated settings and mode. The checker of an idle compiler stops after
|
|
20
|
+
* this time, so that a worker process does not keep a checker process running.
|
|
21
|
+
*/
|
|
22
|
+
const designSystems = new LoaderCache(closeDesignSystem, 3e4);
|
|
23
|
+
/**
|
|
24
|
+
* Closes the checkers of a design system's compilers and discards their shared sources. The design
|
|
25
|
+
* system stays usable, and a later compilation loads the sources again.
|
|
26
|
+
*
|
|
27
|
+
* @param designSystem - Design system whose compilers to close.
|
|
28
|
+
*/
|
|
29
|
+
function closeDesignSystem({ compiler, graphCompiler, shared }) {
|
|
30
|
+
compiler.close();
|
|
31
|
+
graphCompiler.close();
|
|
32
|
+
shared?.close();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Design systems of development compilers, keyed by the application directory that one recursive
|
|
36
|
+
* watcher of this process observes. A design system that the cache dropped can be collected.
|
|
37
|
+
*/
|
|
38
|
+
const sourceWatchers = /* @__PURE__ */ new Map();
|
|
39
|
+
/**
|
|
40
|
+
* Starts or reuses a recursive watcher that reports changes of script, component, and JSON files
|
|
41
|
+
* under an application directory to the compilers of registered design systems. Changes under
|
|
42
|
+
* `node_modules`, `.next`, and `.git` are not reported. When the watcher reports a change without
|
|
43
|
+
* a file name, which happens when changes overflow its buffer, the registered design systems
|
|
44
|
+
* compare their sources with the files before their next use. That event and every added or removed
|
|
45
|
+
* file also discard the modules that reconstructions visited. When the watcher fails, it closes, and
|
|
46
|
+
* every registered design system discards its shared sources and stops reusing visited modules.
|
|
47
|
+
*
|
|
48
|
+
* Events can arrive after a compilation already read a changed file, so callers must also report
|
|
49
|
+
* the text that they read through {@link IntegrationSession.sourceRead}.
|
|
50
|
+
*
|
|
51
|
+
* @param root - Absolute application directory.
|
|
52
|
+
* @returns The set in which to register design systems, or undefined when the platform cannot
|
|
53
|
+
* watch the directory recursively.
|
|
54
|
+
*/
|
|
55
|
+
function watchSources(root) {
|
|
56
|
+
const existing = sourceWatchers.get(root);
|
|
57
|
+
if (existing) return existing;
|
|
58
|
+
const targets = /* @__PURE__ */ new Set();
|
|
59
|
+
/**
|
|
60
|
+
* Calls an operation for every registered design system that is still reachable.
|
|
61
|
+
*
|
|
62
|
+
* @param operation - Operation that receives the design system.
|
|
63
|
+
*/
|
|
64
|
+
const each = (operation) => {
|
|
65
|
+
for (const target of targets) {
|
|
66
|
+
const designSystem = target.deref();
|
|
67
|
+
if (designSystem) operation(designSystem);
|
|
68
|
+
else targets.delete(target);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
let watcher;
|
|
72
|
+
try {
|
|
73
|
+
watcher = watch(root, {
|
|
74
|
+
recursive: true,
|
|
75
|
+
persistent: false
|
|
76
|
+
}, (event, name) => {
|
|
77
|
+
if (!name) {
|
|
78
|
+
each((designSystem) => {
|
|
79
|
+
designSystem.unverified = true;
|
|
80
|
+
designSystem.scans?.clear();
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (/(?:^|[\\/])(?:node_modules|\.next|\.git)[\\/]/.test(name) || !/\.(?:[cm]?[jt]sx?|json|astro|svelte|vue)$/.test(name)) return;
|
|
85
|
+
const file = path.join(root, name);
|
|
86
|
+
each((designSystem) => {
|
|
87
|
+
designSystem.compiler.sourceChanged(file, event === "rename");
|
|
88
|
+
designSystem.graphCompiler.sourceChanged(file, event === "rename");
|
|
89
|
+
if (event === "rename") designSystem.scans?.clear();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
} catch {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
watcher.on("error", () => {
|
|
96
|
+
watcher.close();
|
|
97
|
+
sourceWatchers.delete(root);
|
|
98
|
+
each((designSystem) => {
|
|
99
|
+
designSystem.scans = void 0;
|
|
100
|
+
closeDesignSystem(designSystem);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
sourceWatchers.set(root, targets);
|
|
104
|
+
return targets;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Loads the design system and compiler for a Turbopack or Next loader invocation, or reuses them.
|
|
108
|
+
*
|
|
109
|
+
* Invocations in one process share the evaluated configuration while its files keep their contents,
|
|
110
|
+
* and share the design system and compiler while the configuration and the CSS files stay
|
|
111
|
+
* unchanged. Configuration dependencies, missing discovery candidates, compiler files, and CSS
|
|
112
|
+
* dependencies are registered with the loader context of every invocation.
|
|
113
|
+
*
|
|
114
|
+
* @param context - Loader context containing serializable discovery settings, the bundler root,
|
|
115
|
+
* filesystem access, resolver operations, and dependency tracking.
|
|
116
|
+
* @returns A promise for the project. The caller must call its `release` function after its last use.
|
|
117
|
+
* @throws If configuration evaluation or project selection fails, the CSS graph cannot be loaded,
|
|
118
|
+
* or compiler initialization fails.
|
|
119
|
+
*/
|
|
120
|
+
async function createProject(context) {
|
|
121
|
+
const supplied = context.getOptions();
|
|
122
|
+
const applicationRoot = path.resolve(context.rootContext, supplied.root);
|
|
123
|
+
/**
|
|
124
|
+
* Reads text through Turbopack's loader filesystem.
|
|
125
|
+
* @param id - File path accepted by the loader filesystem.
|
|
126
|
+
* @returns File contents converted to a string.
|
|
127
|
+
* @throws If the filesystem reports a read error.
|
|
128
|
+
*/
|
|
129
|
+
const read = (id) => new Promise((done, reject) => {
|
|
130
|
+
context.fs.readFile(id, (error, contents) => error ? reject(error) : done(String(contents)));
|
|
131
|
+
});
|
|
132
|
+
const probe = (id) => read(id).catch((error) => {
|
|
133
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") return;
|
|
134
|
+
throw error;
|
|
135
|
+
});
|
|
136
|
+
const configurationLease = await configurations.use(JSON.stringify([supplied.compiler, applicationRoot]), probe, async () => {
|
|
137
|
+
const value = await resolveIntegrationConfig(supplied.compiler, applicationRoot);
|
|
138
|
+
const recorder = recordInputs(probe);
|
|
139
|
+
for (const file of value.dependencies) recorder.watch(file);
|
|
140
|
+
for (const file of value.missing) recorder.watchMissing(file);
|
|
141
|
+
return {
|
|
142
|
+
value,
|
|
143
|
+
inputs: await recorder.finish()
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
configurationLease.done();
|
|
147
|
+
const configuration = configurationLease.value;
|
|
148
|
+
const options = {
|
|
149
|
+
...supplied,
|
|
150
|
+
compiler: configuration.config,
|
|
151
|
+
root: configuration.config.root
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Registers a file whose changes invalidate this loader result.
|
|
155
|
+
* @param id - Filesystem path for configuration, compiler code, CSS, or a resolved dependency.
|
|
156
|
+
*/
|
|
157
|
+
const watch = (id) => {
|
|
158
|
+
context.addDependency(id);
|
|
159
|
+
};
|
|
160
|
+
for (const file of configuration.dependencies) watch(file);
|
|
161
|
+
for (const file of configuration.missing) context.addMissingDependency(file);
|
|
162
|
+
for (const file of nativeBindingFiles()) watch(file);
|
|
163
|
+
watch(fileURLToPath(import.meta.resolve("@stillwind/host")));
|
|
164
|
+
watch(import.meta.filename);
|
|
165
|
+
for (const file of ["loader.js", "css-loader.js"]) watch(fileURLToPath(new URL(`./${file}`, import.meta.resolve("@stillwind/integration/turbopack"))));
|
|
166
|
+
/**
|
|
167
|
+
* Adapts a Turbopack resolver to imports relative to a source file.
|
|
168
|
+
*
|
|
169
|
+
* @param settings - Resolution policy passed to the loader's resolver factory.
|
|
170
|
+
* @returns An asynchronous resolver accepting a specifier and full importer identity. Its promise
|
|
171
|
+
* rejects on resolver errors or missing results, and otherwise returns the resolved identity.
|
|
172
|
+
*/
|
|
173
|
+
const resolver = (settings) => {
|
|
174
|
+
const resolve = context.getResolve(settings);
|
|
175
|
+
return (specifier, importer) => new Promise((done, reject) => {
|
|
176
|
+
resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) => error ? reject(error) : id ? done(id) : reject(/* @__PURE__ */ new Error(`Cannot resolve ${specifier} from ${importer}`)));
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const resolveJs = resolver({
|
|
180
|
+
extensions: [
|
|
181
|
+
".tsx",
|
|
182
|
+
".ts",
|
|
183
|
+
".jsx",
|
|
184
|
+
".js",
|
|
185
|
+
".mjs",
|
|
186
|
+
".cjs",
|
|
187
|
+
".json"
|
|
188
|
+
],
|
|
189
|
+
dependencyType: "esm"
|
|
190
|
+
});
|
|
191
|
+
const resolveAsset = resolver({});
|
|
192
|
+
const designSystem = await designSystems.use(JSON.stringify([
|
|
193
|
+
options.compiler,
|
|
194
|
+
options.root,
|
|
195
|
+
options.mode
|
|
196
|
+
]), probe, async () => {
|
|
197
|
+
const recorder = recordInputs(probe);
|
|
198
|
+
const loaded = await loadCssGraph(path.resolve(options.root, cssEntrypoint(options.compiler)), buildCompilerOptions(options.compiler), {
|
|
199
|
+
read: recorder.read,
|
|
200
|
+
documentUri: (id) => pathToFileURL(id).href,
|
|
201
|
+
sourceMapSource: (id) => pathToFileURL(id).href,
|
|
202
|
+
watch: recorder.watch,
|
|
203
|
+
watchDirectory: recorder.watchDirectory,
|
|
204
|
+
resolve: resolver({
|
|
205
|
+
conditionNames: [
|
|
206
|
+
"style",
|
|
207
|
+
"import",
|
|
208
|
+
"default"
|
|
209
|
+
],
|
|
210
|
+
extensions: [".css"],
|
|
211
|
+
mainFields: ["style", "main"]
|
|
212
|
+
}),
|
|
213
|
+
plugins: nodePluginHost
|
|
214
|
+
}, void 0, void 0, {
|
|
215
|
+
plugins: options.compiler.plugins,
|
|
216
|
+
tailwind: options.compiler.tailwind,
|
|
217
|
+
important: options.compiler.important,
|
|
218
|
+
root: options.root
|
|
219
|
+
});
|
|
220
|
+
const release = options.mode === "release";
|
|
221
|
+
const entries = options.entries.map((entry) => path.resolve(options.root, entry));
|
|
222
|
+
const watcher = release ? void 0 : watchSources(options.root);
|
|
223
|
+
const shared = release || watcher ? new SharedTypeFacts(resolveTypeFactsEnvironment(options.root, options.compiler.tsconfig)) : void 0;
|
|
224
|
+
const sourceEntries = shared ? await buildSourceEntries(entries, configuration.scope) : void 0;
|
|
225
|
+
const session = (domain) => new IntegrationSession(options.root, loaded.loader, options.compiler, false, options.mode, loaded.plugins, release ? sourceEntries : void 0, release ? void 0 : sourceEntries, shared, domain);
|
|
226
|
+
const value = {
|
|
227
|
+
loaded,
|
|
228
|
+
compiler: session("loader"),
|
|
229
|
+
graphCompiler: session("graph"),
|
|
230
|
+
shared,
|
|
231
|
+
scans: shared ? /* @__PURE__ */ new Map() : void 0
|
|
232
|
+
};
|
|
233
|
+
watcher?.add(new WeakRef(value));
|
|
234
|
+
return {
|
|
235
|
+
value,
|
|
236
|
+
inputs: await recorder.finish()
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
const { loaded, compiler, graphCompiler } = designSystem.value;
|
|
240
|
+
if (designSystem.value.unverified) {
|
|
241
|
+
designSystem.value.unverified = false;
|
|
242
|
+
const current = (id) => readFile(id, "utf8").catch((error) => {
|
|
243
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") return;
|
|
244
|
+
throw error;
|
|
245
|
+
});
|
|
246
|
+
designSystem.value.verification = Promise.all([compiler.verifySources(current), graphCompiler.verifySources(current)]).then(() => {});
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await designSystem.value.verification;
|
|
250
|
+
} catch (error) {
|
|
251
|
+
designSystem.done();
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
for (const file of designSystem.inputs.files.keys()) watch(file);
|
|
255
|
+
for (const file of designSystem.inputs.missing) context.addMissingDependency(file);
|
|
256
|
+
for (const directory of designSystem.inputs.directories) context.addContextDependency(directory);
|
|
257
|
+
return {
|
|
258
|
+
options,
|
|
259
|
+
compiler,
|
|
260
|
+
graphCompiler,
|
|
261
|
+
host: {
|
|
262
|
+
describe: (id) => fileModuleDescriptor(options.root, id),
|
|
263
|
+
read,
|
|
264
|
+
watch,
|
|
265
|
+
resolve: async (specifier, importer) => isBuiltin(specifier) || specifier === "server-only" || specifier === "client-only" ? {
|
|
266
|
+
id: specifier,
|
|
267
|
+
external: true
|
|
268
|
+
} : { id: path.isAbsolute(specifier) ? path.normalize(specifier) : await resolveJs(specifier, importer) },
|
|
269
|
+
warn: (message) => {
|
|
270
|
+
context.emitWarning(new Error(message));
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
loaded,
|
|
274
|
+
scans: designSystem.value.scans,
|
|
275
|
+
resolveAsset,
|
|
276
|
+
release: designSystem.done
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.
|
|
281
|
+
*
|
|
282
|
+
* Calls with the same graph compiler run one at a time. A producer is compiled again only when its
|
|
283
|
+
* source or the source of a local module that it reaches changed since the previous call.
|
|
284
|
+
*
|
|
285
|
+
* @param entries - Entry paths, absolute or relative to the evaluated project root. Statically
|
|
286
|
+
* named imports, including lazy imports, are followed. Dynamic request expressions are not traversed.
|
|
287
|
+
* @param project - Loader project. The caller releases it after this operation.
|
|
288
|
+
* Its host receives warnings for the CSS statements that loading skipped and for rejected names.
|
|
289
|
+
* @returns A document plan selecting automatic producers, with a revision derived from visited
|
|
290
|
+
* source paths and contents. Explicit CSS values remain owned by their modules.
|
|
291
|
+
* @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.
|
|
292
|
+
*/
|
|
293
|
+
function compileGraph(entries, project) {
|
|
294
|
+
const run = (graphRuns.get(project.graphCompiler) ?? Promise.resolve()).catch(() => {}).then(() => reconstruct(entries, project));
|
|
295
|
+
graphRuns.set(project.graphCompiler, run);
|
|
296
|
+
return run;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Compiles the entry graph and plans its stylesheet for {@link compileGraph}.
|
|
300
|
+
*
|
|
301
|
+
* @param entries - Entry paths, absolute or relative to the evaluated project root.
|
|
302
|
+
* @param project - Loader project whose graph compiler no other reconstruction uses meanwhile.
|
|
303
|
+
* @returns A document plan for the automatic producers that the entries reach.
|
|
304
|
+
* @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.
|
|
305
|
+
*/
|
|
306
|
+
async function reconstruct(entries, project) {
|
|
307
|
+
const { options, graphCompiler: compiler, host } = project;
|
|
308
|
+
const scans = project.scans;
|
|
309
|
+
/**
|
|
310
|
+
* Reads a module, registers it as a dependency, and lists the local modules that it imports.
|
|
311
|
+
* @param id - Absolute file path.
|
|
312
|
+
* @returns The visited module.
|
|
313
|
+
* @throws If reading, scanning, or resolving one of its imports fails.
|
|
314
|
+
*/
|
|
315
|
+
const visit = async (id) => {
|
|
316
|
+
host.watch(id);
|
|
317
|
+
const source = await host.read(id);
|
|
318
|
+
compiler.sourceRead(id, source);
|
|
319
|
+
const cached = scans?.get(id);
|
|
320
|
+
if (cached?.source === source) return cached;
|
|
321
|
+
const descriptor = fileModuleDescriptor(options.root, id);
|
|
322
|
+
const scan = scanSource({
|
|
323
|
+
kind: "direct",
|
|
324
|
+
moduleId: descriptor.moduleId,
|
|
325
|
+
document: {
|
|
326
|
+
...descriptor.document,
|
|
327
|
+
code: source
|
|
328
|
+
},
|
|
329
|
+
syntax: descriptor.syntax
|
|
330
|
+
});
|
|
331
|
+
if (scan.kind === "failed") throw new CompilationFailure([scan.batch]);
|
|
332
|
+
const summary = scan.summary;
|
|
333
|
+
const resolved = await Promise.all(summary.moduleSpecifiers.map(({ source: specifier }) => isBuiltin(specifier) || specifier === "stillwind" || specifier.startsWith("stillwind/") ? Promise.resolve(void 0) : host.resolve(specifier, id)));
|
|
334
|
+
const imports = [];
|
|
335
|
+
for (const result of resolved) {
|
|
336
|
+
const file = result && cleanModuleId(result.id);
|
|
337
|
+
if (file && !result.external && !/[\\/]node_modules[\\/]/.test(file) && /\.[cm]?[jt]sx?$/.test(file)) imports.push(file);
|
|
338
|
+
}
|
|
339
|
+
const node = {
|
|
340
|
+
id,
|
|
341
|
+
source,
|
|
342
|
+
imports,
|
|
343
|
+
producer: Boolean(summary.macroImports || summary.moduleCssImports)
|
|
344
|
+
};
|
|
345
|
+
scans?.set(id, node);
|
|
346
|
+
return node;
|
|
347
|
+
};
|
|
348
|
+
const visited = /* @__PURE__ */ new Set();
|
|
349
|
+
const revision = createHash("sha256");
|
|
350
|
+
const nodes = [];
|
|
351
|
+
let level = entries.map((entry) => path.resolve(options.root, entry));
|
|
352
|
+
while (level.length) {
|
|
353
|
+
const unvisited = [...new Set(level)].filter((id) => !visited.has(id));
|
|
354
|
+
for (const id of unvisited) visited.add(id);
|
|
355
|
+
const visitedLevel = await Promise.all(unvisited.map(visit));
|
|
356
|
+
for (const node of visitedLevel) {
|
|
357
|
+
revision.update(node.id).update("\0").update(node.source).update("\0");
|
|
358
|
+
nodes.push(node);
|
|
359
|
+
}
|
|
360
|
+
level = visitedLevel.flatMap((node) => node.imports);
|
|
361
|
+
}
|
|
362
|
+
const outputs = graphOutputs.get(compiler) ?? /* @__PURE__ */ new Map();
|
|
363
|
+
graphOutputs.set(compiler, outputs);
|
|
364
|
+
/**
|
|
365
|
+
* Compiles a module and records its output.
|
|
366
|
+
*
|
|
367
|
+
* @param node - Visited module.
|
|
368
|
+
* @returns Whether a producer compilation ran.
|
|
369
|
+
*/
|
|
370
|
+
const compile = async (node) => {
|
|
371
|
+
const compiled = node.producer ? await compiler.compile(node.source, node.id, host, { moduleCssImport: "stillwind/module-css" }) : void 0;
|
|
372
|
+
outputs.set(node.id, {
|
|
373
|
+
source: node.source,
|
|
374
|
+
selected: compiled && !compiled.hasModuleCssImport ? compiled.moduleId : void 0
|
|
375
|
+
});
|
|
376
|
+
return node.producer;
|
|
377
|
+
};
|
|
378
|
+
const importers = /* @__PURE__ */ new Map();
|
|
379
|
+
for (const node of nodes) for (const imported of node.imports) importers.set(imported, [...importers.get(imported) ?? [], node.id]);
|
|
380
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
381
|
+
const queue = [];
|
|
382
|
+
const compiled = /* @__PURE__ */ new Set();
|
|
383
|
+
for (const node of nodes) {
|
|
384
|
+
if (outputs.get(node.id)?.source === node.source) continue;
|
|
385
|
+
compiled.add(node.id);
|
|
386
|
+
if (!await compile(node) || !compiler.keepsInterface(node.id)) queue.push(...(importers.get(node.id) ?? []).map((importer) => byId.get(importer)));
|
|
387
|
+
}
|
|
388
|
+
const stale = /* @__PURE__ */ new Set();
|
|
389
|
+
for (let node = queue.pop(); node; node = queue.pop()) {
|
|
390
|
+
if (stale.has(node.id)) continue;
|
|
391
|
+
stale.add(node.id);
|
|
392
|
+
for (const importer of importers.get(node.id) ?? []) queue.push(byId.get(importer));
|
|
393
|
+
}
|
|
394
|
+
const selection = [];
|
|
395
|
+
for (const node of nodes) {
|
|
396
|
+
if (stale.has(node.id) && !compiled.has(node.id)) await compile(node);
|
|
397
|
+
const selected = outputs.get(node.id)?.selected;
|
|
398
|
+
if (selected) selection.push(selected);
|
|
399
|
+
}
|
|
400
|
+
const plan = compiler.native.planStylesheet({
|
|
401
|
+
modules: selection,
|
|
402
|
+
coverage: {
|
|
403
|
+
kind: "complete",
|
|
404
|
+
target: "entry-graph",
|
|
405
|
+
revision: revision.digest("hex")
|
|
406
|
+
},
|
|
407
|
+
placement: "document"
|
|
408
|
+
});
|
|
409
|
+
warnSkippedCss(project.loaded.skipped, (message) => host.warn(message));
|
|
410
|
+
warnRejectedNames(plan.rejectedNames, (message) => host.warn(message));
|
|
411
|
+
return plan;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Last graph compilation results of each graph compiler, keyed by absolute file path. A compiler
|
|
415
|
+
* keeps the compiled state of every module, so a reconstruction compiles only modules whose sources
|
|
416
|
+
* or imported modules changed since the previous reconstruction. Only reconstructions compile with
|
|
417
|
+
* a graph compiler: a per-module compilation of another source would replace a module's state
|
|
418
|
+
* without changing its result here.
|
|
419
|
+
*/
|
|
420
|
+
const graphOutputs = /* @__PURE__ */ new WeakMap();
|
|
421
|
+
/**
|
|
422
|
+
* Latest reconstruction of each graph compiler. A concurrent reconstruction could publish a module
|
|
423
|
+
* from an older snapshot after a newer reconstruction recorded the newer source.
|
|
424
|
+
*/
|
|
425
|
+
const graphRuns = /* @__PURE__ */ new WeakMap();
|
|
426
|
+
export { createProject as n, compileGraph as t };
|
|
427
|
+
|
|
428
|
+
//# sourceMappingURL=project-egWF2vWJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-egWF2vWJ.js","names":["watchDirectory"],"sources":["../src/turbopack/project.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { watch as watchDirectory, type FSWatcher } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nimport type { BuildConfig, SerializableInlineConfig } from \"@stillwind/config\";\nimport { resolveIntegrationConfig, type ResolvedIntegrationConfig } from \"@stillwind/config/node\";\nimport {\n cleanModuleId,\n CompilationFailure,\n cssEntrypoint,\n fileModuleDescriptor,\n loadCssGraph,\n nodePluginHost,\n resolveTypeFactsEnvironment,\n warnRejectedNames,\n type CompilerHost,\n type LoadedCssGraph,\n} from \"@stillwind/host\";\nimport { scanSource } from \"@stillwind/native\";\nimport type { LoaderContext } from \"webpack\";\n\nimport { nativeBindingFiles } from \"../binding-files.ts\";\nimport { LoaderCache, recordInputs, type InputReader } from \"../loader-cache.ts\";\nimport {\n buildCompilerOptions,\n IntegrationSession,\n SharedTypeFacts,\n warnSkippedCss,\n} from \"../session.ts\";\nimport { buildSourceEntries } from \"../source-entries.ts\";\n\n/**\n * Removes readonly constraints recursively so cloned inline settings fit the bundler's loader transport.\n */\ntype MutableSettings<T> = T extends readonly (infer Item)[]\n ? MutableSettings<Item>[]\n : T extends object\n ? { -readonly [K in keyof T]: MutableSettings<T[K]> }\n : T;\n\n/**\n * Serializable compiler settings and entry selection passed to Turbopack's isolated loaders.\n */\nexport type TurbopackLoaderOptions = {\n /** Configuration file selection and serializable inline settings. */\n compiler: MutableSettings<SerializableInlineConfig>;\n /** Application directory, absolute or relative to the loader context's root. */\n root: string;\n /** Entry files whose imports are traversed when reconstructing document CSS. */\n entries: string[];\n /** Compiler mode, normally `development` or `release`. */\n mode: string;\n};\n\n/**\n * Compiler session and host operations that one Turbopack or Next loader invocation uses.\n */\nexport interface TurbopackProject {\n /** Evaluated compiler settings with an absolute project root, captured entry selection, and mode. */\n options: Omit<TurbopackLoaderOptions, \"compiler\"> & {\n /** Evaluated settings selected from configuration and inline overrides. */\n compiler: BuildConfig;\n };\n /**\n * Compiler that other invocations in the same process may use at the same time. The caller must\n * not close it.\n */\n compiler: IntegrationSession;\n /**\n * Compiler that only {@link compileGraph} uses, so that its compiled modules match the sources\n * that the previous reconstruction read. Resource owners in its plans resolve through it.\n */\n graphCompiler: IntegrationSession;\n /** Filesystem, source metadata, resolver, dependency watcher, and warning operations. */\n host: TurbopackHost;\n /** Completed CSS graph and authored resources used by the compiler. */\n loaded: LoadedCssGraph;\n /**\n * Modules that earlier reconstructions visited, keyed by absolute file path. A reconstruction\n * reuses the imports of a module whose source is unchanged. Absent when the process cannot learn\n * about added and removed files, which can change how an unchanged import resolves.\n */\n scans?: Map<string, GraphNode>;\n /**\n * Resolves an asset with the loader context's default resolver.\n *\n * @param specifier - Resource request text from CSS or a producer.\n * @param importer - Absolute identity of the resource owner.\n * @returns A promise for the resolved asset identity. Unresolved requests reject the promise.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n /**\n * Ends this invocation's use of the compiler and design system. The caller must call it after\n * compilation or stylesheet reconstruction, and must not use the project afterward.\n */\n release: () => void;\n}\n\n/**\n * Design system and compiler shared by loader invocations with equal settings.\n */\ninterface SharedDesignSystem {\n loaded: LoadedCssGraph;\n compiler: IntegrationSession;\n graphCompiler: IntegrationSession;\n /**\n * Checker and prepared sources of both compilers. Absent in development when the process cannot\n * watch the application directory.\n */\n shared?: SharedTypeFacts;\n /** Modules that reconstructions visited, as {@link TurbopackProject.scans} describes. */\n scans?: Map<string, GraphNode>;\n /** Whether the directory watcher missed changes since the compilers last compared their sources. */\n unverified?: boolean;\n /** Comparison of the sources with the files after missed changes, which loader calls await. */\n verification?: Promise<void>;\n}\n\n/**\n * Evaluated configuration keyed by loader options and the application directory. It is evaluated\n * again when one of its files changes.\n */\nconst configurations = new LoaderCache<ResolvedIntegrationConfig>();\n\n/**\n * Design systems keyed by evaluated settings and mode. The checker of an idle compiler stops after\n * this time, so that a worker process does not keep a checker process running.\n */\nconst designSystems = new LoaderCache<SharedDesignSystem>(closeDesignSystem, 30_000);\n\n/**\n * Closes the checkers of a design system's compilers and discards their shared sources. The design\n * system stays usable, and a later compilation loads the sources again.\n *\n * @param designSystem - Design system whose compilers to close.\n */\nfunction closeDesignSystem({ compiler, graphCompiler, shared }: SharedDesignSystem): void {\n compiler.close();\n graphCompiler.close();\n shared?.close();\n}\n\n/**\n * Design systems of development compilers, keyed by the application directory that one recursive\n * watcher of this process observes. A design system that the cache dropped can be collected.\n */\nconst sourceWatchers = new Map<string, Set<WeakRef<SharedDesignSystem>>>();\n\n/**\n * Starts or reuses a recursive watcher that reports changes of script, component, and JSON files\n * under an application directory to the compilers of registered design systems. Changes under\n * `node_modules`, `.next`, and `.git` are not reported. When the watcher reports a change without\n * a file name, which happens when changes overflow its buffer, the registered design systems\n * compare their sources with the files before their next use. That event and every added or removed\n * file also discard the modules that reconstructions visited. When the watcher fails, it closes, and\n * every registered design system discards its shared sources and stops reusing visited modules.\n *\n * Events can arrive after a compilation already read a changed file, so callers must also report\n * the text that they read through {@link IntegrationSession.sourceRead}.\n *\n * @param root - Absolute application directory.\n * @returns The set in which to register design systems, or undefined when the platform cannot\n * watch the directory recursively.\n */\nfunction watchSources(root: string): Set<WeakRef<SharedDesignSystem>> | undefined {\n const existing = sourceWatchers.get(root);\n if (existing) {\n return existing;\n }\n const targets = new Set<WeakRef<SharedDesignSystem>>();\n /**\n * Calls an operation for every registered design system that is still reachable.\n *\n * @param operation - Operation that receives the design system.\n */\n const each = (operation: (designSystem: SharedDesignSystem) => void) => {\n for (const target of targets) {\n const designSystem = target.deref();\n if (designSystem) {\n operation(designSystem);\n } else {\n targets.delete(target);\n }\n }\n };\n let watcher: FSWatcher;\n try {\n watcher = watchDirectory(root, { recursive: true, persistent: false }, (event, name) => {\n if (!name) {\n each((designSystem) => {\n designSystem.unverified = true;\n designSystem.scans?.clear();\n });\n return;\n }\n if (\n /(?:^|[\\\\/])(?:node_modules|\\.next|\\.git)[\\\\/]/.test(name) ||\n !/\\.(?:[cm]?[jt]sx?|json|astro|svelte|vue)$/.test(name)\n ) {\n return;\n }\n const file = path.join(root, name);\n // A rename event reports an added or removed file, which can change import resolution.\n each((designSystem) => {\n designSystem.compiler.sourceChanged(file, event === \"rename\");\n designSystem.graphCompiler.sourceChanged(file, event === \"rename\");\n if (event === \"rename\") {\n designSystem.scans?.clear();\n }\n });\n });\n } catch {\n return undefined;\n }\n watcher.on(\"error\", () => {\n watcher.close();\n sourceWatchers.delete(root);\n each((designSystem) => {\n designSystem.scans = undefined;\n closeDesignSystem(designSystem);\n });\n });\n sourceWatchers.set(root, targets);\n return targets;\n}\n\n/**\n * Compiler host whose resolver returns an identity or rejects instead of returning null.\n */\nexport interface TurbopackHost extends CompilerHost {\n /**\n * Resolves a script dependency or marks a Node builtin or Next boundary marker as external.\n *\n * @param specifier - Script request text, including any resource query.\n * @param importer - Absolute identity of the importing source.\n * @returns A promise for the resolved identity and optional external status. Resolution failures\n * reject the promise.\n */\n resolve: (\n specifier: string,\n importer: string,\n ) => Promise<{\n /** Resolved absolute source identity or external module name. */\n id: string;\n /** Whether the graph must skip loading this module as source. */\n external?: boolean;\n }>;\n}\n\n/**\n * Loads the design system and compiler for a Turbopack or Next loader invocation, or reuses them.\n *\n * Invocations in one process share the evaluated configuration while its files keep their contents,\n * and share the design system and compiler while the configuration and the CSS files stay\n * unchanged. Configuration dependencies, missing discovery candidates, compiler files, and CSS\n * dependencies are registered with the loader context of every invocation.\n *\n * @param context - Loader context containing serializable discovery settings, the bundler root,\n * filesystem access, resolver operations, and dependency tracking.\n * @returns A promise for the project. The caller must call its `release` function after its last use.\n * @throws If configuration evaluation or project selection fails, the CSS graph cannot be loaded,\n * or compiler initialization fails.\n */\nexport async function createProject(\n context: LoaderContext<TurbopackLoaderOptions>,\n): Promise<TurbopackProject> {\n const supplied = context.getOptions();\n const applicationRoot = path.resolve(context.rootContext, supplied.root);\n /**\n * Reads text through Turbopack's loader filesystem.\n * @param id - File path accepted by the loader filesystem.\n * @returns File contents converted to a string.\n * @throws If the filesystem reports a read error.\n */\n const read = (id: string) =>\n new Promise<string>((done, reject) => {\n context.fs.readFile(id, (error, contents) =>\n error ? reject(error) : done(String(contents)),\n );\n });\n const probe: InputReader = (id) =>\n read(id).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\" || error.code === \"ENOTDIR\") {\n return undefined;\n }\n throw error;\n });\n const configurationLease = await configurations.use(\n JSON.stringify([supplied.compiler, applicationRoot]),\n probe,\n async () => {\n const value = await resolveIntegrationConfig(supplied.compiler, applicationRoot);\n const recorder = recordInputs(probe);\n for (const file of value.dependencies) {\n recorder.watch(file);\n }\n for (const file of value.missing) {\n recorder.watchMissing(file);\n }\n return { value, inputs: await recorder.finish() };\n },\n );\n configurationLease.done();\n const configuration = configurationLease.value;\n const options = {\n ...supplied,\n compiler: configuration.config,\n root: configuration.config.root,\n };\n /**\n * Registers a file whose changes invalidate this loader result.\n * @param id - Filesystem path for configuration, compiler code, CSS, or a resolved dependency.\n */\n const watch = (id: string) => {\n context.addDependency(id);\n };\n for (const file of configuration.dependencies) {\n watch(file);\n }\n for (const file of configuration.missing) {\n context.addMissingDependency(file);\n }\n for (const file of nativeBindingFiles()) {\n watch(file);\n }\n watch(fileURLToPath(import.meta.resolve(\"@stillwind/host\")));\n watch(import.meta.filename);\n for (const file of [\"loader.js\", \"css-loader.js\"]) {\n watch(\n fileURLToPath(new URL(`./${file}`, import.meta.resolve(\"@stillwind/integration/turbopack\"))),\n );\n }\n /**\n * Adapts a Turbopack resolver to imports relative to a source file.\n *\n * @param settings - Resolution policy passed to the loader's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. Its promise\n * rejects on resolver errors or missing results, and otherwise returns the resolved identity.\n */\n const resolver = (settings: Parameters<typeof context.getResolve>[0]) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) => {\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error\n ? reject(error)\n : id\n ? done(id)\n : reject(new Error(`Cannot resolve ${specifier} from ${importer}`)),\n );\n });\n };\n const resolveJs = resolver({\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".json\"],\n dependencyType: \"esm\",\n });\n const resolveAsset = resolver({});\n const designSystem = await designSystems.use(\n JSON.stringify([options.compiler, options.root, options.mode]),\n probe,\n async () => {\n const recorder = recordInputs(probe);\n const loaded = await loadCssGraph(\n path.resolve(options.root, cssEntrypoint(options.compiler)),\n buildCompilerOptions(options.compiler),\n {\n read: recorder.read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch: recorder.watch,\n watchDirectory: recorder.watchDirectory,\n // The resolver belongs to this invocation's context. Later invocations reuse only the\n // loaded graph, which does not resolve CSS again.\n resolve: resolver({\n conditionNames: [\"style\", \"import\", \"default\"],\n extensions: [\".css\"],\n mainFields: [\"style\", \"main\"],\n }),\n plugins: nodePluginHost,\n },\n undefined,\n undefined,\n {\n plugins: options.compiler.plugins,\n tailwind: options.compiler.tailwind,\n important: options.compiler.important,\n root: options.root,\n },\n );\n // Both compilers load the project files into one checker when its project is empty. Files\n // do not change during a production build. A development server does not report file\n // changes to loaders, so the process watches the application directory itself. When it\n // cannot, each compilation reads the files again.\n const release = options.mode === \"release\";\n const entries = options.entries.map((entry) => path.resolve(options.root, entry));\n const watcher = release ? undefined : watchSources(options.root);\n const shared =\n release || watcher\n ? new SharedTypeFacts(\n resolveTypeFactsEnvironment(options.root, options.compiler.tsconfig),\n )\n : undefined;\n const sourceEntries = shared\n ? await buildSourceEntries(entries, configuration.scope)\n : undefined;\n const session = (domain: string) =>\n new IntegrationSession(\n options.root,\n loaded.loader,\n options.compiler,\n false,\n options.mode,\n loaded.plugins,\n release ? sourceEntries : undefined,\n release ? undefined : sourceEntries,\n shared,\n domain,\n );\n const value = {\n loaded,\n compiler: session(\"loader\"),\n graphCompiler: session(\"graph\"),\n shared,\n scans: shared ? new Map<string, GraphNode>() : undefined,\n };\n watcher?.add(new WeakRef(value));\n return {\n value,\n inputs: await recorder.finish(),\n };\n },\n );\n const { loaded, compiler, graphCompiler } = designSystem.value;\n if (designSystem.value.unverified) {\n designSystem.value.unverified = false;\n // The loader filesystem can return the previous text of a file right after an edit.\n const current = (id: string) =>\n readFile(id, \"utf8\").catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\" || error.code === \"ENOTDIR\") {\n return undefined;\n }\n throw error;\n });\n designSystem.value.verification = Promise.all([\n compiler.verifySources(current),\n graphCompiler.verifySources(current),\n ]).then(() => {});\n }\n try {\n await designSystem.value.verification;\n } catch (error) {\n designSystem.done();\n throw error;\n }\n for (const file of designSystem.inputs.files.keys()) {\n watch(file);\n }\n for (const file of designSystem.inputs.missing) {\n context.addMissingDependency(file);\n }\n for (const directory of designSystem.inputs.directories) {\n context.addContextDependency(directory);\n }\n const host = {\n describe: (id: string) => fileModuleDescriptor(options.root, id),\n read,\n watch,\n resolve: async (specifier: string, importer: string) =>\n // Next checks boundary markers when it builds server and client modules.\n // They provide no styles for this graph and do not use its loader resolver.\n isBuiltin(specifier) || specifier === \"server-only\" || specifier === \"client-only\"\n ? {\n id: specifier,\n external: true,\n }\n : {\n // Turbopack's resolver rewrites an absolute request to a relative one with native\n // separators, which it cannot resolve. Project files reach the compiler as absolute\n // paths.\n id: path.isAbsolute(specifier)\n ? path.normalize(specifier)\n : await resolveJs(specifier, importer),\n },\n warn: (message: string) => {\n context.emitWarning(new Error(message));\n },\n };\n return {\n options,\n compiler,\n graphCompiler,\n host,\n loaded,\n scans: designSystem.value.scans,\n resolveAsset,\n release: designSystem.done,\n };\n}\n\n/**\n * Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.\n *\n * Calls with the same graph compiler run one at a time. A producer is compiled again only when its\n * source or the source of a local module that it reaches changed since the previous call.\n *\n * @param entries - Entry paths, absolute or relative to the evaluated project root. Statically\n * named imports, including lazy imports, are followed. Dynamic request expressions are not traversed.\n * @param project - Loader project. The caller releases it after this operation.\n * Its host receives warnings for the CSS statements that loading skipped and for rejected names.\n * @returns A document plan selecting automatic producers, with a revision derived from visited\n * source paths and contents. Explicit CSS values remain owned by their modules.\n * @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.\n */\nexport function compileGraph(entries: readonly string[], project: TurbopackProject) {\n const previous = graphRuns.get(project.graphCompiler) ?? Promise.resolve();\n const run = previous.catch(() => {}).then(() => reconstruct(entries, project));\n graphRuns.set(project.graphCompiler, run);\n return run;\n}\n\n/**\n * Compiles the entry graph and plans its stylesheet for {@link compileGraph}.\n *\n * @param entries - Entry paths, absolute or relative to the evaluated project root.\n * @param project - Loader project whose graph compiler no other reconstruction uses meanwhile.\n * @returns A document plan for the automatic producers that the entries reach.\n * @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.\n */\nasync function reconstruct(entries: readonly string[], project: TurbopackProject) {\n const { options, graphCompiler: compiler, host } = project;\n const scans = project.scans;\n /**\n * Reads a module, registers it as a dependency, and lists the local modules that it imports.\n * @param id - Absolute file path.\n * @returns The visited module.\n * @throws If reading, scanning, or resolving one of its imports fails.\n */\n const visit = async (id: string): Promise<GraphNode> => {\n host.watch(id);\n const source = await host.read(id);\n compiler.sourceRead(id, source);\n const cached = scans?.get(id);\n if (cached?.source === source) {\n return cached;\n }\n const descriptor = fileModuleDescriptor(options.root, id);\n const scan = scanSource({\n kind: \"direct\",\n moduleId: descriptor.moduleId,\n document: {\n ...descriptor.document,\n code: source,\n },\n syntax: descriptor.syntax,\n });\n if (scan.kind === \"failed\") {\n throw new CompilationFailure([scan.batch]);\n }\n const summary = scan.summary;\n const resolved = await Promise.all(\n summary.moduleSpecifiers.map(({ source: specifier }) =>\n isBuiltin(specifier) || specifier === \"stillwind\" || specifier.startsWith(\"stillwind/\")\n ? Promise.resolve(undefined)\n : host.resolve(specifier, id),\n ),\n );\n const imports: string[] = [];\n for (const result of resolved) {\n const file = result && cleanModuleId(result.id);\n if (\n file &&\n !result.external &&\n !/[\\\\/]node_modules[\\\\/]/.test(file) &&\n /\\.[cm]?[jt]sx?$/.test(file)\n ) {\n imports.push(file);\n }\n }\n const node = {\n id,\n source,\n imports,\n producer: Boolean(summary.macroImports || summary.moduleCssImports),\n };\n scans?.set(id, node);\n return node;\n };\n // Modules of one breadth-first level are visited concurrently. The node order equals the order\n // of a sequential breadth-first traversal, so the revision and compilation order do not depend\n // on read timing.\n const visited = new Set<string>();\n const revision = createHash(\"sha256\");\n const nodes: GraphNode[] = [];\n let level = entries.map((entry) => path.resolve(options.root, entry));\n while (level.length) {\n const unvisited = [...new Set(level)].filter((id) => !visited.has(id));\n for (const id of unvisited) {\n visited.add(id);\n }\n const visitedLevel = await Promise.all(unvisited.map(visit));\n for (const node of visitedLevel) {\n revision.update(node.id).update(\"\\0\").update(node.source).update(\"\\0\");\n nodes.push(node);\n }\n level = visitedLevel.flatMap((node) => node.imports);\n }\n const outputs = graphOutputs.get(compiler) ?? new Map<string, GraphOutput>();\n graphOutputs.set(compiler, outputs);\n /**\n * Compiles a module and records its output.\n *\n * @param node - Visited module.\n * @returns Whether a producer compilation ran.\n */\n const compile = async (node: GraphNode) => {\n const compiled = node.producer\n ? await compiler.compile(node.source, node.id, host, {\n moduleCssImport: \"stillwind/module-css\",\n })\n : undefined;\n outputs.set(node.id, {\n source: node.source,\n selected: compiled && !compiled.hasModuleCssImport ? compiled.moduleId : undefined,\n });\n return node.producer;\n };\n const importers = new Map<string, string[]>();\n for (const node of nodes) {\n for (const imported of node.imports) {\n importers.set(imported, [...(importers.get(imported) ?? []), node.id]);\n }\n }\n const byId = new Map(nodes.map((node) => [node.id, node]));\n // A module's output depends on the types of the local modules that it imports, so a change\n // also compiles every module that reaches the changed module. A changed producer that keeps\n // its exports gives its importers the same output, except for their checker diagnostics, which\n // are not refreshed until they are compiled for another reason.\n const queue: GraphNode[] = [];\n const compiled = new Set<string>();\n for (const node of nodes) {\n if (outputs.get(node.id)?.source === node.source) {\n continue;\n }\n compiled.add(node.id);\n if (!(await compile(node)) || !compiler.keepsInterface(node.id)) {\n queue.push(...(importers.get(node.id) ?? []).map((importer) => byId.get(importer)!));\n }\n }\n const stale = new Set<string>();\n for (let node = queue.pop(); node; node = queue.pop()) {\n if (stale.has(node.id)) {\n continue;\n }\n stale.add(node.id);\n for (const importer of importers.get(node.id) ?? []) {\n queue.push(byId.get(importer)!);\n }\n }\n const selection: string[] = [];\n for (const node of nodes) {\n if (stale.has(node.id) && !compiled.has(node.id)) {\n await compile(node);\n }\n const selected = outputs.get(node.id)?.selected;\n if (selected) {\n selection.push(selected);\n }\n }\n const plan = compiler.native.planStylesheet({\n modules: selection,\n coverage: {\n kind: \"complete\",\n target: \"entry-graph\",\n revision: revision.digest(\"hex\"),\n },\n placement: \"document\",\n });\n warnSkippedCss(project.loaded.skipped, (message) => host.warn(message));\n warnRejectedNames(plan.rejectedNames, (message) => host.warn(message));\n return plan;\n}\n\n/**\n * Local JavaScript or TypeScript module that a graph traversal visited.\n */\ninterface GraphNode {\n /** Absolute file path. */\n id: string;\n source: string;\n /** Absolute paths of the local modules that the source imports. */\n imports: string[];\n /** Whether the source imports a Stillwind macro or module CSS, so that it needs compilation. */\n producer: boolean;\n}\n\n/**\n * Result of the last graph compilation of one module.\n */\ninterface GraphOutput {\n /** Source text that the result was compiled from. */\n source: string;\n /** Compiler module ID that the document plan selects, or undefined when it selects nothing. */\n selected?: string;\n}\n\n/**\n * Last graph compilation results of each graph compiler, keyed by absolute file path. A compiler\n * keeps the compiled state of every module, so a reconstruction compiles only modules whose sources\n * or imported modules changed since the previous reconstruction. Only reconstructions compile with\n * a graph compiler: a per-module compilation of another source would replace a module's state\n * without changing its result here.\n */\nconst graphOutputs = new WeakMap<IntegrationSession, Map<string, GraphOutput>>();\n\n/**\n * Latest reconstruction of each graph compiler. A concurrent reconstruction could publish a module\n * from an older snapshot after a newer reconstruction recorded the newer source.\n */\nconst graphRuns = new WeakMap<IntegrationSession, Promise<unknown>>();\n"],"mappings":";;;;;;;;;;;;;;;;AA6HA,MAAM,iBAAiB,IAAI,YAAuC;;;;;AAMlE,MAAM,gBAAgB,IAAI,YAAgC,mBAAmB,GAAM;;;;;;;AAQnF,SAAS,kBAAkB,EAAE,UAAU,eAAe,UAAoC;CACxF,SAAS,MAAM;CACf,cAAc,MAAM;CACpB,QAAQ,MAAM;AAChB;;;;;AAMA,MAAM,iCAAiB,IAAI,IAA8C;;;;;;;;;;;;;;;;;AAkBzE,SAAS,aAAa,MAA4D;CAChF,MAAM,WAAW,eAAe,IAAI,IAAI;CACxC,IAAI,UACF,OAAO;CAET,MAAM,0BAAU,IAAI,IAAiC;;;;;;CAMrD,MAAM,QAAQ,cAA0D;EACtE,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,eAAe,OAAO,MAAM;GAClC,IAAI,cACF,UAAU,YAAY;QAEtB,QAAQ,OAAO,MAAM;EAEzB;CACF;CACA,IAAI;CACJ,IAAI;EACF,UAAUA,MAAe,MAAM;GAAE,WAAW;GAAM,YAAY;EAAM,IAAI,OAAO,SAAS;GACtF,IAAI,CAAC,MAAM;IACT,MAAM,iBAAiB;KACrB,aAAa,aAAa;KAC1B,aAAa,OAAO,MAAM;IAC5B,CAAC;IACD;GACF;GACA,IACE,gDAAgD,KAAK,IAAI,KACzD,CAAC,4CAA4C,KAAK,IAAI,GAEtD;GAEF,MAAM,OAAO,KAAK,KAAK,MAAM,IAAI;GAEjC,MAAM,iBAAiB;IACrB,aAAa,SAAS,cAAc,MAAM,UAAU,QAAQ;IAC5D,aAAa,cAAc,cAAc,MAAM,UAAU,QAAQ;IACjE,IAAI,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rationSession } from "./session-
|
|
1
|
+
import { t as IntegrationSession } from "./session-Cxf4D6oQ.js";
|
|
2
2
|
import { CompilerHost, LoadedCssGraph } from "@stillwind/host";
|
|
3
3
|
import { BuildConfig, SerializableInlineConfig } from "@stillwind/config";
|
|
4
4
|
import { LoaderContext } from "webpack";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Removes readonly constraints recursively so cloned inline settings fit the bundler's loader transport.
|
|
7
|
+
*/
|
|
6
8
|
type MutableSettings<T> = T extends readonly (infer Item)[] ? MutableSettings<Item>[] : T extends object ? { -readonly [K in keyof T]: MutableSettings<T[K]>; } : T;
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Serializable compiler settings and entry selection passed to Turbopack's isolated loaders.
|
|
11
|
+
*/
|
|
8
12
|
type TurbopackLoaderOptions = {
|
|
9
13
|
/** Configuration file selection and serializable inline settings. */
|
|
10
14
|
compiler: MutableSettings<SerializableInlineConfig>;
|
|
@@ -15,19 +19,35 @@ type TurbopackLoaderOptions = {
|
|
|
15
19
|
/** Compiler mode, normally `development` or `release`. */
|
|
16
20
|
mode: string;
|
|
17
21
|
};
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Compiler session and host operations that one Turbopack or Next loader invocation uses.
|
|
24
|
+
*/
|
|
19
25
|
interface TurbopackProject {
|
|
20
26
|
/** Evaluated compiler settings with an absolute project root, captured entry selection, and mode. */
|
|
21
27
|
options: Omit<TurbopackLoaderOptions, "compiler"> & {
|
|
22
28
|
/** Evaluated settings selected from configuration and inline overrides. */
|
|
23
29
|
compiler: BuildConfig;
|
|
24
30
|
};
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Compiler that other invocations in the same process may use at the same time. The caller must
|
|
33
|
+
* not close it.
|
|
34
|
+
*/
|
|
26
35
|
compiler: IntegrationSession;
|
|
36
|
+
/**
|
|
37
|
+
* Compiler that only {@link compileGraph} uses, so that its compiled modules match the sources
|
|
38
|
+
* that the previous reconstruction read. Resource owners in its plans resolve through it.
|
|
39
|
+
*/
|
|
40
|
+
graphCompiler: IntegrationSession;
|
|
27
41
|
/** Filesystem, source metadata, resolver, dependency watcher, and warning operations. */
|
|
28
42
|
host: TurbopackHost;
|
|
29
43
|
/** Completed CSS graph and authored resources used by the compiler. */
|
|
30
44
|
loaded: LoadedCssGraph;
|
|
45
|
+
/**
|
|
46
|
+
* Modules that earlier reconstructions visited, keyed by absolute file path. A reconstruction
|
|
47
|
+
* reuses the imports of a module whose source is unchanged. Absent when the process cannot learn
|
|
48
|
+
* about added and removed files, which can change how an unchanged import resolves.
|
|
49
|
+
*/
|
|
50
|
+
scans?: Map<string, GraphNode>;
|
|
31
51
|
/**
|
|
32
52
|
* Resolves an asset with the loader context's default resolver.
|
|
33
53
|
*
|
|
@@ -36,8 +56,15 @@ interface TurbopackProject {
|
|
|
36
56
|
* @returns A promise for the resolved asset identity. Unresolved requests reject the promise.
|
|
37
57
|
*/
|
|
38
58
|
resolveAsset: (specifier: string, importer: string) => Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Ends this invocation's use of the compiler and design system. The caller must call it after
|
|
61
|
+
* compilation or stylesheet reconstruction, and must not use the project afterward.
|
|
62
|
+
*/
|
|
63
|
+
release: () => void;
|
|
39
64
|
}
|
|
40
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Compiler host whose resolver returns an identity or rejects instead of returning null.
|
|
67
|
+
*/
|
|
41
68
|
interface TurbopackHost extends CompilerHost {
|
|
42
69
|
/**
|
|
43
70
|
* Resolves a script dependency or marks a Node builtin or Next boundary marker as external.
|
|
@@ -54,5 +81,17 @@ interface TurbopackHost extends CompilerHost {
|
|
|
54
81
|
external?: boolean;
|
|
55
82
|
}>;
|
|
56
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Local JavaScript or TypeScript module that a graph traversal visited.
|
|
86
|
+
*/
|
|
87
|
+
interface GraphNode {
|
|
88
|
+
/** Absolute file path. */
|
|
89
|
+
id: string;
|
|
90
|
+
source: string;
|
|
91
|
+
/** Absolute paths of the local modules that the source imports. */
|
|
92
|
+
imports: string[];
|
|
93
|
+
/** Whether the source imports a Stillwind macro or module CSS, so that it needs compilation. */
|
|
94
|
+
producer: boolean;
|
|
95
|
+
}
|
|
57
96
|
export { TurbopackProject as n, TurbopackLoaderOptions as t };
|
|
58
|
-
//# sourceMappingURL=project-
|
|
97
|
+
//# sourceMappingURL=project-mB7CODIs.d.ts.map
|
package/dist/rsbuild/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { InlineConfig, InlineConfig as IntegrationConfig } from "@stillwind/config";
|
|
2
2
|
import { RsbuildPlugin } from "@rsbuild/core";
|
|
3
3
|
import { RspackOptions } from "@rspack/core";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Rsbuild plugin that uses only the hook for updating the Rspack configuration.
|
|
6
|
+
*/
|
|
5
7
|
export interface StillwindRsbuildPlugin extends RsbuildPlugin {
|
|
6
8
|
/**
|
|
7
9
|
* Registers Stillwind's configuration changes through the host's Rspack hook.
|
|
@@ -11,6 +13,7 @@ export interface StillwindRsbuildPlugin extends RsbuildPlugin {
|
|
|
11
13
|
setup(api: {
|
|
12
14
|
/**
|
|
13
15
|
* Registers a modifier for each generated Rspack configuration.
|
|
16
|
+
*
|
|
14
17
|
* @param callback - Receives mutable host options and returns the configuration to use.
|
|
15
18
|
*/
|
|
16
19
|
modifyRspackConfig(callback: (options: RspackOptions) => RspackOptions): void;
|
package/dist/rsbuild/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as StillwindPlugin } from "../plugin-D-45o54j.js";
|
|
2
|
+
import { f as stillwindRules } from "../emission-BpaN4Z4m.js";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
// src/rsbuild/index.ts
|
|
5
5
|
/**
|