@stencil/cli 5.0.0-beta.20 → 5.0.0-beta.22
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/dist/index.d.mts +1 -1
- package/dist/index.mjs +130 -73
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ type TaskCommand = 'add' | 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info'
|
|
|
10
10
|
/**
|
|
11
11
|
* All the Boolean options supported by the Stencil CLI
|
|
12
12
|
*/
|
|
13
|
-
declare const BOOLEAN_CLI_FLAGS: readonly ["cache", "ci", "debug", "dev", "
|
|
13
|
+
declare const BOOLEAN_CLI_FLAGS: readonly ["cache", "ci", "debug", "dev", "dryRun", "help", "log", "open", "prerender", "profile", "serviceWorker", "serve", "ssr", "verbose", "version", "watch"];
|
|
14
14
|
/**
|
|
15
15
|
* All the Number options supported by the Stencil CLI
|
|
16
16
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,6 @@ const BOOLEAN_CLI_FLAGS = [
|
|
|
24
24
|
"ci",
|
|
25
25
|
"debug",
|
|
26
26
|
"dev",
|
|
27
|
-
"docs",
|
|
28
27
|
"dryRun",
|
|
29
28
|
"help",
|
|
30
29
|
"log",
|
|
@@ -587,7 +586,6 @@ const mergeFlags = (config, flags) => {
|
|
|
587
586
|
if (flags.debug === true || flags.verbose === true) merged.logLevel = "debug";
|
|
588
587
|
else if (flags.logLevel) merged.logLevel = flags.logLevel;
|
|
589
588
|
if (typeof flags.watch === "boolean") merged.watch = flags.watch;
|
|
590
|
-
if (flags.docs === true || flags.task === "docs") merged._docsFlag = true;
|
|
591
589
|
if (typeof flags.profile === "boolean") merged.profile = flags.profile;
|
|
592
590
|
if (typeof flags.log === "boolean") merged.writeLog = flags.log;
|
|
593
591
|
if (typeof flags.cache === "boolean") merged.enableCache = flags.cache;
|
|
@@ -1265,7 +1263,7 @@ function clearInheritedProductionEnv() {
|
|
|
1265
1263
|
}
|
|
1266
1264
|
//#endregion
|
|
1267
1265
|
//#region src/wizard/splash.ts
|
|
1268
|
-
const CLI_VERSION = "5.0.0-beta.
|
|
1266
|
+
const CLI_VERSION = "5.0.0-beta.22";
|
|
1269
1267
|
const isTTY = process.stdout.isTTY;
|
|
1270
1268
|
const noColor = !isTTY || "NO_COLOR" in process.env;
|
|
1271
1269
|
const RESET = noColor ? "" : "\x1B[0m";
|
|
@@ -2022,11 +2020,23 @@ const formAssociatedRule = {
|
|
|
2022
2020
|
* Migration mapping:
|
|
2023
2021
|
* - `addGlobalStyleToComponents: true` → `inject: 'all'`
|
|
2024
2022
|
* - `addGlobalStyleToComponents: 'client'` → `inject: 'client'`
|
|
2025
|
-
* - `addGlobalStyleToComponents: false` →
|
|
2023
|
+
* - `addGlobalStyleToComponents: false` → `inject: 'none'` (a stylesheet from `globalStyle` defaults
|
|
2024
|
+
* to `'client'`, so omitting it would start injecting)
|
|
2026
2025
|
*
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
2029
|
-
*
|
|
2026
|
+
* The top-level `globalStyle` option moves into the new output target as well, so the config
|
|
2027
|
+
* isn't left describing one stylesheet in two places:
|
|
2028
|
+
*
|
|
2029
|
+
* ```ts
|
|
2030
|
+
* { type: 'global-style', input: 'src/global/app.css', fileName: 'my-lib.css', inject: 'none', copyToLoaderBrowser: true }
|
|
2031
|
+
* ```
|
|
2032
|
+
*
|
|
2033
|
+
* `fileName` is written (from `namespace`) because a target with an explicit `input` otherwise
|
|
2034
|
+
* names its output after the input file, where `globalStyle` used `{namespace}.css`.
|
|
2035
|
+
* When `globalStyle` isn't a string literal in the config (e.g. the stylesheet is auto-detected
|
|
2036
|
+
* from `src/global.*`), only `{ type: 'global-style', inject }` is written.
|
|
2037
|
+
*
|
|
2038
|
+
* Note: This migration only acts on explicitly set `addGlobalStyleToComponents`. A config
|
|
2039
|
+
* without it keeps `globalStyle` as it is, which still injects on the client as v4 did.
|
|
2030
2040
|
*/
|
|
2031
2041
|
const globalStyleInjectRule = {
|
|
2032
2042
|
id: "global-style-inject",
|
|
@@ -2058,79 +2068,97 @@ const globalStyleInjectRule = {
|
|
|
2058
2068
|
return matches;
|
|
2059
2069
|
},
|
|
2060
2070
|
transform(sourceFile, matches) {
|
|
2061
|
-
|
|
2062
|
-
|
|
2071
|
+
const original = sourceFile.getFullText();
|
|
2072
|
+
if (matches.length === 0) return original;
|
|
2063
2073
|
const matchNode = matches[0].node;
|
|
2064
|
-
if (!ts.isPropertyAssignment(matchNode)) return
|
|
2074
|
+
if (!ts.isPropertyAssignment(matchNode)) return original;
|
|
2065
2075
|
let injectValue = null;
|
|
2066
2076
|
if (matchNode.initializer.kind === ts.SyntaxKind.TrueKeyword) injectValue = "all";
|
|
2067
2077
|
else if (ts.isStringLiteral(matchNode.initializer) && matchNode.initializer.text === "client") injectValue = "client";
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
}
|
|
2081
|
-
const afterProp = text.slice(end).match(/^\s*,/);
|
|
2082
|
-
if (afterProp) end = end + afterProp[0].length;
|
|
2083
|
-
else {
|
|
2084
|
-
const beforeProp = text.slice(0, start).match(/,\s*$/);
|
|
2085
|
-
if (beforeProp) {
|
|
2086
|
-
text = text.slice(0, start - beforeProp[0].length) + text.slice(end);
|
|
2087
|
-
end = -1;
|
|
2078
|
+
else if (matchNode.initializer.kind === ts.SyntaxKind.FalseKeyword) injectValue = "none";
|
|
2079
|
+
const edits = [removalOf(original, matchNode)];
|
|
2080
|
+
const outputTargets = findTopLevelProperty(sourceFile, "outputTargets");
|
|
2081
|
+
const hasGlobalStyleTarget = original.includes("type: 'global-style'");
|
|
2082
|
+
if (injectValue && !hasGlobalStyleTarget && outputTargets && ts.isArrayLiteralExpression(outputTargets.initializer)) {
|
|
2083
|
+
const globalStyle = findTopLevelProperty(sourceFile, "globalStyle");
|
|
2084
|
+
const namespace = findTopLevelProperty(sourceFile, "namespace");
|
|
2085
|
+
const props = [`type: 'global-style'`];
|
|
2086
|
+
if (globalStyle && ts.isStringLiteralLike(globalStyle.initializer)) {
|
|
2087
|
+
props.push(`input: ${globalStyle.initializer.getText()}`);
|
|
2088
|
+
if (namespace && ts.isStringLiteralLike(namespace.initializer)) props.push(`fileName: '${namespace.initializer.text.toLowerCase().trim()}.css'`);
|
|
2089
|
+
edits.push(removalOf(original, globalStyle));
|
|
2088
2090
|
}
|
|
2091
|
+
props.push(`inject: '${injectValue}'`);
|
|
2092
|
+
if (props.length > 2) props.push(`copyToLoaderBrowser: true`);
|
|
2093
|
+
edits.push(insertionOfOutputTarget(original, outputTargets.initializer, props));
|
|
2089
2094
|
}
|
|
2090
|
-
|
|
2091
|
-
text =
|
|
2092
|
-
return text;
|
|
2095
|
+
let text = original;
|
|
2096
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) text = text.slice(0, edit.start) + edit.text + text.slice(edit.end);
|
|
2097
|
+
return cleanupEmptyExtras$1(text);
|
|
2093
2098
|
}
|
|
2094
2099
|
};
|
|
2095
2100
|
/**
|
|
2096
|
-
* Find
|
|
2101
|
+
* Find a property of the exported config object, e.g. `globalStyle` or `outputTargets`.
|
|
2097
2102
|
* @param sourceFile The source file to search
|
|
2098
|
-
* @
|
|
2103
|
+
* @param name The property name
|
|
2104
|
+
* @returns The property assignment, or null if the config has no such top-level property
|
|
2099
2105
|
*/
|
|
2100
|
-
function
|
|
2101
|
-
let
|
|
2102
|
-
const visit = (node) => {
|
|
2103
|
-
if (
|
|
2104
|
-
ts.
|
|
2106
|
+
function findTopLevelProperty(sourceFile, name) {
|
|
2107
|
+
let found = null;
|
|
2108
|
+
const visit = (node, depth) => {
|
|
2109
|
+
if (found) return;
|
|
2110
|
+
if (ts.isObjectLiteralExpression(node)) {
|
|
2111
|
+
if (depth > 0) return;
|
|
2112
|
+
for (const prop of node.properties) if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === name) {
|
|
2113
|
+
found = prop;
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
ts.forEachChild(node, (child) => visit(child, depth));
|
|
2105
2119
|
};
|
|
2106
|
-
visit(sourceFile);
|
|
2107
|
-
return
|
|
2120
|
+
visit(sourceFile, 0);
|
|
2121
|
+
return found;
|
|
2108
2122
|
}
|
|
2109
2123
|
/**
|
|
2110
|
-
*
|
|
2111
|
-
* @param text The source text
|
|
2112
|
-
* @
|
|
2124
|
+
* Build the edit that removes a property, together with its trailing comma and its own line.
|
|
2125
|
+
* @param text The original source text
|
|
2126
|
+
* @param node The property to remove
|
|
2127
|
+
* @returns The edit
|
|
2113
2128
|
*/
|
|
2114
|
-
function
|
|
2115
|
-
|
|
2129
|
+
function removalOf(text, node) {
|
|
2130
|
+
let start = node.getStart();
|
|
2131
|
+
let end = node.getEnd();
|
|
2132
|
+
const trailingComma = text.slice(end).match(/^\s*,/);
|
|
2133
|
+
if (trailingComma) end += trailingComma[0].length;
|
|
2134
|
+
else {
|
|
2135
|
+
const leadingComma = text.slice(0, start).match(/,\s*$/);
|
|
2136
|
+
if (leadingComma) return {
|
|
2137
|
+
start: start - leadingComma[0].length,
|
|
2138
|
+
end,
|
|
2139
|
+
text: ""
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
const lineStart = text.lastIndexOf("\n", start - 1) + 1;
|
|
2143
|
+
const restOfLine = text.slice(end).match(/^[ \t]*\n/);
|
|
2144
|
+
if (/^[ \t]*$/.test(text.slice(lineStart, start)) && restOfLine) {
|
|
2145
|
+
start = lineStart;
|
|
2146
|
+
end += restOfLine[0].length;
|
|
2147
|
+
}
|
|
2148
|
+
return {
|
|
2149
|
+
start,
|
|
2150
|
+
end,
|
|
2151
|
+
text: ""
|
|
2152
|
+
};
|
|
2116
2153
|
}
|
|
2117
2154
|
/**
|
|
2118
|
-
*
|
|
2119
|
-
* @param text The source text
|
|
2120
|
-
* @param
|
|
2121
|
-
* @param
|
|
2122
|
-
* @returns The
|
|
2155
|
+
* Build the edit that appends a `global-style` output target to the `outputTargets` array.
|
|
2156
|
+
* @param text The original source text
|
|
2157
|
+
* @param array The `outputTargets` array
|
|
2158
|
+
* @param props The new output target's properties, as source text
|
|
2159
|
+
* @returns The edit
|
|
2123
2160
|
*/
|
|
2124
|
-
function
|
|
2125
|
-
if (text.includes("type: 'global-style'")) return text;
|
|
2126
|
-
let outputTargetsArray = null;
|
|
2127
|
-
const findOutputTargets = (node) => {
|
|
2128
|
-
if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text === "outputTargets" && ts.isArrayLiteralExpression(node.initializer)) outputTargetsArray = node.initializer;
|
|
2129
|
-
ts.forEachChild(node, findOutputTargets);
|
|
2130
|
-
};
|
|
2131
|
-
findOutputTargets(sourceFile);
|
|
2132
|
-
if (!outputTargetsArray) return text;
|
|
2133
|
-
const array = outputTargetsArray;
|
|
2161
|
+
function insertionOfOutputTarget(text, array, props) {
|
|
2134
2162
|
let indent = " ";
|
|
2135
2163
|
if (array.elements.length > 0) {
|
|
2136
2164
|
const elemStart = array.elements[0].getStart();
|
|
@@ -2138,19 +2166,33 @@ function addGlobalStyleOutputTarget(text, sourceFile, injectValue) {
|
|
|
2138
2166
|
const leadingWhitespace = text.slice(lineStart, elemStart);
|
|
2139
2167
|
if (/^\s+$/.test(leadingWhitespace)) indent = leadingWhitespace;
|
|
2140
2168
|
}
|
|
2169
|
+
const newTarget = `{\n${props.map((prop) => `${indent} ${prop},\n`).join("")}${indent}}`;
|
|
2141
2170
|
const lastElement = array.elements[array.elements.length - 1];
|
|
2142
2171
|
if (!lastElement) {
|
|
2143
2172
|
const arrayStart = array.getStart() + 1;
|
|
2144
|
-
|
|
2145
|
-
|
|
2173
|
+
return {
|
|
2174
|
+
start: arrayStart,
|
|
2175
|
+
end: arrayStart,
|
|
2176
|
+
text: `\n${indent}${newTarget}\n${indent.slice(2)}`
|
|
2177
|
+
};
|
|
2146
2178
|
}
|
|
2147
2179
|
let insertPos = lastElement.getEnd();
|
|
2148
2180
|
const afterLastElement = text.slice(insertPos).match(/^(\s*,)?/);
|
|
2149
2181
|
const hasTrailingComma = afterLastElement && afterLastElement[1];
|
|
2150
2182
|
if (hasTrailingComma) insertPos += afterLastElement[0].length;
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2183
|
+
return {
|
|
2184
|
+
start: insertPos,
|
|
2185
|
+
end: insertPos,
|
|
2186
|
+
text: (hasTrailingComma ? "" : ",") + "\n" + indent + newTarget
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Clean up empty extras object after removing addGlobalStyleToComponents.
|
|
2191
|
+
* @param text The source text to clean up
|
|
2192
|
+
* @returns The cleaned up text with empty extras removed
|
|
2193
|
+
*/
|
|
2194
|
+
function cleanupEmptyExtras$1(text) {
|
|
2195
|
+
return text.replace(/,?\s*extras\s*:\s*\{\s*\},?/g, "");
|
|
2154
2196
|
}
|
|
2155
2197
|
//#endregion
|
|
2156
2198
|
//#region src/migrations/rules/hash-file-names.ts
|
|
@@ -3230,6 +3272,7 @@ const taskWatch = async (coreCompiler, config, flags) => {
|
|
|
3230
3272
|
//#endregion
|
|
3231
3273
|
//#region src/task-build.ts
|
|
3232
3274
|
const taskBuild = async (coreCompiler, config, flags) => {
|
|
3275
|
+
if (flags.unknownArgs?.includes("--docs")) config.logger.warn(`The --docs flag has been removed. To generate docs in a dev build, set "skipInDev: false" on the docs output targets, or run "stencil docs" (optionally with --watch).`);
|
|
3233
3276
|
if (flags.watch) {
|
|
3234
3277
|
await taskWatch(coreCompiler, config, flags);
|
|
3235
3278
|
return;
|
|
@@ -3345,14 +3388,27 @@ async function promptForMigration(config, migrationResult, context) {
|
|
|
3345
3388
|
}
|
|
3346
3389
|
//#endregion
|
|
3347
3390
|
//#region src/task-docs.ts
|
|
3348
|
-
const taskDocs = async (coreCompiler, config) => {
|
|
3391
|
+
const taskDocs = async (coreCompiler, config, flags) => {
|
|
3349
3392
|
config.devServer = {};
|
|
3350
3393
|
config.outputTargets = config.outputTargets.filter(isOutputTargetDocs);
|
|
3351
3394
|
config.devMode = true;
|
|
3395
|
+
config.outputTargets.forEach((o) => o.skipInDev = false);
|
|
3396
|
+
if (config.outputTargets.length === 0) {
|
|
3397
|
+
config.logger.warn(`No docs output targets are configured, so there is nothing to generate. Add one to "outputTargets" (e.g. { type: 'docs-readme' }) or use --docsJson <path>.`);
|
|
3398
|
+
return;
|
|
3399
|
+
}
|
|
3400
|
+
if (flags.watch) {
|
|
3401
|
+
await taskWatch(coreCompiler, config, {
|
|
3402
|
+
...flags,
|
|
3403
|
+
serve: false
|
|
3404
|
+
});
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3352
3407
|
startupCompilerLog(coreCompiler, config);
|
|
3353
3408
|
const compiler = await coreCompiler.createCompiler(config);
|
|
3354
|
-
await compiler.build();
|
|
3409
|
+
const results = await compiler.build();
|
|
3355
3410
|
await compiler.destroy();
|
|
3411
|
+
if (results.hasError) return config.sys.exit(1);
|
|
3356
3412
|
};
|
|
3357
3413
|
//#endregion
|
|
3358
3414
|
//#region src/resolve-entry-script.ts
|
|
@@ -3591,12 +3647,12 @@ const taskHelp = async (logger, sys) => {
|
|
|
3591
3647
|
${logger.cyan("--watch")} ${logger.dim("...........")} Rebuild when files update
|
|
3592
3648
|
${logger.cyan("--serve")} ${logger.dim("...........")} Start the dev-server (requires --watch)
|
|
3593
3649
|
${logger.cyan("--prerender")} ${logger.dim(".......")} Prerender the application
|
|
3594
|
-
${logger.cyan("--docs")} ${logger.dim("............")} Also generate docs output targets in a --dev build
|
|
3595
3650
|
${logger.cyan("--ssr")} ${logger.dim(".............")} Build a server-side-rendering bundle
|
|
3596
3651
|
${logger.cyan("--config")} ${logger.dim("..........")} Set stencil config file
|
|
3597
3652
|
${logger.cyan("--maxWorkers")} ${logger.dim("......")} Max number of workers, e.g. --maxWorkers 4
|
|
3598
3653
|
${logger.cyan("--no-cache")} ${logger.dim("........")} Disable the build cache
|
|
3599
3654
|
${logger.cyan("--stats")} ${logger.dim("...........")} Write stats, optional file path (default: stencil-stats.json)
|
|
3655
|
+
${logger.cyan("--docsJson")} ${logger.dim("........")} Also write a docs.json file to the given path
|
|
3600
3656
|
${logger.cyan("--log")} ${logger.dim(".............")} Write stencil-build.log file
|
|
3601
3657
|
${logger.cyan("--ci")} ${logger.dim("..............")} Run in CI mode (disables colors, version checks)
|
|
3602
3658
|
${logger.cyan("--debug")} ${logger.dim("...........")} Set the log level to debug
|
|
@@ -3611,10 +3667,11 @@ const taskHelp = async (logger, sys) => {
|
|
|
3611
3667
|
${logger.cyan("--open")} ${logger.dim("............")} Open the browser
|
|
3612
3668
|
|
|
3613
3669
|
|
|
3614
|
-
${logger.bold("Docs:")} ${logger.dim("Generate
|
|
3670
|
+
${logger.bold("Docs:")} ${logger.dim("Generate only the docs output targets (a production build already includes them).")}
|
|
3615
3671
|
|
|
3616
|
-
${prompt} ${logger.green("stencil docs [--docsJson]")}
|
|
3672
|
+
${prompt} ${logger.green("stencil docs [--watch] [--docsJson]")}
|
|
3617
3673
|
|
|
3674
|
+
${logger.cyan("--watch")} ${logger.dim("...........")} Regenerate when files update
|
|
3618
3675
|
${logger.cyan("--docsJson")} ${logger.dim("........")} Write a docs.json file to the given path
|
|
3619
3676
|
|
|
3620
3677
|
|
|
@@ -4239,7 +4296,7 @@ const runTask = async (coreCompiler, config, task, sys, flags) => {
|
|
|
4239
4296
|
await taskBuild(coreCompiler, strictConfig, resolvedFlags);
|
|
4240
4297
|
break;
|
|
4241
4298
|
case "docs":
|
|
4242
|
-
await taskDocs(coreCompiler, strictConfig);
|
|
4299
|
+
await taskDocs(coreCompiler, strictConfig, resolvedFlags);
|
|
4243
4300
|
break;
|
|
4244
4301
|
case "generate":
|
|
4245
4302
|
case "g":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.22",
|
|
4
4
|
"description": "CLI for Stencil - Web component compiler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"nypm": "^0.3.12",
|
|
43
43
|
"std-env": "^3.10.0",
|
|
44
44
|
"typescript": ">5.0.0 <7.0.0",
|
|
45
|
-
"@stencil/
|
|
46
|
-
"@stencil/
|
|
45
|
+
"@stencil/templates": "5.0.0-beta.22",
|
|
46
|
+
"@stencil/dev-server": "5.0.0-beta.22"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsdown": "^0.22.14",
|
|
50
50
|
"vitest": "^4.1.10",
|
|
51
|
-
"@stencil/core": "5.0.0-beta.
|
|
51
|
+
"@stencil/core": "5.0.0-beta.22"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@stencil/core": "^5.0.0 || 5.0.0-beta.
|
|
54
|
+
"@stencil/core": "^5.0.0 || 5.0.0-beta.22"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=22.0.0"
|