@stillwind/integration 0.0.0-stage → 0.1.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/dist/NPM-THIRD-PARTY-LICENSES +52 -0
  4. package/dist/astro/development.d.ts +15 -0
  5. package/dist/astro/development.js +34 -0
  6. package/dist/astro/development.js.map +1 -0
  7. package/dist/astro/index.d.ts +17 -0
  8. package/dist/astro/index.js +194 -0
  9. package/dist/astro/index.js.map +1 -0
  10. package/dist/astro/middleware.d.ts +2 -0
  11. package/dist/astro/middleware.js +64 -0
  12. package/dist/astro/middleware.js.map +1 -0
  13. package/dist/binding-files-Ds5NpyVV.js +45 -0
  14. package/dist/binding-files-Ds5NpyVV.js.map +1 -0
  15. package/dist/emission-BVi5aRbb.js +520 -0
  16. package/dist/emission-BVi5aRbb.js.map +1 -0
  17. package/dist/fresh/index.d.ts +10 -0
  18. package/dist/fresh/index.js +55 -0
  19. package/dist/fresh/index.js.map +1 -0
  20. package/dist/gen-mapping-D7jFzOEh.js +559 -0
  21. package/dist/gen-mapping-D7jFzOEh.js.map +1 -0
  22. package/dist/index-DFfbZxNT.d.ts +12 -0
  23. package/dist/next/css-loader.d.ts +14 -0
  24. package/dist/next/css-loader.js +58 -0
  25. package/dist/next/css-loader.js.map +1 -0
  26. package/dist/next/index.d.ts +15 -0
  27. package/dist/next/index.js +66 -0
  28. package/dist/next/index.js.map +1 -0
  29. package/dist/node-loader-D-3Ynpy1.d.ts +19 -0
  30. package/dist/nuxt/index.d.ts +13 -0
  31. package/dist/nuxt/index.js +64 -0
  32. package/dist/nuxt/index.js.map +1 -0
  33. package/dist/plugin-C_ZFfzo2.js +2572 -0
  34. package/dist/plugin-C_ZFfzo2.js.map +1 -0
  35. package/dist/plugin-aV0zIIAe.d.ts +278 -0
  36. package/dist/plugin-mPiBLdqa.js +79 -0
  37. package/dist/plugin-mPiBLdqa.js.map +1 -0
  38. package/dist/project-BNw0nZBE.d.ts +58 -0
  39. package/dist/project-C3IH7geC.js +182 -0
  40. package/dist/project-C3IH7geC.js.map +1 -0
  41. package/dist/project-DUGu8g_L.d.ts +15 -0
  42. package/dist/rsbuild/index.d.ts +28 -0
  43. package/dist/rsbuild/index.js +77 -0
  44. package/dist/rsbuild/index.js.map +1 -0
  45. package/dist/rspack/index.d.ts +3 -0
  46. package/dist/rspack/index.js +1 -0
  47. package/dist/rules-BvKsL2at.js +91 -0
  48. package/dist/rules-BvKsL2at.js.map +1 -0
  49. package/dist/session-B9_rp9TH.d.ts +72 -0
  50. package/dist/session-DHUCQMG5.js +117 -0
  51. package/dist/session-DHUCQMG5.js.map +1 -0
  52. package/dist/source-map-loader-CBLiYaBI.d.ts +128 -0
  53. package/dist/sveltekit/handle.d.ts +13 -0
  54. package/dist/sveltekit/handle.js +16 -0
  55. package/dist/sveltekit/handle.js.map +1 -0
  56. package/dist/trace-mapping-DV_eP3r7.d.ts +58 -0
  57. package/dist/turbopack/css-loader.d.ts +15 -0
  58. package/dist/turbopack/css-loader.js +44 -0
  59. package/dist/turbopack/css-loader.js.map +1 -0
  60. package/dist/turbopack/index.d.ts +54 -0
  61. package/dist/turbopack/index.js +1 -0
  62. package/dist/turbopack/loader.d.ts +13 -0
  63. package/dist/turbopack/loader.js +70 -0
  64. package/dist/turbopack/loader.js.map +1 -0
  65. package/dist/turbopack/node-loader.d.ts +2 -0
  66. package/dist/turbopack/node-loader.js +20 -0
  67. package/dist/turbopack/node-loader.js.map +1 -0
  68. package/dist/turbopack/stillwind-turbopack.css +0 -0
  69. package/dist/vite/index.d.ts +3 -0
  70. package/dist/vite/index.js +1 -0
  71. package/dist/vite/runtime-source-map.d.ts +19 -0
  72. package/dist/vite/runtime-source-map.js +106 -0
  73. package/dist/vite/runtime-source-map.js.map +1 -0
  74. package/dist/vite/runtime.d.ts +58 -0
  75. package/dist/vite/runtime.js +90 -0
  76. package/dist/vite/runtime.js.map +1 -0
  77. package/dist/webpack/css-loader.d.ts +17 -0
  78. package/dist/webpack/css-loader.js +36 -0
  79. package/dist/webpack/css-loader.js.map +1 -0
  80. package/dist/webpack/css-map-loader.d.ts +24 -0
  81. package/dist/webpack/css-map-loader.js +43 -0
  82. package/dist/webpack/css-map-loader.js.map +1 -0
  83. package/dist/webpack/document-loader.d.ts +12 -0
  84. package/dist/webpack/document-loader.js +19 -0
  85. package/dist/webpack/document-loader.js.map +1 -0
  86. package/dist/webpack/fragment-loader.d.ts +9 -0
  87. package/dist/webpack/fragment-loader.js +23 -0
  88. package/dist/webpack/fragment-loader.js.map +1 -0
  89. package/dist/webpack/index.d.ts +3 -0
  90. package/dist/webpack/index.js +1 -0
  91. package/dist/webpack/loader.d.ts +35 -0
  92. package/dist/webpack/loader.js +199 -0
  93. package/dist/webpack/loader.js.map +1 -0
  94. package/dist/webpack/source-loader.d.ts +11 -0
  95. package/dist/webpack/source-loader.js +17 -0
  96. package/dist/webpack/source-loader.js.map +1 -0
  97. package/dist/webpack/source-map-loader.d.ts +2 -0
  98. package/dist/webpack/source-map-loader.js +35 -0
  99. package/dist/webpack/source-map-loader.js.map +1 -0
  100. package/dist/webpack/stillwind-fragment.d.ts +1 -0
  101. package/dist/webpack/stillwind-fragment.js +1 -0
  102. package/dist/webpack/stillwind-webpack.css +1 -0
  103. package/package.json +133 -3
