@stencil/cli 5.0.0-alpha.27 → 5.0.0-alpha.29

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 CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as d from "@stencil/core/compiler";
2
2
  import { ConfigCompat, LogLevel, OutputTarget } from "@stencil/core/compiler";
3
-
4
3
  //#region src/types.d.ts
5
4
  /**
6
5
  * Supported CLI task commands
@@ -48,7 +47,7 @@ declare const LOG_LEVEL_CLI_FLAGS: readonly ["logLevel"];
48
47
  * for which we want optional keys, we make all the properties optional (w/ `'?'`)
49
48
  * and possibly null.
50
49
  */
51
- type ObjectFromKeys<K extends ReadonlyArray<string>, T> = { [key in K[number]]?: T | null };
50
+ type ObjectFromKeys<K extends ReadonlyArray<string>, T> = { [key in K[number]]?: T | null; };
52
51
  /**
53
52
  * Type containing the possible Boolean configuration flags, to be included
54
53
  * in ConfigFlags, below
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
5
5
  import * as p from "@clack/prompts";
6
6
  import { cancel, isCancel, select } from "@clack/prompts";
7
7
  import * as nypm from "nypm";
8
- import { addDevDependency, detectPackageManager, installDependencies } from "nypm";
8
+ import { addDevDependency, detectPackageManager } from "nypm";
9
9
  import { isCI } from "std-env";
10
10
  import ts from "typescript";
11
11
  import { pathToFileURL } from "node:url";
@@ -198,8 +198,10 @@ const parseCLITerm = (flags, args) => {
198
198
  const [originalArg, value] = parseEqualsArg(arg);
199
199
  setCLIArg(flags, desugarRawAlias(originalArg), normalizeFlagName(originalArg), value);
200
200
  } else if (CLI_FLAG_REGEX.test(arg)) setCLIArg(flags, desugarRawAlias(arg), normalizeFlagName(arg), parseCLIValue(args));
201
- else if (arg.startsWith("--no-") && arg.length > 5) setCLIArg(flags, arg, normalizeNegativeFlagName(arg), "");
202
- else if (arg.startsWith("--no") && (isNegatedBoolean || isNegatedBooleanOrString)) setCLIArg(flags, arg, normalizeNegativeFlagName(arg), "");
201
+ else if (arg.startsWith("--no-") && arg.length > 5) {
202
+ const normalized = normalizeNegativeFlagName(arg);
203
+ setCLIArg(flags, arg, normalized, "");
204
+ } else if (arg.startsWith("--no") && (isNegatedBoolean || isNegatedBooleanOrString)) setCLIArg(flags, arg, normalizeNegativeFlagName(arg), "");
203
205
  else if (arg.startsWith("--") && arg.length > 2) setCLIArg(flags, arg, normalizeFlagName(arg), parseCLIValue(args));
204
206
  else flags.unknownArgs.push(arg);
205
207
  };
@@ -252,52 +254,58 @@ const setCLIArg = (flags, rawArg, normalizedArg, value) => {
252
254
  flags[normalizedArg] = typeof value === "string" ? value === "true" : true;
253
255
  flags.knownArgs.push(rawArg);
254
256
  if (typeof value === "string" && value !== "") flags.knownArgs.push(value);
255
- } else if (readOnlyArrayHasStringMember(STRING_CLI_FLAGS, normalizedArg)) if (typeof value === "string") {
256
- flags[normalizedArg] = value;
257
- flags.knownArgs.push(rawArg);
258
- flags.knownArgs.push(value);
259
- } else throwCLIParsingError(rawArg, "expected a string argument but received nothing");
260
- else if (STRING_ARRAY_CLI_FLAGS.length > 0 && readOnlyArrayHasStringMember(STRING_ARRAY_CLI_FLAGS, normalizedArg)) if (typeof value === "string") {
261
- const flagsRecord = flags;
262
- if (!Array.isArray(flagsRecord[normalizedArg])) flagsRecord[normalizedArg] = [];
263
- const targetArray = flagsRecord[normalizedArg];
264
- if (Array.isArray(targetArray)) {
265
- targetArray.push(value);
257
+ } else if (readOnlyArrayHasStringMember(STRING_CLI_FLAGS, normalizedArg)) {
258
+ if (typeof value === "string") {
259
+ flags[normalizedArg] = value;
266
260
  flags.knownArgs.push(rawArg);
267
261
  flags.knownArgs.push(value);
268
- }
269
- } else throwCLIParsingError(rawArg, "expected a string argument but received nothing");
270
- else if (readOnlyArrayHasStringMember(NUMBER_CLI_FLAGS, normalizedArg)) if (typeof value === "string") {
271
- const parsed = parseInt(value, 10);
272
- if (isNaN(parsed)) throwNumberParsingError(rawArg, value);
273
- else {
274
- flags[normalizedArg] = parsed;
262
+ } else throwCLIParsingError(rawArg, "expected a string argument but received nothing");
263
+ } else if (STRING_ARRAY_CLI_FLAGS.length > 0 && readOnlyArrayHasStringMember(STRING_ARRAY_CLI_FLAGS, normalizedArg)) {
264
+ if (typeof value === "string") {
265
+ const flagsRecord = flags;
266
+ if (!Array.isArray(flagsRecord[normalizedArg])) flagsRecord[normalizedArg] = [];
267
+ const targetArray = flagsRecord[normalizedArg];
268
+ if (Array.isArray(targetArray)) {
269
+ targetArray.push(value);
270
+ flags.knownArgs.push(rawArg);
271
+ flags.knownArgs.push(value);
272
+ }
273
+ } else throwCLIParsingError(rawArg, "expected a string argument but received nothing");
274
+ } else if (readOnlyArrayHasStringMember(NUMBER_CLI_FLAGS, normalizedArg)) {
275
+ if (typeof value === "string") {
276
+ const parsed = parseInt(value, 10);
277
+ if (isNaN(parsed)) throwNumberParsingError(rawArg, value);
278
+ else {
279
+ flags[normalizedArg] = parsed;
280
+ flags.knownArgs.push(rawArg);
281
+ flags.knownArgs.push(value);
282
+ }
283
+ } else throwCLIParsingError(rawArg, "expected a number argument but received nothing");
284
+ } else if (readOnlyArrayHasStringMember(STRING_NUMBER_CLI_FLAGS, normalizedArg)) {
285
+ if (typeof value === "string") {
286
+ if (CLI_ARG_STRING_REGEX.test(value)) flags[normalizedArg] = value;
287
+ else {
288
+ const parsed = Number(value);
289
+ if (isNaN(parsed)) throwNumberParsingError(rawArg, value);
290
+ else flags[normalizedArg] = parsed;
291
+ }
275
292
  flags.knownArgs.push(rawArg);
276
293
  flags.knownArgs.push(value);
277
- }
278
- } else throwCLIParsingError(rawArg, "expected a number argument but received nothing");
279
- else if (readOnlyArrayHasStringMember(STRING_NUMBER_CLI_FLAGS, normalizedArg)) if (typeof value === "string") {
280
- if (CLI_ARG_STRING_REGEX.test(value)) flags[normalizedArg] = value;
281
- else {
282
- const parsed = Number(value);
283
- if (isNaN(parsed)) throwNumberParsingError(rawArg, value);
284
- else flags[normalizedArg] = parsed;
285
- }
286
- flags.knownArgs.push(rawArg);
287
- flags.knownArgs.push(value);
288
- } else throwCLIParsingError(rawArg, "expected a string or a number but received nothing");
289
- else if (readOnlyArrayHasStringMember(BOOLEAN_STRING_CLI_FLAGS, normalizedArg)) {
294
+ } else throwCLIParsingError(rawArg, "expected a string or a number but received nothing");
295
+ } else if (readOnlyArrayHasStringMember(BOOLEAN_STRING_CLI_FLAGS, normalizedArg)) {
290
296
  const derivedValue = typeof value === "string" ? value ? value : false : true;
291
297
  flags[normalizedArg] = derivedValue;
292
298
  flags.knownArgs.push(rawArg);
293
299
  if (typeof derivedValue === "string" && derivedValue) flags.knownArgs.push(derivedValue);
294
- } else if (readOnlyArrayHasStringMember(LOG_LEVEL_CLI_FLAGS, normalizedArg)) if (typeof value === "string") if (isLogLevel(value)) {
295
- flags[normalizedArg] = value;
296
- flags.knownArgs.push(rawArg);
297
- flags.knownArgs.push(value);
298
- } else throwCLIParsingError(rawArg, `expected to receive a valid log level but received "${String(value)}"`);
299
- else throwCLIParsingError(rawArg, "expected to receive a valid log level but received nothing");
300
- else {
300
+ } else if (readOnlyArrayHasStringMember(LOG_LEVEL_CLI_FLAGS, normalizedArg)) {
301
+ if (typeof value === "string") {
302
+ if (isLogLevel(value)) {
303
+ flags[normalizedArg] = value;
304
+ flags.knownArgs.push(rawArg);
305
+ flags.knownArgs.push(value);
306
+ } else throwCLIParsingError(rawArg, `expected to receive a valid log level but received "${String(value)}"`);
307
+ } else throwCLIParsingError(rawArg, "expected to receive a valid log level but received nothing");
308
+ } else {
301
309
  flags.unknownArgs.push(rawArg);
302
310
  if (typeof value === "string") flags.unknownArgs.push(value);
303
311
  }
@@ -448,9 +456,10 @@ const findConfig = async (opts) => {
448
456
  const cwd = sys.getCurrentDirectory();
449
457
  const rootDir = normalizePath(cwd);
450
458
  let configPath = opts.configPath;
451
- if (isString(configPath)) if (!sys.platformPath.isAbsolute(configPath)) configPath = normalizePath(sys.platformPath.join(cwd, configPath));
452
- else configPath = normalizePath(configPath);
453
- else configPath = rootDir;
459
+ if (isString(configPath)) {
460
+ if (!sys.platformPath.isAbsolute(configPath)) configPath = normalizePath(sys.platformPath.join(cwd, configPath));
461
+ else configPath = normalizePath(configPath);
462
+ } else configPath = rootDir;
454
463
  const results = {
455
464
  configPath: null,
456
465
  rootDir: normalizePath(cwd)
@@ -636,7 +645,10 @@ async function openStencilConfig(configPath) {
636
645
  }
637
646
  function replaceInArray(arr, substring, expression) {
638
647
  for (const element of arr.elements) if (text.slice(element.getStart(), element.getEnd()).includes(substring)) {
639
- text = text.slice(0, element.getStart()) + expression + text.slice(element.getEnd());
648
+ const lineStart = text.lastIndexOf("\n", element.getStart()) + 1;
649
+ const indent = text.slice(lineStart, element.getStart()).match(/^\s+/)?.[0] ?? "";
650
+ const indentedExpression = indent ? expression.replace(/\n/g, `\n${indent}`) : expression;
651
+ text = text.slice(0, element.getStart()) + indentedExpression + text.slice(element.getEnd());
640
652
  return true;
641
653
  }
642
654
  return false;
@@ -674,12 +686,14 @@ async function openStencilConfig(configPath) {
674
686
  let insertPos = arr.elements[arr.elements.length - 1].getEnd();
675
687
  const trailingComma = text.slice(insertPos).match(/^\s*,/);
676
688
  if (trailingComma) insertPos += trailingComma[0].length;
689
+ const separator = trailingComma ? "" : ",";
677
690
  const firstElemStart = arr.elements[0].getStart();
678
691
  if (text.slice(arr.getStart(), firstElemStart).includes("\n")) {
679
692
  const lineStart = text.lastIndexOf("\n", firstElemStart) + 1;
680
693
  const indent = text.slice(lineStart, firstElemStart).match(/^\s+/)?.[0] ?? " ";
681
- text = `${text.slice(0, insertPos)},\n${indent}${code}${text.slice(insertPos)}`;
682
- } else text = `${text.slice(0, insertPos)}, ${code}${text.slice(insertPos)}`;
694
+ const indentedCode = code.replace(/\n/g, `\n${indent}`);
695
+ text = `${text.slice(0, insertPos)}${separator}\n${indent}${indentedCode}${text.slice(insertPos)}`;
696
+ } else text = `${text.slice(0, insertPos)}${separator} ${code}${text.slice(insertPos)}`;
683
697
  }
684
698
  function addArrayProp(sf, propName, code) {
685
699
  const configObj = findConfigObject(sf);
@@ -690,7 +704,8 @@ async function openStencilConfig(configPath) {
690
704
  const lineStart = text.lastIndexOf("\n", firstPropStart) + 1;
691
705
  propIndent = text.slice(lineStart, firstPropStart).match(/^\s+/)?.[0] ?? " ";
692
706
  }
693
- const newProp = `${propName}: [\n${propIndent + " "}${code},\n${propIndent}]`;
707
+ const elemIndent = propIndent + " ";
708
+ const newProp = `${propName}: [\n${elemIndent}${code.replace(/\n/g, `\n${elemIndent}`)},\n${propIndent}]`;
694
709
  const lastProp = configObj.properties[configObj.properties.length - 1];
695
710
  if (lastProp) {
696
711
  let insertPos = lastProp.getEnd();
@@ -803,7 +818,7 @@ async function loadOne(rootDir, packageName, loader) {
803
818
  async function discoverPlugins(rootDir, loader = (url) => import(url)) {
804
819
  const pkg = await readJson$1(join(rootDir, "package.json"));
805
820
  if (!pkg) return [];
806
- const depNames = [...new Set([...Object.keys(toStringRecord(pkg.dependencies)), ...Object.keys(toStringRecord(pkg.devDependencies))])];
821
+ const depNames = [.../* @__PURE__ */ new Set([...Object.keys(toStringRecord(pkg.dependencies)), ...Object.keys(toStringRecord(pkg.devDependencies))])];
807
822
  const plugins = (await Promise.allSettled(depNames.map((name) => loadOne(rootDir, name, loader)))).filter((r) => r.status === "fulfilled" && r.value !== null).map((r) => r.value);
