@stillwind/config 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.
- package/LICENSE +21 -0
- package/README.md +11 -2
- package/dist/browser.d.ts +50 -0
- package/dist/browser.js +65 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.d.ts +208 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +102 -0
- package/dist/node.js +227 -0
- package/dist/node.js.map +1 -0
- package/dist/resolution-BK-NUhyh.js +1351 -0
- package/dist/resolution-BK-NUhyh.js.map +1 -0
- package/dist/resolution-BnR6LLM-.d.ts +1210 -0
- package/package.json +57 -3
package/dist/node.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { a as resolveProjectPaths, d as resolveConfig, i as resolveCompilerSettings, n as configurationCandidates$1, o as selectProject, s as validateInlineConfig, t as compilerConfig } from "./resolution-BK-NUhyh.js";
|
|
2
|
+
import { isBuiltin } from "node:module";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { createJiti } from "jiti";
|
|
8
|
+
import { rolldown } from "rolldown";
|
|
9
|
+
// src/node.ts
|
|
10
|
+
/**
|
|
11
|
+
* Node configuration discovery, evaluation, and project selection. `loadConfiguration` opens an
|
|
12
|
+
* explicit file. `resolveIntegrationConfig` also discovers files and applies build overrides.
|
|
13
|
+
* `evaluateModule` bundles and evaluates other local modules, such as plugin files. Consumers
|
|
14
|
+
* retaining compiler state use the returned dependency paths for change tracking.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Finds the nearest supported stillwind.config.* file at or above an application directory.
|
|
18
|
+
*
|
|
19
|
+
* @param directory - Directory to start from. Relative paths use the process working directory.
|
|
20
|
+
* @returns The first existing candidate's absolute path, or undefined if none exists.
|
|
21
|
+
*/
|
|
22
|
+
function findConfiguration(directory) {
|
|
23
|
+
return configurationCandidates$1(directory, path).find((file) => existsSync(file));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Bundles local imports of a module in memory and evaluates the bundle without module
|
|
27
|
+
* caches. Local sources are read again on each call, so a changed local import takes
|
|
28
|
+
* effect. External packages use runtime module loading, and Node keeps them cached. The
|
|
29
|
+
* module runs as trusted Node code and can perform side effects. Evaluation is
|
|
30
|
+
* available before a framework generates its TypeScript configuration.
|
|
31
|
+
*
|
|
32
|
+
* `import.meta.url`, `import.meta.filename`, `import.meta.dirname`, `__filename`, and
|
|
33
|
+
* `__dirname` describe the original source file of each bundled module.
|
|
34
|
+
*
|
|
35
|
+
* @param file - JS, TS, or JSON module path. Relative paths use the process working
|
|
36
|
+
* directory.
|
|
37
|
+
* @returns The export and the file paths observed while resolving and bundling imports.
|
|
38
|
+
* Runtime file reads and imports that cannot be statically resolved are not added to
|
|
39
|
+
* dependencies.
|
|
40
|
+
* @throws If a package cannot be resolved, or bundling or module evaluation fails.
|
|
41
|
+
*/
|
|
42
|
+
async function evaluateModule(file) {
|
|
43
|
+
file = path.resolve(file);
|
|
44
|
+
const dependencies = /* @__PURE__ */ new Set([file]);
|
|
45
|
+
const sources = /* @__PURE__ */ new Map();
|
|
46
|
+
const bundle = await rolldown({
|
|
47
|
+
input: file,
|
|
48
|
+
cwd: path.dirname(file),
|
|
49
|
+
logLevel: "silent",
|
|
50
|
+
platform: "node",
|
|
51
|
+
treeshake: false,
|
|
52
|
+
tsconfig: false,
|
|
53
|
+
transform: {
|
|
54
|
+
target: "node22",
|
|
55
|
+
define: {
|
|
56
|
+
"import.meta.url": "__stillwind_module_url",
|
|
57
|
+
"import.meta.filename": "__stillwind_module_filename",
|
|
58
|
+
"import.meta.dirname": "__stillwind_module_dirname",
|
|
59
|
+
__filename: "__stillwind_module_filename",
|
|
60
|
+
__dirname: "__stillwind_module_dirname"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
plugins: [{
|
|
64
|
+
name: "stillwind-module",
|
|
65
|
+
/**
|
|
66
|
+
* Resolves external packages from their importer and records their paths for watching.
|
|
67
|
+
* @param id - Import request before resolution.
|
|
68
|
+
* @param importer - Importing file, or undefined for the entry.
|
|
69
|
+
* @param options - Import kind used to select package export conditions.
|
|
70
|
+
* @returns An external module URL or require path, or undefined for bundled local sources.
|
|
71
|
+
* @throws If a package cannot be resolved.
|
|
72
|
+
*/
|
|
73
|
+
async resolveId(id, importer, options) {
|
|
74
|
+
if (!importer || id.startsWith(".") || path.isAbsolute(id)) return;
|
|
75
|
+
if (isBuiltin(id)) return {
|
|
76
|
+
id,
|
|
77
|
+
external: true
|
|
78
|
+
};
|
|
79
|
+
const resolved = await this.resolve(id, importer, {
|
|
80
|
+
skipSelf: true,
|
|
81
|
+
kind: options.kind
|
|
82
|
+
});
|
|
83
|
+
if (!resolved) throw new Error(`Cannot resolve import ${id} from ${importer}`);
|
|
84
|
+
dependencies.add(resolved.id);
|
|
85
|
+
return {
|
|
86
|
+
id: options.kind === "require-call" ? resolved.id : pathToFileURL(resolved.id).href,
|
|
87
|
+
external: "absolute"
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Reads a bundled local file and records its text.
|
|
92
|
+
* @param id - Absolute path of a local file, or a virtual module ID.
|
|
93
|
+
* @returns The file's text, or undefined for a virtual module.
|
|
94
|
+
*/
|
|
95
|
+
async load(id) {
|
|
96
|
+
if (id.startsWith("\0")) return;
|
|
97
|
+
const code = await readFile(id, "utf8");
|
|
98
|
+
sources.set(id, code);
|
|
99
|
+
return code;
|
|
100
|
+
},
|
|
101
|
+
transform: {
|
|
102
|
+
filter: { id: /\.[cm]?[jt]sx?$/ },
|
|
103
|
+
/**
|
|
104
|
+
* Keeps file location expressions relative to each original source.
|
|
105
|
+
* @param code - Local module source.
|
|
106
|
+
* @param id - Absolute source path.
|
|
107
|
+
* @returns Source with its file location constants before ordinary syntax lowering.
|
|
108
|
+
*/
|
|
109
|
+
handler(code, id) {
|
|
110
|
+
return `const __stillwind_module_url = ${JSON.stringify(pathToFileURL(id).href)};
|
|
111
|
+
const __stillwind_module_filename = ${JSON.stringify(id)};
|
|
112
|
+
const __stillwind_module_dirname = ${JSON.stringify(path.dirname(id))};
|
|
113
|
+
${code}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
let code;
|
|
119
|
+
try {
|
|
120
|
+
const entry = (await bundle.generate({
|
|
121
|
+
format: "esm",
|
|
122
|
+
codeSplitting: false
|
|
123
|
+
})).output.find((output) => output.type === "chunk" && output.isEntry);
|
|
124
|
+
if (entry?.type !== "chunk") throw new Error(`Module bundle has no entry: ${file}`);
|
|
125
|
+
for (const id of entry.moduleIds) if (!id.startsWith("\0")) dependencies.add(id);
|
|
126
|
+
code = entry.code;
|
|
127
|
+
} finally {
|
|
128
|
+
await bundle.close();
|
|
129
|
+
}
|
|
130
|
+
const value = await createJiti(pathToFileURL(file).href, {
|
|
131
|
+
fsCache: false,
|
|
132
|
+
moduleCache: false
|
|
133
|
+
}).evalModule(code, {
|
|
134
|
+
filename: file.replaceAll("\\", "/"),
|
|
135
|
+
async: true,
|
|
136
|
+
forceTranspile: true
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
exported: value !== null && typeof value === "object" && "default" in value ? value.default : value,
|
|
140
|
+
dependencies: [...dependencies],
|
|
141
|
+
sources
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Evaluates a configuration module with {@link evaluateModule} and validates its settings.
|
|
146
|
+
* Configuration runs as trusted Node code and can perform side effects.
|
|
147
|
+
*
|
|
148
|
+
* @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.
|
|
149
|
+
* @returns Evaluated settings and the file paths observed while resolving and bundling imports.
|
|
150
|
+
* Runtime file reads and imports that cannot be statically resolved are not added to dependencies.
|
|
151
|
+
* @throws If bundling, module evaluation, factory execution, or configuration validation fails.
|
|
152
|
+
*/
|
|
153
|
+
async function loadConfiguration(file) {
|
|
154
|
+
file = path.resolve(file);
|
|
155
|
+
const { exported, dependencies } = await evaluateModule(file);
|
|
156
|
+
return {
|
|
157
|
+
config: await resolveConfig(exported),
|
|
158
|
+
configFile: file,
|
|
159
|
+
dependencies
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Resolves project paths and removes analysis scope and provider settings.
|
|
164
|
+
*
|
|
165
|
+
* @param project - Evaluated project configuration with paths relative to its root.
|
|
166
|
+
* @param directory - Base directory for a relative project root, normally the configuration directory.
|
|
167
|
+
* @returns Compiler settings with absolute root, CSS, and tsconfig paths. The supplied project is not modified.
|
|
168
|
+
* A false or omitted tsconfig setting is preserved.
|
|
169
|
+
* @throws If compiler normalization fails or the project does not supply a valid CSS path.
|
|
170
|
+
*/
|
|
171
|
+
function resolveProjectConfig(project, directory) {
|
|
172
|
+
const resolved = resolveProjectPaths(project, directory, path);
|
|
173
|
+
return resolveCompilerSettings(compilerConfig(resolved), {}, resolved.root, path);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Loads build settings and merges inline overrides into one selected project's compiler settings.
|
|
177
|
+
* Without an explicit name, selection uses the sole project or the unique deepest root containing
|
|
178
|
+
* the application directory after its inline root override. Arrays are replaced during merging.
|
|
179
|
+
*
|
|
180
|
+
* @param inline - File selection, optional project name, and compiler overrides. An inline root
|
|
181
|
+
* uses applicationRoot. A configured root uses the configuration file's directory.
|
|
182
|
+
* @param applicationRoot - Build directory used for discovery and relative inline paths.
|
|
183
|
+
* Relative paths use the process working directory.
|
|
184
|
+
* @param defaults - Browser targets used when the selected project and inline settings omit target.
|
|
185
|
+
* @returns Validated compiler settings with an absolute root and paths to watch. When discovery
|
|
186
|
+
* finds no file, inline settings must supply a CSS entrypoint.
|
|
187
|
+
* @throws If an explicit file is missing, project selection is ambiguous or unsuccessful,
|
|
188
|
+
* configuration evaluation fails, or merged compiler settings are invalid.
|
|
189
|
+
*/
|
|
190
|
+
async function resolveIntegrationConfig(inline, applicationRoot, defaults = {}) {
|
|
191
|
+
applicationRoot = path.resolve(applicationRoot);
|
|
192
|
+
validateInlineConfig(inline);
|
|
193
|
+
const requested = inline.configFile;
|
|
194
|
+
const candidates = requested === false ? [] : requested ? [path.resolve(applicationRoot, requested)] : configurationCandidates(applicationRoot);
|
|
195
|
+
const file = candidates.find((candidate) => existsSync(candidate));
|
|
196
|
+
const missing = candidates.slice(0, file ? candidates.indexOf(file) : candidates.length);
|
|
197
|
+
if (requested && !file) throw new Error(`Cannot find Stillwind configuration: ${candidates[0]}`);
|
|
198
|
+
const loaded = file ? await loadConfiguration(file) : void 0;
|
|
199
|
+
const projects = loaded?.config.projects.map((project) => resolveProjectPaths(project, path.dirname(file), path));
|
|
200
|
+
if (!projects && inline.project !== void 0) throw new Error("Cannot select a Stillwind project without a configuration file");
|
|
201
|
+
const selected = projects ? selectProject(projects, applicationRoot, inline, path) : void 0;
|
|
202
|
+
const base = selected ? compilerConfig(selected) : {
|
|
203
|
+
root: applicationRoot,
|
|
204
|
+
lint: inline.lint
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
config: resolveCompilerSettings({
|
|
208
|
+
...base,
|
|
209
|
+
target: base.target ?? defaults.target
|
|
210
|
+
}, inline, applicationRoot, path),
|
|
211
|
+
configFile: file,
|
|
212
|
+
dependencies: loaded?.dependencies ?? [],
|
|
213
|
+
missing
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Enumerates Node configuration candidates without checking existence.
|
|
218
|
+
* @param directory - Starting directory. Relative paths use the process working directory.
|
|
219
|
+
* @returns Absolute paths ordered from the nearest directory to the filesystem root, with
|
|
220
|
+
* configurationFiles precedence within each directory.
|
|
221
|
+
*/
|
|
222
|
+
function configurationCandidates(directory) {
|
|
223
|
+
return configurationCandidates$1(directory, path);
|
|
224
|
+
}
|
|
225
|
+
export { evaluateModule, findConfiguration, loadConfiguration, resolveIntegrationConfig, resolveProjectConfig };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":["candidates"],"sources":["../src/node.ts"],"sourcesContent":["/**\n * Node configuration discovery, evaluation, and project selection. `loadConfiguration` opens an\n * explicit file. `resolveIntegrationConfig` also discovers files and applies build overrides.\n * `evaluateModule` bundles and evaluates other local modules, such as plugin files. Consumers\n * retaining compiler state use the returned dependency paths for change tracking.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport { createJiti } from \"jiti\";\nimport { rolldown } from \"rolldown\";\n\nimport type { BaseConfig, NormalizedCompilerConfig } from \"./compiler.ts\";\nimport {\n resolveConfig,\n type AnalysisProjectConfig,\n type StillwindConfig,\n} from \"./configuration.ts\";\nimport {\n configurationCandidates as candidates,\n compilerConfig,\n resolveCompilerSettings,\n resolveProjectPaths,\n selectProject,\n validateInlineConfig,\n type InlineConfig,\n} from \"./resolution.ts\";\n\n/** Evaluated settings and files that consumers must watch when retaining a compiler session. */\nexport interface LoadedConfiguration {\n /** Validated settings after awaiting the module export and invoking its factory, if supplied. */\n config: StillwindConfig;\n /** Absolute path of the evaluated configuration file. */\n configFile: string;\n /** Distinct absolute paths of the configuration, bundled local imports, and resolved external imports. */\n dependencies: string[];\n}\n\n/** Settings for one build integration after project selection and inline overrides. */\nexport interface ResolvedIntegrationConfig {\n /** Selected compiler settings after inline overrides and defaults. Filesystem paths are absolute. */\n config: NormalizedCompilerConfig & {\n /** Absolute selected project directory after applying inline overrides. */\n root: string;\n /** Absolute design-system stylesheet path, without an existence check. */\n css: string;\n };\n /** Absolute evaluated configuration path, or undefined when no file was loaded. */\n configFile?: string;\n /** Existing configuration dependency paths to watch. Empty when settings are entirely inline. */\n dependencies: string[];\n /** Absolute missing candidate paths before the selected file, nearest directory first. Watch their creation. */\n missing: string[];\n}\n\n/**\n * Finds the nearest supported stillwind.config.* file at or above an application directory.\n *\n * @param directory - Directory to start from. Relative paths use the process working directory.\n * @returns The first existing candidate's absolute path, or undefined if none exists.\n */\nexport function findConfiguration(directory: string): string | undefined {\n return candidates(directory, path).find((file) => existsSync(file));\n}\n\n/** An evaluated module and the files that its evaluation read. */\nexport interface EvaluatedModule {\n /** Default export, or the module value when it has no default export. */\n exported: unknown;\n /** Distinct absolute paths of the entry, bundled local imports, and resolved external imports. */\n dependencies: string[];\n /** Text of each bundled local file, keyed by absolute path, as the bundler read it. */\n sources: Map<string, string>;\n}\n\n/**\n * Bundles local imports of a module in memory and evaluates the bundle without module\n * caches. Local sources are read again on each call, so a changed local import takes\n * effect. External packages use runtime module loading, and Node keeps them cached. The\n * module runs as trusted Node code and can perform side effects. Evaluation is\n * available before a framework generates its TypeScript configuration.\n *\n * `import.meta.url`, `import.meta.filename`, `import.meta.dirname`, `__filename`, and\n * `__dirname` describe the original source file of each bundled module.\n *\n * @param file - JS, TS, or JSON module path. Relative paths use the process working\n * directory.\n * @returns The export and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to\n * dependencies.\n * @throws If a package cannot be resolved, or bundling or module evaluation fails.\n */\nexport async function evaluateModule(file: string): Promise<EvaluatedModule> {\n file = path.resolve(file);\n\n const dependencies = new Set([file]);\n const sources = new Map<string, string>();\n const bundle = await rolldown({\n input: file,\n cwd: path.dirname(file),\n logLevel: \"silent\",\n platform: \"node\",\n treeshake: false,\n tsconfig: false,\n transform: {\n target: \"node22\",\n define: {\n \"import.meta.url\": \"__stillwind_module_url\",\n \"import.meta.filename\": \"__stillwind_module_filename\",\n \"import.meta.dirname\": \"__stillwind_module_dirname\",\n __filename: \"__stillwind_module_filename\",\n __dirname: \"__stillwind_module_dirname\",\n },\n },\n plugins: [\n {\n name: \"stillwind-module\",\n /**\n * Resolves external packages from their importer and records their paths for watching.\n * @param id - Import request before resolution.\n * @param importer - Importing file, or undefined for the entry.\n * @param options - Import kind used to select package export conditions.\n * @returns An external module URL or require path, or undefined for bundled local sources.\n * @throws If a package cannot be resolved.\n */\n async resolveId(id, importer, options) {\n if (!importer || id.startsWith(\".\") || path.isAbsolute(id)) {\n return;\n }\n if (isBuiltin(id)) {\n return {\n id,\n external: true,\n };\n }\n const resolved = await this.resolve(id, importer, {\n skipSelf: true,\n kind: options.kind,\n });\n if (!resolved) {\n throw new Error(`Cannot resolve import ${id} from ${importer}`);\n }\n dependencies.add(resolved.id);\n return {\n id: options.kind === \"require-call\" ? resolved.id : pathToFileURL(resolved.id).href,\n external: \"absolute\",\n };\n },\n /**\n * Reads a bundled local file and records its text.\n * @param id - Absolute path of a local file, or a virtual module ID.\n * @returns The file's text, or undefined for a virtual module.\n */\n async load(id) {\n if (id.startsWith(\"\\0\")) {\n return;\n }\n const code = await readFile(id, \"utf8\");\n sources.set(id, code);\n return code;\n },\n transform: {\n filter: {\n id: /\\.[cm]?[jt]sx?$/,\n },\n /**\n * Keeps file location expressions relative to each original source.\n * @param code - Local module source.\n * @param id - Absolute source path.\n * @returns Source with its file location constants before ordinary syntax lowering.\n */\n handler(code, id) {\n return `const __stillwind_module_url = ${JSON.stringify(pathToFileURL(id).href)};\nconst __stillwind_module_filename = ${JSON.stringify(id)};\nconst __stillwind_module_dirname = ${JSON.stringify(path.dirname(id))};\n${code}`;\n },\n },\n },\n ],\n });\n\n let code: string;\n try {\n const result = await bundle.generate({\n format: \"esm\",\n codeSplitting: false,\n });\n const entry = result.output.find((output) => output.type === \"chunk\" && output.isEntry);\n if (entry?.type !== \"chunk\") {\n throw new Error(`Module bundle has no entry: ${file}`);\n }\n for (const id of entry.moduleIds) {\n if (!id.startsWith(\"\\0\")) {\n dependencies.add(id);\n }\n }\n code = entry.code;\n } finally {\n await bundle.close();\n }\n\n const jiti = createJiti(pathToFileURL(file).href, {\n fsCache: false,\n moduleCache: false,\n });\n const value = await jiti.evalModule(code, {\n filename: file.replaceAll(\"\\\\\", \"/\"),\n async: true,\n forceTranspile: true,\n });\n return {\n exported:\n value !== null && typeof value === \"object\" && \"default\" in value ? value.default : value,\n dependencies: [...dependencies],\n sources,\n };\n}\n\n/**\n * Evaluates a configuration module with {@link evaluateModule} and validates its settings.\n * Configuration runs as trusted Node code and can perform side effects.\n *\n * @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.\n * @returns Evaluated settings and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to dependencies.\n * @throws If bundling, module evaluation, factory execution, or configuration validation fails.\n */\nexport async function loadConfiguration(file: string): Promise<LoadedConfiguration> {\n file = path.resolve(file);\n const { exported, dependencies } = await evaluateModule(file);\n return {\n config: await resolveConfig(exported),\n configFile: file,\n dependencies,\n };\n}\n\n/**\n * Resolves project paths and removes analysis scope and provider settings.\n *\n * @param project - Evaluated project configuration with paths relative to its root.\n * @param directory - Base directory for a relative project root, normally the configuration directory.\n * @returns Compiler settings with absolute root, CSS, and tsconfig paths. The supplied project is not modified.\n * A false or omitted tsconfig setting is preserved.\n * @throws If compiler normalization fails or the project does not supply a valid CSS path.\n */\nexport function resolveProjectConfig(\n project: AnalysisProjectConfig,\n directory: string,\n): NormalizedCompilerConfig & {\n /** Absolute root resolved against directory. */\n root: string;\n /** Absolute CSS entrypoint resolved against the project's root. */\n css: string;\n} {\n const resolved = resolveProjectPaths(project, directory, path);\n return resolveCompilerSettings(compilerConfig(resolved), {}, resolved.root, path);\n}\n\n/**\n * Loads build settings and merges inline overrides into one selected project's compiler settings.\n * Without an explicit name, selection uses the sole project or the unique deepest root containing\n * the application directory after its inline root override. Arrays are replaced during merging.\n *\n * @param inline - File selection, optional project name, and compiler overrides. An inline root\n * uses applicationRoot. A configured root uses the configuration file's directory.\n * @param applicationRoot - Build directory used for discovery and relative inline paths.\n * Relative paths use the process working directory.\n * @param defaults - Browser targets used when the selected project and inline settings omit target.\n * @returns Validated compiler settings with an absolute root and paths to watch. When discovery\n * finds no file, inline settings must supply a CSS entrypoint.\n * @throws If an explicit file is missing, project selection is ambiguous or unsuccessful,\n * configuration evaluation fails, or merged compiler settings are invalid.\n */\nexport async function resolveIntegrationConfig(\n inline: InlineConfig,\n applicationRoot: string,\n defaults: Pick<BaseConfig, \"target\"> = {},\n): Promise<ResolvedIntegrationConfig> {\n applicationRoot = path.resolve(applicationRoot);\n\n validateInlineConfig(inline);\n const requested = inline.configFile;\n const candidates =\n requested === false\n ? []\n : requested\n ? [path.resolve(applicationRoot, requested)]\n : configurationCandidates(applicationRoot);\n const file = candidates.find((candidate) => existsSync(candidate));\n const missing = candidates.slice(0, file ? candidates.indexOf(file) : candidates.length);\n if (requested && !file) {\n throw new Error(`Cannot find Stillwind configuration: ${candidates[0]}`);\n }\n\n const loaded = file ? await loadConfiguration(file) : undefined;\n const projects = loaded?.config.projects.map((project) =>\n resolveProjectPaths(project, path.dirname(file!), path),\n );\n if (!projects && inline.project !== undefined) {\n throw new Error(\"Cannot select a Stillwind project without a configuration file\");\n }\n\n const selected = projects ? selectProject(projects, applicationRoot, inline, path) : undefined;\n const base = selected\n ? compilerConfig(selected)\n : {\n root: applicationRoot,\n lint: inline.lint,\n };\n const config = resolveCompilerSettings(\n { ...base, target: base.target ?? defaults.target },\n inline,\n applicationRoot,\n path,\n );\n\n return {\n config,\n configFile: file,\n dependencies: loaded?.dependencies ?? [],\n missing,\n };\n}\n\n/**\n * Enumerates Node configuration candidates without checking existence.\n * @param directory - Starting directory. Relative paths use the process working directory.\n * @returns Absolute paths ordered from the nearest directory to the filesystem root, with\n * configurationFiles precedence within each directory.\n */\nfunction configurationCandidates(directory: string): string[] {\n return candidates(directory, path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,kBAAkB,WAAuC;CACvE,OAAOA,0BAAW,WAAW,IAAI,CAAC,CAAC,MAAM,SAA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