@@ -0,0 +1,278 @@
1
+ import { CssUpstreamMap, UpstreamSourceMap } from "@stillwind/host";
2
+ import { ResolvedIntegrationConfig } from "@stillwind/config/node";
3
+ import { BuildConfig, InlineConfig } from "@stillwind/config";
4
+ /** Resolver policies passed to webpack or Rspack for CSS, script, and asset imports. */
5
+ interface ResolveSettings {
6
+ /** Dependency category used to select bundler resolution behavior, such as `esm`. */
7
+ dependencyType?: string;
8
+ /** Package export conditions considered when resolving a request. */
9
+ conditionNames?: string[];
10
+ /** File extensions tested for extensionless requests, in resolution order. */
11
+ extensions?: string[];
12
+ /** Package metadata fields considered in resolution order. */
13
+ mainFields?: string[];
14
+ }
15
+ /**
16
+ * Completion handler for webpack or Rspack resolution.
17
+ *
18
+ * @param error - Resolution failure, or null or undefined when no error occurred.
19
+ * @param id - Resolved resource identity. A missing or false ID declines the request.
20
+ */
21
+ type ResolveCallback = (error?: Error | null, id?: string | false) => void;
22
+ /**
23
+ * Resolver bound to the bundler's configured conditions, extensions, and package fields.
24
+ *
25
+ * @param directory - Absolute directory of the importing file.
26
+ * @param specifier - Import or resource request text, including any query suffix.
27
+ * @param callback - Receives the resolution failure or resulting resource identity.
28
+ */
29
+ type Resolver = (directory: string, specifier: string, callback: ResolveCallback) => void;
30
+ /** Bundler filesystem and resolver operations shared by producer loaders and CSS reconstruction. */
31
+ interface ResolverHost {
32
+ /** Bundler input filesystem. Reads may return UTF-8 text or bytes through the callback. */
33
+ fs: {
34
+ /**
35
+ * Reads through the bundler filesystem rather than bypassing its virtual files.
36
+ * @param id - Filesystem identity without a resource query.
37
+ * @param callback - Receives an error or file contents. Callers convert successful contents to text.
38
+ */
39
+ readFile(id: string, callback: (error?: Error | null, value?: string | Buffer) => void): void;
40
+ };
41
+ /**
42
+ * Creates a callback resolver with the requested dependency policy.
43
+ *
44
+ * @param settings - Conditions, extensions, and package fields used for this resolver.
45
+ * @returns A resolver accepting the importer directory, request text, and a completion callback.
46
+ */
47
+ getResolve(settings: ResolveSettings): Resolver;
48
+ }
49
+ /**
50
+ * A producer and its captured dependencies stored in bundler metadata for CSS reconstruction.
51
+ */
52
+ interface ProducerInput {
53
+ /** Source text received by the producer loader, before Stillwind compilation. */
54
+ source: string;
55
+ /** Producer identity. Query-qualified script dependencies retain their query suffix. */
56
+ id: string;
57
+ /** Absolute project root against which compiler module identities are resolved. */
58
+ root: string;
59
+ /** Compiler configuration shared by every producer in this compilation. */
60
+ config: BuildConfig;
61
+ /**
62
+ * Whether this producer is excluded from automatic document CSS and supplies explicit CSS values.
63
+ */
64
+ manual: boolean;
65
+ /** Map from loader input back to the original source, used when composing final CSS maps. */
66
+ upstream?: CssUpstreamMap;
67
+ /**
68
+ * Transformed dependencies captured through the loader chain. Cached metadata retains them for
69
+ * reconstruction.
70
+ */
71
+ dependencies?: {
72
+ /** Complete resolver identity, including the query that selected the transformed dependency. */
73
+ id: string;
74
+ /** Source produced by the loaders that ran before Stillwind. */
75
+ source: string;
76
+ /**
77
+ * Map from the captured source back to its original source, when the preceding loaders supplied
78
+ * one.
79
+ */
80
+ upstream?: CssUpstreamMap;
81
+ }[];
82
+ }
83
+ /**
84
+ * Bundler module metadata used to recover cached producer inputs and identify the shared document
85
+ * CSS carrier.
86
+ */
87
+ interface EmissionModule {
88
+ /** Resource path and query used to identify the shared document CSS carrier. */
89
+ resource?: string;
90
+ /** Build metadata retained by the bundler when a module is reused from cache. */
91
+ buildInfo?: {
92
+ /** Producer input reconstructed after the compilation graph is complete. */
93
+ stillwind?: ProducerInput;
94
+ /** Build fields owned by the bundler or other plugins, retained without interpretation. */
95
+ [key: string]: unknown;
96
+ };
97
+ }
98
+ /**
99
+ * Compilation operations required to collect producers and rebuild document CSS carriers.
100
+ */
101
+ interface EmissionCompilation<Module extends EmissionModule = EmissionModule> {
102
+ /** Parent compilation used by CSS extraction loaders that run a child compiler. */
103
+ compiler?: {
104
+ parentCompilation?: EmissionCompilation<Module>;
105
+ };
106
+ /** Settings evaluated by StillwindPlugin before the build run, reused by producer loaders. */
107
+ __stillwindConfiguration?: ResolvedIntegrationConfig;
108
+ /** Missing configuration candidates whose creation must trigger a watch rebuild. */
109
+ missingDependencies: {
110
+ /**
111
+ * Registers a missing path so its creation invalidates this compilation.
112
+ *
113
+ * @param id - Absolute missing configuration candidate.
114
+ * @returns The bundler collection's insertion result, which Stillwind ignores.
115
+ */
116
+ add(id: string): unknown;
117
+ };
118
+ /** Compilation lifecycle operations used to wait for the completed producer graph. */
119
+ hooks: {
120
+ /** Runs after ordinary module builds, before document carriers are rebuilt. */
121
+ finishModules: {
122
+ /**
123
+ * Registers asynchronous CSS reconstruction for the completed modules.
124
+ *
125
+ * @param name - Plugin registration name.
126
+ * @param callback - Operation receiving cached and newly built modules. Rejections fail compilation.
127
+ */
128
+ tapPromise(name: string, callback: (modules: Iterable<Module>) => Promise<void>): void;
129
+ };
130
+ };
131
+ /** Files whose changes invalidate reconstructed CSS. */
132
+ fileDependencies: {
133
+ /**
134
+ * Adds a compiler or source file to watch tracking.
135
+ *
136
+ * @param id - Absolute dependency path.
137
+ * @returns The bundler collection's insertion result, which Stillwind ignores.
138
+ */
139
+ add(id: string): unknown;
140
+ };
141
+ /** Directories whose entry additions and removals invalidate reconstructed CSS. */
142
+ contextDependencies: {
143
+ /**
144
+ * Adds a directory that a plugin lists to watch tracking.
145
+ *
146
+ * @param id - Absolute directory path.
147
+ * @returns The bundler collection's insertion result, which Stillwind ignores.
148
+ */
149
+ add(id: string): unknown;
150
+ };
151
+ /** Bundler warning collection receiving compiler lint and rejected-name messages. */
152
+ warnings: {
153
+ /**
154
+ * Appends a warning without failing reconstruction.
155
+ *
156
+ * @param error - Warning represented as an Error instance.
157
+ * @returns The collection's append result, which Stillwind ignores.
158
+ */
159
+ push(error: Error): unknown;
160
+ };
161
+ /**
162
+ * Reruns a document carrier after reconstructed CSS has been stored on the compilation.
163
+ *
164
+ * @param module - Carrier from the completed module graph.
165
+ * @param callback - Completion handler receiving an error when rebuilding fails.
166
+ */
167
+ rebuildModule(module: Module, callback: (error?: Error | null) => void): void;
168
+ /**
169
+ * Reconstructed document CSS, optionally including an inline source map. Undefined before
170
+ * reconstruction.
171
+ */
172
+ __stillwindCss?: string;
173
+ }
174
+ /**
175
+ * Configures producer loaders and reconstructs document CSS for webpack and Rspack compilations.
176
+ */
177
+ declare class StillwindPlugin {
178
+ protected readonly config: InlineConfig;
179
+ /**
180
+ * Retains configuration selection and overrides for the plugin's loader rules.
181
+ * Files are evaluated in beforeRun and watchRun. The resulting settings are shared by that run's
182
+ * compilations. Constructor execution does not evaluate configuration.
183
+ *
184
+ * @param config - Configuration discovery, project selection, and inline compiler overrides.
185
+ * Omission discovers stillwind.config.* from the compiler context or process working directory.
186
+ */
187
+ constructor(config?: InlineConfig);
188
+ /**
189
+ * Prepends Stillwind rules before framework plugins can clone the rule list.
190
+ *
191
+ * The host retains its existing CSS pipeline for document carriers. Register this plugin before
192
+ * `VueLoaderPlugin` so cloned rules include Stillwind.
193
+ *
194
+ * @param rules - Mutable rule list from the compiler configuration.
195
+ */
196
+ protected configureRules(rules: unknown[]): void;
197
+ /**
198
+ * Installs loader rules, configuration evaluation hooks, and CSS reconstruction hooks.
199
+ * Evaluation errors fail the build run. Existing and missing configuration dependencies are
200
+ * registered on each compilation for watch tracking.
201
+ *
202
+ * @param compiler - webpack or Rspack compiler with a usable input filesystem and resolver. Call
203
+ * through the bundler's plugin setup before compilation begins.
204
+ */
205
+ apply<Module extends EmissionModule>(compiler: EmissionCompiler<Module>): void;
206
+ }
207
+ /**
208
+ * Compiler operations shared by webpack and Rspack for installing rules and registering each
209
+ * compilation.
210
+ */
211
+ interface EmissionCompiler<Module extends EmissionModule> {
212
+ /** Run and compilation hooks used to evaluate configuration before registering emission. */
213
+ hooks: {
214
+ /** Normal build hook that initializes settings before thisCompilation. */
215
+ beforeRun: {
216
+ /**
217
+ * Registers asynchronous work before a normal build run.
218
+ * @param name - Plugin registration name.
219
+ * @param callback - Configuration initializer whose rejection fails the run.
220
+ */
221
+ tapPromise(name: string, callback: () => Promise<void>): void;
222
+ };
223
+ /** Watch build hook that reevaluates settings before each compilation. */
224
+ watchRun: {
225
+ /**
226
+ * Registers asynchronous work before a watch build run.
227
+ * @param name - Plugin registration name.
228
+ * @param callback - Configuration initializer whose rejection fails the run.
229
+ */
230
+ tapPromise(name: string, callback: () => Promise<void>): void;
231
+ };
232
+ /** Hook that exposes each new compilation after run configuration has been initialized. */
233
+ thisCompilation: {
234
+ /**
235
+ * Registers settings, dependency watches, and emission on a new compilation.
236
+ * @param name - Plugin registration name.
237
+ * @param callback - Operation receiving the current compilation.
238
+ */
239
+ tap(name: string, callback: (compilation: EmissionCompilation<Module>) => void): void;
240
+ };
241
+ };
242
+ /** Bundler input filesystem, which must be initialized before compilation registration. */
243
+ inputFileSystem: ResolverHost["fs"] | null;
244
+ /** Mutable compiler options to which Stillwind loader rules are added. */
245
+ options: {
246
+ /** Application directory for configuration discovery. Omission uses process.cwd(). */
247
+ context?: string;
248
+ /** Bundler mode forwarded to reconstruction. Only development selects development compilation. */
249
+ mode?: string;
250
+ /** Module rule configuration, initialized by apply when absent. */
251
+ module?: {
252
+ /** Mutable rules retained by the compiler and extended before framework plugins clone them. */
253
+ rules?: unknown[];
254
+ };
255
+ };
256
+ /** Resolver factory bound to this compiler's filesystem and configuration. */
257
+ resolverFactory: {
258
+ /**
259
+ * Obtains a bundler resolver with a selected policy.
260
+ * @param type - Resolver category. Stillwind requests normal.
261
+ * @param settings - Import conditions, extensions, and package fields.
262
+ * @returns Resolver that reports completion through its callback.
263
+ */
264
+ get(type: string, settings: ResolveSettings): {
265
+ /**
266
+ * Resolves a request without changing compiler state.
267
+ * @param context - Bundler request metadata. Stillwind passes an empty object.
268
+ * @param directory - Absolute importer directory.
269
+ * @param specifier - Authored import or resource request.
270
+ * @param resolveContext - Bundler resolution metadata. Stillwind passes an empty object.
271
+ * @param callback - Receives a failure or resolved identity.
272
+ */
273
+ resolve(context: object, directory: string, specifier: string, resolveContext: object, callback: ResolveCallback): void;
274
+ };
275
+ };
276
+ }
277
+ export { StillwindPlugin as t };
278
+ //# sourceMappingURL=plugin-aV0zIIAe.d.ts.map
@@ -0,0 +1,79 @@
1
+ import { d as stillwindRules, t as installEmission } from "./emission-BVi5aRbb.js";
2
+ import { resolveIntegrationConfig } from "@stillwind/config/node";
3
+ import process from "node:process";
4
+ // src/webpack/plugin.ts
5
+ /**
6
+ * Configures producer loaders and reconstructs document CSS for webpack and Rspack compilations.
7
+ */
8
+ var StillwindPlugin = class {
9
+ config;
10
+ /**
11
+ * Retains configuration selection and overrides for the plugin's loader rules.
12
+ * Files are evaluated in beforeRun and watchRun. The resulting settings are shared by that run's
13
+ * compilations. Constructor execution does not evaluate configuration.
14
+ *
15
+ * @param config - Configuration discovery, project selection, and inline compiler overrides.
16
+ * Omission discovers stillwind.config.* from the compiler context or process working directory.
17
+ */
18
+ constructor(config = {}) {
19
+ this.config = config;
20
+ }
21
+ /**
22
+ * Prepends Stillwind rules before framework plugins can clone the rule list.
23
+ *
24
+ * The host retains its existing CSS pipeline for document carriers. Register this plugin before
25
+ * `VueLoaderPlugin` so cloned rules include Stillwind.
26
+ *
27
+ * @param rules - Mutable rule list from the compiler configuration.
28
+ */
29
+ configureRules(rules) {
30
+ rules.unshift(...stillwindRules(this.config));
31
+ }
32
+ /**
33
+ * Installs loader rules, configuration evaluation hooks, and CSS reconstruction hooks.
34
+ * Evaluation errors fail the build run. Existing and missing configuration dependencies are
35
+ * registered on each compilation for watch tracking.
36
+ *
37
+ * @param compiler - webpack or Rspack compiler with a usable input filesystem and resolver. Call
38
+ * through the bundler's plugin setup before compilation begins.
39
+ */
40
+ apply(compiler) {
41
+ compiler.options.module ??= {};
42
+ compiler.options.module.rules ??= [];
43
+ this.configureRules(compiler.options.module.rules);
44
+ let configuration;
45
+ /**
46
+ * Evaluates current configuration before a normal or watch build run.
47
+ * @returns Completion after the settings shared by subsequent compilations have been replaced.
48
+ * @throws If configuration discovery, evaluation, or project selection fails.
49
+ */
50
+ const configure = async () => {
51
+ configuration = await resolveIntegrationConfig(this.config, compiler.options.context ?? process.cwd());
52
+ };
53
+ compiler.hooks.beforeRun.tapPromise("StillwindConfiguration", configure);
54
+ compiler.hooks.watchRun.tapPromise("StillwindConfiguration", configure);
55
+ compiler.hooks.thisCompilation.tap("StillwindEmission", (compilation) => {
56
+ if (!configuration) throw new Error("Stillwind configuration has not been initialized");
57
+ compilation.__stillwindConfiguration = configuration;
58
+ for (const file of configuration.dependencies) compilation.fileDependencies.add(file);
59
+ for (const file of configuration.missing) compilation.missingDependencies.add(file);
60
+ installEmission({
61
+ _compilation: compilation,
62
+ fs: compiler.inputFileSystem,
63
+ mode: compiler.options.mode,
64
+ /**
65
+ * Adapts the compiler's normal resolver for document CSS reconstruction.
66
+ * @param settings - Requested dependency conditions, extensions, and metadata fields.
67
+ * @returns A callback resolver using the compiler's configured input filesystem.
68
+ */
69
+ getResolve(settings) {
70
+ const resolver = compiler.resolverFactory.get("normal", settings);
71
+ return (directory, specifier, callback) => resolver.resolve({}, directory, specifier, {}, callback);
72
+ }
73
+ });
74
+ });
75
+ }
76
+ };
77
+ export { StillwindPlugin as t };
78
+
79
+ //# sourceMappingURL=plugin-mPiBLdqa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-mPiBLdqa.js","names":[],"sources":["../src/webpack/plugin.ts"],"sourcesContent":["import process from \"node:process\";\n\nimport type { InlineConfig } from \"@stillwind/config\";\nimport { resolveIntegrationConfig, type ResolvedIntegrationConfig } from \"@stillwind/config/node\";\n\nimport { installEmission, type EmissionCompilation, type EmissionModule } from \"./emission.ts\";\nimport type { ResolveCallback, ResolverHost, ResolveSettings } from \"./host.ts\";\nimport { stillwindRules } from \"./rules.ts\";\n\n/**\n * Configures producer loaders and reconstructs document CSS for webpack and Rspack compilations.\n */\nexport class StillwindPlugin {\n /**\n * Retains configuration selection and overrides for the plugin's loader rules.\n * Files are evaluated in beforeRun and watchRun. The resulting settings are shared by that run's\n * compilations. Constructor execution does not evaluate configuration.\n *\n * @param config - Configuration discovery, project selection, and inline compiler overrides.\n * Omission discovers stillwind.config.* from the compiler context or process working directory.\n */\n constructor(protected readonly config: InlineConfig = {}) {}\n\n /**\n * Prepends Stillwind rules before framework plugins can clone the rule list.\n *\n * The host retains its existing CSS pipeline for document carriers. Register this plugin before\n * `VueLoaderPlugin` so cloned rules include Stillwind.\n *\n * @param rules - Mutable rule list from the compiler configuration.\n */\n protected configureRules(rules: unknown[]): void {\n rules.unshift(...stillwindRules(this.config));\n }\n\n /**\n * Installs loader rules, configuration evaluation hooks, and CSS reconstruction hooks.\n * Evaluation errors fail the build run. Existing and missing configuration dependencies are\n * registered on each compilation for watch tracking.\n *\n * @param compiler - webpack or Rspack compiler with a usable input filesystem and resolver. Call\n * through the bundler's plugin setup before compilation begins.\n */\n apply<Module extends EmissionModule>(compiler: EmissionCompiler<Module>): void {\n compiler.options.module ??= {};\n compiler.options.module.rules ??= [];\n this.configureRules(compiler.options.module.rules);\n let configuration: ResolvedIntegrationConfig | undefined;\n /**\n * Evaluates current configuration before a normal or watch build run.\n * @returns Completion after the settings shared by subsequent compilations have been replaced.\n * @throws If configuration discovery, evaluation, or project selection fails.\n */\n const configure = async () => {\n configuration = await resolveIntegrationConfig(\n this.config,\n compiler.options.context ?? process.cwd(),\n );\n };\n compiler.hooks.beforeRun.tapPromise(\"StillwindConfiguration\", configure);\n compiler.hooks.watchRun.tapPromise(\"StillwindConfiguration\", configure);\n compiler.hooks.thisCompilation.tap(\"StillwindEmission\", (compilation) => {\n if (!configuration) {\n throw new Error(\"Stillwind configuration has not been initialized\");\n }\n compilation.__stillwindConfiguration = configuration;\n for (const file of configuration.dependencies) {\n compilation.fileDependencies.add(file);\n }\n for (const file of configuration.missing) {\n compilation.missingDependencies.add(file);\n }\n installEmission({\n _compilation: compilation,\n fs: compiler.inputFileSystem!,\n mode: compiler.options.mode,\n /**\n * Adapts the compiler's normal resolver for document CSS reconstruction.\n * @param settings - Requested dependency conditions, extensions, and metadata fields.\n * @returns A callback resolver using the compiler's configured input filesystem.\n */\n getResolve(settings) {\n const resolver = compiler.resolverFactory.get(\"normal\", settings);\n return (directory, specifier, callback) =>\n resolver.resolve({}, directory, specifier, {}, callback);\n },\n });\n });\n }\n}\n\n/**\n * Compiler operations shared by webpack and Rspack for installing rules and registering each\n * compilation.\n */\ninterface EmissionCompiler<Module extends EmissionModule> {\n /** Run and compilation hooks used to evaluate configuration before registering emission. */\n hooks: {\n /** Normal build hook that initializes settings before thisCompilation. */\n beforeRun: {\n /**\n * Registers asynchronous work before a normal build run.\n * @param name - Plugin registration name.\n * @param callback - Configuration initializer whose rejection fails the run.\n */\n tapPromise(name: string, callback: () => Promise<void>): void;\n };\n /** Watch build hook that reevaluates settings before each compilation. */\n watchRun: {\n /**\n * Registers asynchronous work before a watch build run.\n * @param name - Plugin registration name.\n * @param callback - Configuration initializer whose rejection fails the run.\n */\n tapPromise(name: string, callback: () => Promise<void>): void;\n };\n /** Hook that exposes each new compilation after run configuration has been initialized. */\n thisCompilation: {\n /**\n * Registers settings, dependency watches, and emission on a new compilation.\n * @param name - Plugin registration name.\n * @param callback - Operation receiving the current compilation.\n */\n tap(name: string, callback: (compilation: EmissionCompilation<Module>) => void): void;\n };\n };\n /** Bundler input filesystem, which must be initialized before compilation registration. */\n inputFileSystem: ResolverHost[\"fs\"] | null;\n /** Mutable compiler options to which Stillwind loader rules are added. */\n options: {\n /** Application directory for configuration discovery. Omission uses process.cwd(). */\n context?: string;\n /** Bundler mode forwarded to reconstruction. Only development selects development compilation. */\n mode?: string;\n /** Module rule configuration, initialized by apply when absent. */\n module?: {\n /** Mutable rules retained by the compiler and extended before framework plugins clone them. */\n rules?: unknown[];\n };\n };\n /** Resolver factory bound to this compiler's filesystem and configuration. */\n resolverFactory: {\n /**\n * Obtains a bundler resolver with a selected policy.\n * @param type - Resolver category. Stillwind requests normal.\n * @param settings - Import conditions, extensions, and package fields.\n * @returns Resolver that reports completion through its callback.\n */\n get(\n type: string,\n settings: ResolveSettings,\n ): {\n /**\n * Resolves a request without changing compiler state.\n * @param context - Bundler request metadata. Stillwind passes an empty object.\n * @param directory - Absolute importer directory.\n * @param specifier - Authored import or resource request.\n * @param resolveContext - Bundler resolution metadata. Stillwind passes an empty object.\n * @param callback - Receives a failure or resolved identity.\n */\n resolve(\n context: object,\n directory: string,\n specifier: string,\n resolveContext: object,\n callback: ResolveCallback,\n ): void;\n };\n };\n}\n"],"mappings":";;;;;;;AAYA,IAAa,kBAAb,MAA6B;CASI;;;;;;;;;CAA/B,YAAY,SAA0C,CAAC,GAAG;EAA3B,KAAA,SAAA;CAA4B;;;;;;;;;CAU3D,eAAyB,OAAwB;EAC/C,MAAM,QAAQ,GAAG,eAAe,KAAK,MAAM,CAAC;CAC9C;;;;;;;;;CAUA,MAAqC,UAA0C;EAC7E,SAAS,QAAQ,WAAW,CAAC;EAC7B,SAAS,QAAQ,OAAO,UAAU,CAAC;EACnC,KAAK,eAAe,SAAS,QAAQ,OAAO,KAAK;EACjD,IAAI;;;;;;EAMJ,MAAM,YAAY,YAAY;GAC5B,gBAAgB,MAAM,yBACpB,KAAK,QACL,SAAS,QAAQ,WAAW,QAAQ,IAAI,CAC1C;EACF;EACA,SAAS,MAAM,UAAU,WAAW,0BAA0B,SAAS;EACvE,SAAS,MAAM,SAAS,WAAW,0BAA0B,SAAS;EACtE,SAAS,MAAM,gBAAgB,IAAI,sBAAsB,gBAAgB;GACvE,IAAI,CAAC,eACH,MAAM,IAAI,MAAM,kDAAkD;GAEpE,YAAY,2BAA2B;GACvC,KAAK,MAAM,QAAQ,cAAc,cAC/B,YAAY,iBAAiB,IAAI,IAAI;GAEvC,KAAK,MAAM,QAAQ,cAAc,SAC/B,YAAY,oBAAoB,IAAI,IAAI;GAE1C,gBAAgB;IACd,cAAc;IACd,IAAI,SAAS;IACb,MAAM,SAAS,QAAQ;;;;;;IAMvB,WAAW,UAAU;KACnB,MAAM,WAAW,SAAS,gBAAgB,IAAI,UAAU,QAAQ;KAChE,QAAQ,WAAW,WAAW,aAC5B,SAAS,QAAQ,CAAC,GAAG,WAAW,WAAW,CAAC,GAAG,QAAQ;IAC3D;GACF,CAAC;EACH,CAAC;CACH;AACF"}
@@ -0,0 +1,58 @@
1
+ import { t as IntegrationSession } from "./session-B9_rp9TH.js";
2
+ import { CompilerHost, LoadedCssGraph } from "@stillwind/host";
3
+ import { BuildConfig, SerializableInlineConfig } from "@stillwind/config";
4
+ import { LoaderContext } from "webpack";
5
+ /** Removes readonly constraints recursively so cloned inline settings fit the bundler's loader transport. */
6
+ type MutableSettings<T> = T extends readonly (infer Item)[] ? MutableSettings<Item>[] : T extends object ? { -readonly [K in keyof T]: MutableSettings<T[K]>; } : T;
7
+ /** Serializable compiler settings and entry selection passed to Turbopack's isolated loaders. */
8
+ type TurbopackLoaderOptions = {
9
+ /** Configuration file selection and serializable inline settings. */
10
+ compiler: MutableSettings<SerializableInlineConfig>;
11
+ /** Application directory, absolute or relative to the loader context's root. */
12
+ root: string;
13
+ /** Entry files whose imports are traversed when reconstructing document CSS. */
14
+ entries: string[];
15
+ /** Compiler mode, normally `development` or `release`. */
16
+ mode: string;
17
+ };
18
+ /** Compiler session and host operations owned by one Turbopack or Next loader invocation. */
19
+ interface TurbopackProject {
20
+ /** Evaluated compiler settings with an absolute project root, captured entry selection, and mode. */
21
+ options: Omit<TurbopackLoaderOptions, "compiler"> & {
22
+ /** Evaluated settings selected from configuration and inline overrides. */
23
+ compiler: BuildConfig;
24
+ };
25
+ /** Initialized compiler. The caller must close it after compilation or stylesheet reconstruction. */
26
+ compiler: IntegrationSession;
27
+ /** Filesystem, source metadata, resolver, dependency watcher, and warning operations. */
28
+ host: TurbopackHost;
29
+ /** Completed CSS graph and authored resources used by the compiler. */
30
+ loaded: LoadedCssGraph;
31
+ /**
32
+ * Resolves an asset with the loader context's default resolver.
33
+ *
34
+ * @param specifier - Resource request text from CSS or a producer.
35
+ * @param importer - Absolute identity of the resource owner.
36
+ * @returns A promise for the resolved asset identity. Unresolved requests reject the promise.
37
+ */
38
+ resolveAsset: (specifier: string, importer: string) => Promise<string>;
39
+ }
40
+ /** Compiler host whose resolver returns an identity or rejects instead of returning null. */
41
+ interface TurbopackHost extends CompilerHost {
42
+ /**
43
+ * Resolves a script dependency or marks a Node builtin or Next boundary marker as external.
44
+ *
45
+ * @param specifier - Script request text, including any resource query.
46
+ * @param importer - Absolute identity of the importing source.
47
+ * @returns A promise for the resolved identity and optional external status. Resolution failures
48
+ * reject the promise.
49
+ */
50
+ resolve: (specifier: string, importer: string) => Promise<{
51
+ /** Resolved absolute source identity or external module name. */
52
+ id: string;
53
+ /** Whether the graph must skip loading this module as source. */
54
+ external?: boolean;
55
+ }>;
56
+ }
57
+ export { TurbopackProject as n, TurbopackLoaderOptions as t };
58
+ //# sourceMappingURL=project-BNw0nZBE.d.ts.map
@@ -0,0 +1,182 @@
1
+ import { n as buildCompilerOptions, r as warnSkippedCss, t as IntegrationSession } from "./session-DHUCQMG5.js";
2
+ import { t as nativeBindingFiles } from "./binding-files-Ds5NpyVV.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, warnRejectedNames } from "@stillwind/host";
7
+ import path from "node:path";
8
+ import { scanSource } from "@stillwind/native";
9
+ import { resolveIntegrationConfig } from "@stillwind/config/node";
10
+ // src/turbopack/project.ts
11
+ /**
12
+ * Loads the design system and creates a compiler for a Turbopack or Next loader invocation.
13
+ *
14
+ * Configuration is evaluated independently in each loader invocation. Configuration dependencies,
15
+ * missing discovery candidates, compiler files, and CSS dependencies are registered with the host.
16
+ *
17
+ * @param context - Loader context containing serializable discovery settings, the bundler root,
18
+ * filesystem access, resolver operations, and dependency tracking.
19
+ * @returns A promise for the initialized project. The caller owns the compiler's lifetime.
20
+ * @throws If configuration evaluation or project selection fails, the CSS graph cannot be loaded,
21
+ * or compiler initialization fails.
22
+ */
23
+ async function createProject(context) {
24
+ const supplied = context.getOptions();
25
+ const configuration = await resolveIntegrationConfig(supplied.compiler, path.resolve(context.rootContext, supplied.root));
26
+ const options = {
27
+ ...supplied,
28
+ compiler: configuration.config,
29
+ root: configuration.config.root
30
+ };
31
+ /**
32
+ * Registers a file whose changes invalidate this loader result.
33
+ * @param id - Filesystem path for configuration, compiler code, CSS, or a resolved dependency.
34
+ */
35
+ const watch = (id) => {
36
+ context.addDependency(id);
37
+ };
38
+ for (const file of configuration.dependencies) watch(file);
39
+ for (const file of configuration.missing) context.addMissingDependency(file);
40
+ for (const file of nativeBindingFiles()) watch(file);
41
+ watch(fileURLToPath(import.meta.resolve("@stillwind/host")));
42
+ watch(import.meta.filename);
43
+ for (const file of ["loader.js", "css-loader.js"]) watch(fileURLToPath(new URL(`./${file}`, import.meta.resolve("@stillwind/integration/turbopack"))));
44
+ /**
45
+ * Reads text through Turbopack's loader filesystem.
46
+ * @param id - File path accepted by the loader filesystem.
47
+ * @returns File contents converted to a string.
48
+ * @throws If the filesystem reports a read error.
49
+ */
50
+ const read = (id) => new Promise((done, reject) => {
51
+ context.fs.readFile(id, (error, contents) => error ? reject(error) : done(String(contents)));
52
+ });
53
+ /**
54
+ * Adapts a Turbopack resolver to imports relative to a source file.
55
+ * @param settings - Resolution policy passed to the loader's resolver factory.
56
+ * @returns An asynchronous resolver accepting a specifier and full importer identity. Its promise
57
+ * rejects on resolver errors or missing results, and otherwise returns the resolved identity.
58
+ */
59
+ const resolver = (settings) => {
60
+ const resolve = context.getResolve(settings);
61
+ return (specifier, importer) => new Promise((done, reject) => {
62
+ resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) => error ? reject(error) : id ? done(id) : reject(/* @__PURE__ */ new Error(`Cannot resolve ${specifier} from ${importer}`)));
63
+ });
64
+ };
65
+ const resolveJs = resolver({
66
+ extensions: [
67
+ ".tsx",
68
+ ".ts",
69
+ ".jsx",
70
+ ".js",
71
+ ".mjs",
72
+ ".cjs",
73
+ ".json"
74
+ ],
75
+ dependencyType: "esm"
76
+ });
77
+ const resolveAsset = resolver({});
78
+ const loaded = await loadCssGraph(path.resolve(options.root, cssEntrypoint(options.compiler)), buildCompilerOptions(options.compiler), {
79
+ read,
80
+ documentUri: (id) => pathToFileURL(id).href,
81
+ sourceMapSource: (id) => pathToFileURL(id).href,
82
+ watch,
83
+ watchDirectory: (id) => {
84
+ context.addContextDependency(id);
85
+ },
86
+ resolve: resolver({
87
+ conditionNames: [
88
+ "style",
89
+ "import",
90
+ "default"
91
+ ],
92
+ extensions: [".css"],
93
+ mainFields: ["style", "main"]
94
+ }),
95
+ plugins: nodePluginHost
96
+ }, void 0, void 0, {
97
+ plugins: options.compiler.plugins,
98
+ tailwind: options.compiler.tailwind,
99
+ important: options.compiler.important,
100
+ root: options.root
101
+ });
102
+ return {
103
+ options,
104
+ compiler: new IntegrationSession(options.root, loaded.loader, options.compiler, false, options.mode, loaded.plugins),
105
+ host: {
106
+ describe: (id) => fileModuleDescriptor(options.root, id),
107
+ read,
108
+ watch,
109
+ resolve: async (specifier, importer) => isBuiltin(specifier) || specifier === "server-only" || specifier === "client-only" ? {
110
+ id: specifier,
111
+ external: true
112
+ } : { id: await resolveJs(specifier, importer) },
113
+ warn: (message) => {
114
+ context.emitWarning(new Error(message));
115
+ }
116
+ },
117
+ loaded,
118
+ resolveAsset
119
+ };
120
+ }
121
+ /**
122
+ * Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.
123
+ *
124
+ * @param entries - Entry paths, absolute or relative to the evaluated project root. Statically
125
+ * named imports, including lazy imports, are followed. Dynamic request expressions are not traversed.
126
+ * @param project - Initialized loader project. The caller closes its compiler after this operation.
127
+ * Its host receives warnings for the CSS statements that loading skipped and for rejected names.
128
+ * @returns A document plan selecting automatic producers, with a revision derived from visited
129
+ * source paths and contents. Explicit CSS values remain owned by their modules.
130
+ * @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.
131
+ */
132
+ async function compileGraph(entries, project) {
133
+ const { options, compiler, host } = project;
134
+ const pending = entries.map((entry) => path.resolve(options.root, entry));
135
+ const visited = /* @__PURE__ */ new Set();
136
+ const selection = [];
137
+ const revision = createHash("sha256");
138
+ while (pending.length) {
139
+ const id = pending.shift();
140
+ if (visited.has(id)) continue;
141
+ visited.add(id);
142
+ host.watch(id);
143
+ const source = await host.read(id);
144
+ revision.update(id).update("\0").update(source).update("\0");
145
+ const descriptor = fileModuleDescriptor(options.root, id);
146
+ const scan = scanSource({
147
+ kind: "direct",
148
+ moduleId: descriptor.moduleId,
149
+ document: {
150
+ ...descriptor.document,
151
+ code: source
152
+ },
153
+ syntax: descriptor.syntax
154
+ });
155
+ if (scan.kind === "failed") throw new CompilationFailure([scan.batch]);
156
+ const summary = scan.summary;
157
+ for (const { source: specifier } of summary.moduleSpecifiers) {
158
+ if (isBuiltin(specifier) || specifier === "stillwind" || specifier.startsWith("stillwind/")) continue;
159
+ const resolved = await host.resolve(specifier, id);
160
+ const file = cleanModuleId(resolved.id);
161
+ if (!resolved.external && !/[\\/]node_modules[\\/]/.test(file) && /\.[cm]?[jt]sx?$/.test(file)) pending.push(file);
162
+ }
163
+ if (!summary.macroImports && !summary.moduleCssImports) continue;
164
+ const output = await compiler.compile(source, id, host, { moduleCssImport: "stillwind/module-css" });
165
+ if (output && !output.hasModuleCssImport) selection.push(output.moduleId);
166
+ }
167
+ const plan = compiler.native.planStylesheet({
168
+ modules: selection,
169
+ coverage: {
170
+ kind: "complete",
171
+ target: "entry-graph",
172
+ revision: revision.digest("hex")
173
+ },
174
+ placement: "document"
175
+ });
176
+ warnSkippedCss(project.loaded.skipped, (message) => host.warn(message));
177
+ warnRejectedNames(plan.rejectedNames, (message) => host.warn(message));
178
+ return plan;
179
+ }
180
+ export { createProject as n, compileGraph as t };
181
+
182
+ //# sourceMappingURL=project-C3IH7geC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-C3IH7geC.js","names":[],"sources":["../src/turbopack/project.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\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 } from \"@stillwind/config/node\";\nimport {\n cleanModuleId,\n CompilationFailure,\n cssEntrypoint,\n fileModuleDescriptor,\n loadCssGraph,\n nodePluginHost,\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 { buildCompilerOptions, IntegrationSession, warnSkippedCss } from \"../session.ts\";\n\n/** Removes readonly constraints recursively so cloned inline settings fit the bundler's loader transport. */\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/** Serializable compiler settings and entry selection passed to Turbopack's isolated loaders. */\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/** Compiler session and host operations owned by one Turbopack or Next loader invocation. */\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 /** Initialized compiler. The caller must close it after compilation or stylesheet reconstruction. */\n compiler: 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 * 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\n/** Compiler host whose resolver returns an identity or rejects instead of returning null. */\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 creates a compiler for a Turbopack or Next loader invocation.\n *\n * Configuration is evaluated independently in each loader invocation. Configuration dependencies,\n * missing discovery candidates, compiler files, and CSS dependencies are registered with the host.\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 initialized project. The caller owns the compiler's lifetime.\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 configuration = await resolveIntegrationConfig(\n supplied.compiler,\n path.resolve(context.rootContext, supplied.root),\n );\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 * 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 /**\n * Adapts a Turbopack resolver to imports relative to a source file.\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 loaded = await loadCssGraph(\n path.resolve(options.root, cssEntrypoint(options.compiler)),\n buildCompilerOptions(options.compiler),\n {\n read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch,\n watchDirectory: (id) => {\n context.addContextDependency(id);\n },\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 const compiler = new IntegrationSession(\n options.root,\n loaded.loader,\n options.compiler,\n false,\n options.mode,\n loaded.plugins,\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 id: await resolveJs(specifier, importer),\n },\n warn: (message: string) => {\n context.emitWarning(new Error(message));\n },\n };\n return {\n options,\n compiler,\n host,\n loaded,\n resolveAsset,\n };\n}\n\n/**\n * Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.\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 - Initialized loader project. The caller closes its compiler 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 async function compileGraph(entries: readonly string[], project: TurbopackProject) {\n const { options, compiler, host } = project;\n const pending = entries.map((entry) => path.resolve(options.root, entry));\n const visited = new Set<string>();\n const selection: string[] = [];\n const revision = createHash(\"sha256\");\n while (pending.length) {\n const id = pending.shift()!;\n if (visited.has(id)) {\n continue;\n }\n visited.add(id);\n host.watch(id);\n const source = await host.read(id);\n revision.update(id).update(\"\\0\").update(source).update(\"\\0\");\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 for (const { source: specifier } of summary.moduleSpecifiers) {\n if (isBuiltin(specifier) || specifier === \"stillwind\" || specifier.startsWith(\"stillwind/\")) {\n continue;\n }\n const resolved = await host.resolve(specifier, id);\n const file = cleanModuleId(resolved.id);\n if (\n !resolved.external &&\n !/[\\\\/]node_modules[\\\\/]/.test(file) &&\n /\\.[cm]?[jt]sx?$/.test(file)\n ) {\n pending.push(file);\n }\n }\n if (!summary.macroImports && !summary.moduleCssImports) {\n continue;\n }\n const output = await compiler.compile(source, id, host, {\n moduleCssImport: \"stillwind/module-css\",\n });\n if (output && !output.hasModuleCssImport) {\n selection.push(output.moduleId);\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 warnSk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