808
823
  const devEnv = process.env.STENCIL_WIZARD_DEV;
809
824
  if (devEnv) {
@@ -1014,6 +1029,11 @@ async function promptDocs() {
1014
1029
  label: "JSON",
1015
1030
  hint: "docs.json - Stencil / Ionic centric schema"
1016
1031
  },
1032
+ {
1033
+ value: "skill",
1034
+ label: "AI Skill",
1035
+ hint: "dist/skill/SKILL.md - Agent Skill (agentskills.io) reference for AI coding agents"
1036
+ },
1017
1037
  {
1018
1038
  value: "vscode",
1019
1039
  label: "VS Code",
@@ -1197,7 +1217,7 @@ async function isExistingStencilProject(dir) {
1197
1217
  }
1198
1218
  //#endregion
1199
1219
  //#region src/wizard/splash.ts
1200
- const CLI_VERSION = "5.0.0-alpha.27";
1220
+ const CLI_VERSION = "5.0.0-alpha.29";
1201
1221
  const isTTY = process.stdout.isTTY;
1202
1222
  const noColor = !isTTY || "NO_COLOR" in process.env;
1203
1223
  const RESET = noColor ? "" : "\x1B[0m";
@@ -1255,7 +1275,7 @@ async function getInstalledPackageNames(rootDir) {
1255
1275
  try {
1256
1276
  const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf8"));
1257
1277
  const keys = (v) => Object.keys(v !== null && typeof v === "object" ? v : {});
1258
- return new Set([...keys(pkg.dependencies), ...keys(pkg.devDependencies)]);
1278
+ return /* @__PURE__ */ new Set([...keys(pkg.dependencies), ...keys(pkg.devDependencies)]);
1259
1279
  } catch {
1260
1280
  return /* @__PURE__ */ new Set();
1261
1281
  }
@@ -1293,23 +1313,26 @@ async function taskAdd(packages, strictConfig) {
1293
1313
  p.outro("Nothing to do.");
1294
1314
  return;
1295
1315
  }
1296
- if (packagesToInstall.length > 0) if (process.env.STENCIL_WIZARD_DEV) p.log.warn(`Dev mode: skipping install, loading wizard from ${process.env.STENCIL_WIZARD_DEV}`);
1297
- else {
1298
- const s = p.spinner();
1299
- s.start(`Installing ${packagesToInstall.join(", ")}`);
1300
- await addDevDependency(withVersionRanges(packagesToInstall), {
1301
- cwd,
1302
- silent: true
1303
- });
1304
- s.stop("Installed");
1316
+ if (packagesToInstall.length > 0) {
1317
+ if (process.env.STENCIL_WIZARD_DEV) p.log.warn(`Dev mode: skipping install, loading wizard from ${process.env.STENCIL_WIZARD_DEV}`);
1318
+ else {
1319
+ const s = p.spinner();
1320
+ s.start(`Installing ${packagesToInstall.join(", ")}`);
1321
+ await addDevDependency(withVersionRanges(packagesToInstall), {
1322
+ cwd,
1323
+ silent: true
1324
+ });
1325
+ s.stop("Installed");
1326
+ }
1305
1327
  }
1306
1328
  const config = strictConfig ? toProjectConfig(strictConfig) : defaultProjectConfig(cwd);
1329
+ const workspaceRoot = await detectWorkspaceRoot(cwd);
1307
1330
  const context = {
1308
1331
  isNewProject: false,
1309
1332
  prompts: p,
1310
1333
  nypm,
1311
1334
  config,
1312
- workspaceRoot: await detectWorkspaceRoot(cwd),
1335
+ workspaceRoot,
1313
1336
  ts,
1314
1337
  openStencilConfig: () => openStencilConfig(join(config.rootDir, "stencil.config.ts"))
1315
1338
  };
@@ -1457,6 +1480,78 @@ const buildDistDocsRule = {
1457
1480
  }
1458
1481
  };
1459
1482
  //#endregion
1483
+ //#region src/migrations/rules/css-import-query-param.ts
1484
+ /**
1485
+ * Ambient module extensions Stencil declares its own type for. In v5 these
1486
+ * now require a `?stencil` query-param marker (see `stencil-ext-modules.d.ts`)
1487
+ * so the ambient declaration doesn't clash with other `*.css` etc. typings in
1488
+ * a monorepo.
1489
+ */
1490
+ const AMBIENT_ASSET_EXTS = [
1491
+ ".css",
1492
+ ".svg",
1493
+ ".txt",
1494
+ ".frag",
1495
+ ".vert"
1496
+ ];
1497
+ const needsStencilMarker = (specifier) => {
1498
+ if (specifier.includes("?")) return false;
1499
+ const lower = specifier.toLowerCase();
1500
+ return AMBIENT_ASSET_EXTS.some((ext) => lower.endsWith(ext));
1501
+ };
1502
+ /**
1503
+ * Migration rule appending `?stencil` to raw asset import specifiers.
1504
+ *
1505
+ * Migrates:
1506
+ * - `import styles from './my-component.css'` → `import styles from './my-component.css?stencil'`
1507
+ * - `import logo from './logo.svg'` → `import logo from './logo.svg?stencil'`
1508
+ *
1509
+ * Does not touch `styleUrl`/`styleUrls` values in `@Component()` options - those are
1510
+ * compiler-resolved filenames, not import specifiers, and are never typed against the
1511
+ * ambient module declarations.
1512
+ */
1513
+ const cssImportQueryParamRule = {
1514
+ id: "css-import-query-param",
1515
+ name: "Asset Import Query Param",
1516
+ description: "Append '?stencil' to raw *.css/*.svg/*.txt/*.frag/*.vert imports so they match Stencil's ambient module types",
1517
+ fromVersion: "4.x",
1518
+ toVersion: "5.x",
1519
+ detect(sourceFile) {
1520
+ const matches = [];
1521
+ const visit = (node) => {
1522
+ let specifierNode;
1523
+ if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) specifierNode = node.moduleSpecifier;
1524
+ else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts.isStringLiteral(node.arguments[0])) specifierNode = node.arguments[0];
1525
+ if (specifierNode && needsStencilMarker(specifierNode.text)) {
1526
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(specifierNode.getStart());
1527
+ matches.push({
1528
+ node: specifierNode,
1529
+ message: `Raw asset import '${specifierNode.text}' needs a '?stencil' suffix to match Stencil's ambient module type`,
1530
+ line: line + 1,
1531
+ column: character + 1
1532
+ });
1533
+ }
1534
+ ts.forEachChild(node, visit);
1535
+ };
1536
+ visit(sourceFile);
1537
+ return matches;
1538
+ },
1539
+ transform(sourceFile, matches) {
1540
+ if (matches.length === 0) return sourceFile.getFullText();
1541
+ let text = sourceFile.getFullText();
1542
+ const sortedMatches = [...matches].sort((a, b) => b.node.getStart() - a.node.getStart());
1543
+ for (const match of sortedMatches) {
1544
+ const node = match.node;
1545
+ const start = node.getStart();
1546
+ const end = node.getEnd();
1547
+ const quote = node.getText(sourceFile)[0];
1548
+ const updated = `${quote}${node.text}?stencil${quote}`;
1549
+ text = text.slice(0, start) + updated + text.slice(end);
1550
+ }
1551
+ return text;
1552
+ }
1553
+ };
1554
+ //#endregion
1460
1555
  //#region src/migrations/rules/dev-mode.ts
1461
1556
  /**
1462
1557
  * Migration rule for `devMode` config option removal.
@@ -1563,20 +1658,22 @@ const encapsulationApiRule = {
1563
1658
  const start = prop.getStart();
1564
1659
  const end = prop.getEnd();
1565
1660
  let replacement;
1566
- if (propName === "shadow") if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) replacement = "encapsulation: { type: 'shadow' }";
1567
- else if (ts.isObjectLiteralExpression(prop.initializer)) {
1568
- const options = [];
1569
- for (const innerProp of prop.initializer.properties) if (ts.isPropertyAssignment(innerProp) && ts.isIdentifier(innerProp.name)) {
1570
- const optName = innerProp.name.text;
1571
- const optValue = innerProp.initializer.getText();
1572
- options.push(`${optName}: ${optValue}`);
1573
- }
1574
- if (options.length > 0) replacement = `encapsulation: { type: 'shadow', ${options.join(", ")} }`;
1575
- else replacement = "encapsulation: { type: 'shadow' }";
1576
- } else replacement = "";
1577
- else if (propName === "scoped") if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) replacement = "encapsulation: { type: 'scoped' }";
1578
- else replacement = "";
1579
- else continue;
1661
+ if (propName === "shadow") {
1662
+ if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) replacement = "encapsulation: { type: 'shadow' }";
1663
+ else if (ts.isObjectLiteralExpression(prop.initializer)) {
1664
+ const options = [];
1665
+ for (const innerProp of prop.initializer.properties) if (ts.isPropertyAssignment(innerProp) && ts.isIdentifier(innerProp.name)) {
1666
+ const optName = innerProp.name.text;
1667
+ const optValue = innerProp.initializer.getText();
1668
+ options.push(`${optName}: ${optValue}`);
1669
+ }
1670
+ if (options.length > 0) replacement = `encapsulation: { type: 'shadow', ${options.join(", ")} }`;
1671
+ else replacement = "encapsulation: { type: 'shadow' }";
1672
+ } else replacement = "";
1673
+ } else if (propName === "scoped") {
1674
+ if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) replacement = "encapsulation: { type: 'scoped' }";
1675
+ else replacement = "";
1676
+ } else continue;
1580
1677
  let endPos = end;
1581
1678
  const afterProp = text.slice(end).match(/^\s*,/);
1582
1679
  if (afterProp && replacement === "") endPos = end + afterProp[0].length;
@@ -1997,7 +2094,7 @@ const hashFileNamesRule = {
1997
2094
  value: node.initializer.getText(sourceFile)
1998
2095
  };
1999
2096
  });
2000
- const TARGET_TYPES = new Set(["loader-bundle", "www"]);
2097
+ const TARGET_TYPES = /* @__PURE__ */ new Set(["loader-bundle", "www"]);
2001
2098
  const insertionsByPos = /* @__PURE__ */ new Map();
2002
2099
  const visit = (node) => {
2003
2100
  if (ts.isObjectLiteralExpression(node)) {
@@ -2074,7 +2171,7 @@ const lightDomPatchesRule = {
2074
2171
  toVersion: "5.x",
2075
2172
  detect(sourceFile) {
2076
2173
  const matches = [];
2077
- const oldKeys = new Set([
2174
+ const oldKeys = /* @__PURE__ */ new Set([
2078
2175
  "experimentalSlotFixes",
2079
2176
  "appendChildSlotFix",
2080
2177
  "cloneNodeFix",
@@ -2394,7 +2491,7 @@ function addExtractedOutputTargets(text, sourceFile, toExtract) {
2394
2491
  * NodeResolve fields that were valid in @rollup/plugin-node-resolve but don't exist
2395
2492
  * in rolldown's native resolver and should be removed.
2396
2493
  */
2397
- const REMOVED_NODE_RESOLVE_FIELDS = new Set([
2494
+ const REMOVED_NODE_RESOLVE_FIELDS = /* @__PURE__ */ new Set([
2398
2495
  "browser",
2399
2496
  "modulePaths",
2400
2497
  "dedupe",
@@ -2608,6 +2705,91 @@ const serviceWorkerDefaultRule = {
2608
2705
  }
2609
2706
  };
2610
2707
  //#endregion
2708
+ //#region src/migrations/rules/suppress-warnings-to-compat.ts
2709
+ /**
2710
+ * Migration rule: move `suppressReservedPublicNameWarnings` / `suppressReservedEventNameWarnings`
2711
+ * off the top level of the config and into `compat`, dropping `Reserved` from their names.
2712
+ *
2713
+ * In v5:
2714
+ * suppressReservedPublicNameWarnings → compat.suppressPublicNameWarnings
2715
+ * suppressReservedEventNameWarnings → compat.suppressEventNameWarnings
2716
+ */
2717
+ const KEY_RENAME = {
2718
+ suppressReservedPublicNameWarnings: "suppressPublicNameWarnings",
2719
+ suppressReservedEventNameWarnings: "suppressEventNameWarnings"
2720
+ };
2721
+ const suppressWarningsToCompatRule = {
2722
+ id: "suppress-warnings-to-compat",
2723
+ name: "Suppress Warnings → Compat",
2724
+ description: "Move 'suppressReservedPublicNameWarnings' / 'suppressReservedEventNameWarnings' into 'compat'",
2725
+ fromVersion: "4.x",
2726
+ toVersion: "5.x",
2727
+ detect(sourceFile) {
2728
+ const matches = [];
2729
+ const visit = (node) => {
2730
+ if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text in KEY_RENAME) {
2731
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
2732
+ matches.push({
2733
+ node,
2734
+ message: `'${node.name.text}' has moved to 'compat.${KEY_RENAME[node.name.text]}'`,
2735
+ line: line + 1,
2736
+ column: character + 1
2737
+ });
2738
+ }
2739
+ ts.forEachChild(node, visit);
2740
+ };
2741
+ visit(sourceFile);
2742
+ return matches;
2743
+ },
2744
+ transform(sourceFile, matches) {
2745
+ if (matches.length === 0) return sourceFile.getFullText();
2746
+ const text = sourceFile.getFullText();
2747
+ const edits = [];
2748
+ const newProps = [];
2749
+ for (const match of matches) {
2750
+ const node = match.node;
2751
+ const key = node.name.text;
2752
+ newProps.push(`${KEY_RENAME[key]}: ${node.initializer.getText(sourceFile)}`);
2753
+ let start = node.getStart();
2754
+ let end = node.getEnd();
2755
+ const trailingComma = text.slice(end).match(/^(\s*,)/);
2756
+ if (trailingComma) end += trailingComma[1].length;
2757
+ else {
2758
+ const leadingComma = text.slice(0, start).match(/,\s*$/);
2759
+ if (leadingComma) start -= leadingComma[0].length;
2760
+ }
2761
+ edits.push({
2762
+ start,
2763
+ end,
2764
+ replacement: ""
2765
+ });
2766
+ }
2767
+ const parentObject = matches[0].node.parent;
2768
+ const existingCompat = parentObject.properties.find((p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === "compat" && ts.isObjectLiteralExpression(p.initializer));
2769
+ if (existingCompat) edits.push(insertIntoObjectLiteral(existingCompat.initializer, newProps));
2770
+ else edits.push(insertIntoObjectLiteral(parentObject, [`compat: { ${newProps.join(", ")} }`]));
2771
+ let result = text;
2772
+ for (const edit of edits.sort((a, b) => b.start - a.start)) result = result.slice(0, edit.start) + edit.replacement + result.slice(edit.end);
2773
+ return result;
2774
+ }
2775
+ };
2776
+ function insertIntoObjectLiteral(obj, newProps) {
2777
+ if (obj.properties.length === 0) {
2778
+ const pos = obj.getStart() + 1;
2779
+ return {
2780
+ start: pos,
2781
+ end: pos,
2782
+ replacement: ` ${newProps.join(", ")} `
2783
+ };
2784
+ }
2785
+ const last = obj.properties[obj.properties.length - 1];
2786
+ return {
2787
+ start: last.getEnd(),
2788
+ end: last.getEnd(),
2789
+ replacement: `, ${newProps.join(", ")}`
2790
+ };
2791
+ }
2792
+ //#endregion
2611
2793
  //#region src/migrations/index.ts
2612
2794
  /**
2613
2795
  * Build a map of local import names to their original names from @stencil/core.
@@ -2654,10 +2836,12 @@ const migrationRules = [
2654
2836
  globalStyleInjectRule,
2655
2837
  lightDomPatchesRule,
2656
2838
  extrasToCompatRule,
2839
+ suppressWarningsToCompatRule,
2657
2840
  externalRuntimeRule,
2658
2841
  hashFileNamesRule,
2659
2842
  rolldownConfigRule,
2660
- serviceWorkerDefaultRule
2843
+ serviceWorkerDefaultRule,
2844
+ cssImportQueryParamRule
2661
2845
  ];
2662
2846
  /**
2663
2847
  * Get all migration rules for a specific version upgrade.
@@ -2767,7 +2951,8 @@ const detectMigrations = async (coreCompiler, config) => {
2767
2951
  const sys = config.sys;
2768
2952
  const logger = config.logger;
2769
2953
  const currentMajor = coreCompiler.version.split(".")[0];
2770
- const rules = getRulesForVersionUpgrade(String(Number(currentMajor) - 1), currentMajor);
2954
+ const fromVersion = String(Number(currentMajor) - 1);
2955
+ const rules = getRulesForVersionUpgrade(fromVersion, currentMajor);
2771
2956
  if (rules.length === 0) return {
2772
2957
  hasMigrations: false,
2773
2958
  totalMatches: 0,
@@ -3835,7 +4020,8 @@ async function copyTemplate(rootDir, projectName, namespace, stencilVersion) {
3835
4020
  for (const entry of entries) {
3836
4021
  if (!entry.isFile()) continue;
3837
4022
  const srcPath = join(entry.parentPath, entry.name);
3838
- const relPath = relative(templateDir, srcPath);
4023
+ let relPath = relative(templateDir, srcPath);
4024
+ if (relPath === "_gitignore") relPath = ".gitignore";
3839
4025
  const destPath = join(rootDir, relPath);
3840
4026
  await mkdir(dirname(destPath), { recursive: true });
3841
4027
  const content = (await readFile(srcPath, "utf8")).replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{NAMESPACE\}\}/g, namespace).replace(/\{\{STENCIL_VERSION\}\}/g, resolvedStencilVersion);
@@ -3962,12 +4148,12 @@ async function writeIndexHtml(rootDir, content) {
3962
4148
  await mkdir(dirname(path), { recursive: true });
3963
4149
  await writeIfAbsent(path, content);
3964
4150
  }
3965
- function workspaceBuildScript(pm) {
4151
+ function workspaceBuildScript(pm, coreName) {
3966
4152
  switch (pm) {
3967
4153
  case "pnpm": return "pnpm -r build";
3968
4154
  case "yarn": return "yarn workspaces run build";
3969
4155
  case "bun": return "bun run --filter \"*\" build";
3970
- default: return "npm run build --workspaces --if-present";
4156
+ default: return `npm run build -w packages/${coreName} && npm run build --workspaces --if-present`;
3971
4157
  }
3972
4158
  }
3973
4159
  /**
@@ -3976,9 +4162,10 @@ function workspaceBuildScript(pm) {
3976
4162
  * `package.json` for npm / yarn / bun), and ensures a root `package.json` exists.
3977
4163
  * @param cwd - Absolute path to the workspace root (where `package.json` will be created).
3978
4164
  * @param projectName - Name to use for the root package.json (typically the project name).
4165
+ * @param coreName - Directory name of the core package under `packages/` (e.g. `core`).
3979
4166
  * @returns A promise that resolves when the workspace root has been scaffolded.
3980
4167
  */
3981
- async function scaffoldWorkspaceRoot(cwd, projectName) {
4168
+ async function scaffoldWorkspaceRoot(cwd, projectName, coreName) {
3982
4169
  await mkdir(join(cwd, "packages"), { recursive: true });
3983
4170
  const pm = await detectPackageManager(cwd);
3984
4171
  const usePnpmYaml = pm?.name === "pnpm";
@@ -3993,7 +4180,7 @@ async function scaffoldWorkspaceRoot(cwd, projectName) {
3993
4180
  pkg.version ??= "0.0.1";
3994
4181
  pkg.private = true;
3995
4182
  pkg.scripts = {
3996
- build: workspaceBuildScript(pm?.name),
4183
+ build: workspaceBuildScript(pm?.name, coreName),
3997
4184
  ...pkg.scripts
3998
4185
  };
3999
4186
  if (!usePnpmYaml) pkg.workspaces = ["packages/*"];
@@ -4020,47 +4207,34 @@ async function applyPackageJsonFields(rootDir, fields) {
4020
4207
  //#endregion
4021
4208
  //#region src/task-init.ts
4022
4209
  /**
4023
- * Package managers can report success while silently failing to write to node_modules
4024
- * (observed with npm computing a resolved lockfile but reifying zero filesystem changes).
4210
+ * Package managers can report success while silently failing to write to node_modules.
4025
4211
  * Confirms packages actually landed on disk instead of trusting the install call's exit code.
4026
4212
  *
4027
4213
  * @param rootDir - directory to resolve packages from.
4028
4214
  * @param packageNames - packages that were just supposed to be installed.
4029
- * @returns names that failed to resolve; empty when everything installed correctly.
4030
4215
  */
4031
4216
  async function verifyInstalled(rootDir, packageNames) {
4032
4217
  const missing = [];
4033
4218
  for (const name of packageNames) if (!await getPackageInfo(name, { paths: [rootDir] })) missing.push(name);
4034
- return missing;
4035
- }
4036
- function failInstallVerification(missing, rootDir) {
4219
+ if (missing.length === 0) return;
4037
4220
  p.log.error(`Install reported success but ${missing.join(", ")} could not be found in ${rootDir}. Your package manager may have silently failed to write to node_modules - check its logs and try again.`);
4038
4221
  process.exit(1);
4039
4222
  }
4040
- const NPM_CONFIG_ENV_PATTERN = /^npm_config_/i;
4041
4223
  /**
4042
- * `stencil init` is commonly run via `npx create-stencil` / `npm init stencil`, which means
4043
- * this process itself is a nested child of an active npm/npx invocation. npm sets `npm_config_*`
4044
- * env vars on every process it spawns, and a nested `npm install` inherits and gets confused by
4045
- * the *outer* invocation's config (observed: silently reifying zero changes despite an empty
4046
- * node_modules - see docs.npmjs.com/cli/using-npm/config and nestjs/nest-cli#153 for the same
4047
- * class of bug). Stripping them for the duration of our own install calls forces the nested
4048
- * npm to compute its config fresh from cwd instead of inheriting the outer process's state.
4049
- *
4050
- * @param fn - install call to run with a clean environment.
4051
- * @returns whatever `fn` resolves to.
4224
+ * npm silently omits devDependencies when this CLI is itself running as a nested child
4225
+ * process (e.g. via `npx create-stencil` / `npm init stencil`). Root cause: npm/exec only
4226
+ * needs @stencil/cli's own regular dependencies to resolve+run it, so that install computes
4227
+ * `omit: ['dev']` - and per npm's own config flattening
4228
+ * (@npmcli/config/lib/definitions/definitions.js), whenever `omit` includes 'dev' npm sets
4229
+ * `process.env.NODE_ENV = 'production'` on itself. We inherit that env var from the outer
4230
+ * npm/npx process, and every child process we (or a wizard plugin) spawn from here would
4231
+ * inherit it right back, causing nested `npm install`s to also compute `omit: ['dev']` and
4232
+ * silently drop (or, worse, actively remove) every devDependency in the scaffolded project.
4233
+ * Clearing it once, up front, fixes every install call transitively - ours and every wizard
4234
+ * plugin's - without needing to special-case npm invocations one by one.
4052
4235
  */
4053
- async function withoutInheritedNpmConfig(fn) {
4054
- const saved = {};
4055
- for (const key of Object.keys(process.env)) if (NPM_CONFIG_ENV_PATTERN.test(key)) {
4056
- saved[key] = process.env[key];
4057
- delete process.env[key];
4058
- }
4059
- try {
4060
- return await fn();
4061
- } finally {
4062
- for (const [key, value] of Object.entries(saved)) process.env[key] = value;
4063
- }
4236
+ function clearInheritedProductionEnv() {
4237
+ if (process.env.NODE_ENV === "production") delete process.env.NODE_ENV;
4064
4238
  }
4065
4239
  function outputKeysToTargets(keys) {
4066
4240
  const map = {
@@ -4073,6 +4247,7 @@ function outputKeysToTargets(keys) {
4073
4247
  return keys.length > 0 ? keys.map((k) => ({ type: map[k] })) : [{ type: "loader-bundle" }];
4074
4248
  }
4075
4249
  async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
4250
+ clearInheritedProductionEnv();
4076
4251
  const cwd = process.cwd();
4077
4252
  const isExistingProject = await isExistingStencilProject(cwd);
4078
4253
  printSplash();
@@ -4119,7 +4294,7 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
4119
4294
  const coreDir = monorepo ? join(cwd, "packages", coreName) : cwd;
4120
4295
  const s1 = p.spinner();
4121
4296
  s1.start("Scaffolding project files");
4122
- if (monorepo) await scaffoldWorkspaceRoot(cwd, projectName);
4297
+ if (monorepo) await scaffoldWorkspaceRoot(cwd, projectName, coreName);
4123
4298
  await copyTemplate(coreDir, projectName, namespace, coreCompiler?.version);
4124
4299
  await applyPackageJsonFields(coreDir, generatePackageJsonFields(outputs));
4125
4300
  if (configSource) await writeStencilConfig(coreDir, configSource);
@@ -4133,24 +4308,22 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
4133
4308
  s1.stop("Project files created");
4134
4309
  const s2 = p.spinner();
4135
4310
  s2.start("Installing dependencies");
4136
- await withoutInheritedNpmConfig(() => installDependencies({
4311
+ await nypm.installDependencies({
4137
4312
  cwd,
4138
4313
  silent: true
4139
- }));
4314
+ });
4140
4315
  s2.stop("Dependencies installed");
4141
- const missingBase = await verifyInstalled(coreDir, ["@stencil/core"]);
4142
- if (missingBase.length > 0) failInstallVerification(missingBase, coreDir);
4316
+ await verifyInstalled(coreDir, ["@stencil/core"]);
4143
4317
  if (selectedIntegrations.length > 0) {
4144
4318
  const s3 = p.spinner();
4145
4319
  const pkgs = selectedIntegrations.map((i) => i.package);
4146
4320
  s3.start(`Installing ${pkgs.join(", ")}`);
4147
- await withoutInheritedNpmConfig(() => addDevDependency(withVersionRanges(pkgs), {
4321
+ await nypm.addDevDependency(withVersionRanges(pkgs), {
4148
4322
  cwd: coreDir,
4149
4323
  silent: true
4150
- }));
4324
+ });
4151
4325
  s3.stop("Integrations installed");
4152
- const missingIntegrations = await verifyInstalled(coreDir, pkgs);
4153
- if (missingIntegrations.length > 0) failInstallVerification(missingIntegrations, coreDir);
4326
+ await verifyInstalled(coreDir, pkgs);
4154
4327
  }
4155
4328
  if (selectedIntegrations.length > 0) {
4156
4329
  const discovered = await discoverPlugins(coreDir);
@@ -4182,7 +4355,7 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
4182
4355
  async function addCapabilities(cwd, strictConfig) {
4183
4356
  const workspaceRoot = await detectWorkspaceRoot(cwd);
4184
4357
  const raw = JSON.parse(await readFile(join(cwd, "package.json"), "utf8"));
4185
- const installed = new Set([...Object.keys(raw.dependencies ?? {}), ...Object.keys(raw.devDependencies ?? {})]);
4358
+ const installed = /* @__PURE__ */ new Set([...Object.keys(raw.dependencies ?? {}), ...Object.keys(raw.devDependencies ?? {})]);
4186
4359
  const discovered = await discoverPlugins(cwd);
4187
4360
  const configurable = discovered.filter((d) => d.plugin.init);
4188
4361
  const installable = KNOWN_INTEGRATIONS.filter((i) => !installed.has(i.package));
@@ -4210,13 +4383,12 @@ async function addCapabilities(cwd, strictConfig) {
4210
4383
  const s = p.spinner();
4211
4384
  const pkgs = toInstall.map((i) => i.package);
4212
4385
  s.start(`Installing ${pkgs.join(", ")}`);
4213
- await withoutInheritedNpmConfig(() => addDevDependency(withVersionRanges(pkgs), {
4386
+ await nypm.addDevDependency(withVersionRanges(pkgs), {
4214
4387
  cwd,
4215
4388
  silent: true
4216
- }));
4389
+ });
4217
4390
  s.stop("Dependencies installed");
4218
- const missing = await verifyInstalled(cwd, pkgs);
4219
- if (missing.length > 0) failInstallVerification(missing, cwd);
4391
+ await verifyInstalled(cwd, pkgs);
4220
4392
  }
4221
4393
  const allDiscovered = toInstall.length > 0 ? await discoverPlugins(cwd) : discovered;
4222
4394
  const newlyInstalledPkgs = new Set(toInstall.map((i) => i.package));
@@ -4234,7 +4406,8 @@ async function addCapabilities(cwd, strictConfig) {
4234
4406
  p.outro("Done! Run pnpm run dev to continue.");
4235
4407
  }
4236
4408
  function toNamespace(name) {
4237
- return toPascalCase(name.replace(/^@[^/]+\//, "").replace(/[/_]/g, "-"));
4409
+ const base = name.replace(/^@[^/]+\//, "");
4410
+ return toPascalCase(base.replace(/[/_]/g, "-"));
4238
4411
  }
4239
4412
  //#endregion
4240
4413
  //#region src/task-serve.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/cli",
3
- "version": "5.0.0-alpha.27",
3
+ "version": "5.0.0-alpha.29",
4
4
  "description": "CLI for Stencil - Web component compiler",
5
5
  "keywords": [
6
6
  "components",
@@ -37,21 +37,21 @@
37
37
  "./cli": "./bin/stencil.mjs"
38
38
  },
39
39
  "dependencies": {
40
- "@clack/prompts": "^1.5.1",
40
+ "@clack/prompts": "^1.7.0",
41
41
  "local-pkg": "^1.2.1",
42
42
  "nypm": "^0.3.12",
43
- "std-env": "^3.8.0",
44
- "typescript": ">4.0.0 <7.0.0",
45
- "@stencil/templates": "5.0.0-alpha.27",
46
- "@stencil/dev-server": "5.0.0-alpha.27"
43
+ "std-env": "^3.10.0",
44
+ "typescript": "^6.0.3",
45
+ "@stencil/templates": "5.0.0-alpha.29",
46
+ "@stencil/dev-server": "5.0.0-alpha.29"
47
47
  },
48
48
  "devDependencies": {
49
- "tsdown": ">=0.21.0 <1.0.0",
50
- "vitest": "^4.1.7",
51
- "@stencil/core": "5.0.0-alpha.27"
49
+ "tsdown": "^0.22.14",
50
+ "vitest": "^4.1.10",
51
+ "@stencil/core": "5.0.0-alpha.29"
52
52
  },
53
53
  "peerDependencies": {
54
- "@stencil/core": "^5.0.0 || 5.0.0-alpha.27"
54
+ "@stencil/core": "^5.0.0 || 5.0.0-alpha.29"
55
55
  },
56
56
  "volta": {
57
57
  "extends": "../../package.json"
File without changes