@stencil/cli 5.0.0-beta.15 → 5.0.0-beta.16
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 +18 -0
- package/dist/index.mjs +216 -151
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -174,6 +174,11 @@ interface ProjectConfig {
|
|
|
174
174
|
compat?: ConfigCompat;
|
|
175
175
|
/** Enable signal-based reactivity backing (top-level in stencil.config.ts). */
|
|
176
176
|
signalBacking?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Whether the build writes an `exports` map into the project's `package.json`. When `true`,
|
|
179
|
+
* consumers can only import the paths that map lists (e.g. `<pkg>/ssr`, not `<pkg>/dist/ssr`).
|
|
180
|
+
*/
|
|
181
|
+
generateExportMaps?: boolean;
|
|
177
182
|
}
|
|
178
183
|
/**
|
|
179
184
|
* Structured editor for `stencil.config.ts`, backed by the TypeScript compiler API.
|
|
@@ -323,6 +328,19 @@ interface StencilConfigEditor {
|
|
|
323
328
|
* editor.removePlugin('sass(');
|
|
324
329
|
*/
|
|
325
330
|
removePlugin(substring: string): boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Sets a top-level property on the config object to `expression`, replacing its
|
|
333
|
+
* value if the property already exists, or adding it (after `namespace`, when
|
|
334
|
+
* present) if it doesn't.
|
|
335
|
+
*
|
|
336
|
+
* @param name - The config property, e.g. `'generateExportMaps'`.
|
|
337
|
+
* @param expression - A TypeScript expression, inserted verbatim, e.g. `'true'`.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* editor.setProperty('generateExportMaps', 'true');
|
|
341
|
+
* // > generateExportMaps: true,
|
|
342
|
+
*/
|
|
343
|
+
setProperty(name: string, expression: string): void;
|
|
326
344
|
/** Write all accumulated edits back to disk. */
|
|
327
345
|
save(): Promise<void>;
|
|
328
346
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -608,155 +608,164 @@ const mergeFlags = (config, flags) => {
|
|
|
608
608
|
async function openStencilConfig(configPath) {
|
|
609
609
|
let text = await readFile(configPath, "utf8");
|
|
610
610
|
const parse = () => ts.createSourceFile(configPath, text, ts.ScriptTarget.Latest, true);
|
|
611
|
-
|
|
611
|
+
const nodeText = (node) => text.slice(node.getStart(), node.getEnd());
|
|
612
|
+
const splice = (start, end, replacement) => {
|
|
613
|
+
text = text.slice(0, start) + replacement + text.slice(end);
|
|
614
|
+
};
|
|
615
|
+
const indentAt = (pos) => {
|
|
616
|
+
const lineStart = text.lastIndexOf("\n", pos - 1) + 1;
|
|
617
|
+
return text.slice(lineStart, pos).match(/^\s*/)?.[0] ?? "";
|
|
618
|
+
};
|
|
619
|
+
const reindent = (code, indent) => code.replace(/\n/g, `\n${indent}`);
|
|
620
|
+
const listItems = (list) => ts.isArrayLiteralExpression(list) ? list.elements : list.properties;
|
|
621
|
+
const isMultiLine = (list) => {
|
|
622
|
+
const [first] = listItems(list);
|
|
623
|
+
return !!first && text.slice(list.getStart(), first.getStart()).includes("\n");
|
|
624
|
+
};
|
|
625
|
+
const findProp = (obj, name) => obj.properties.find((p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === name);
|
|
626
|
+
function findConfigObject(sf) {
|
|
627
|
+
for (const stmt of sf.statements) if (ts.isVariableStatement(stmt)) {
|
|
628
|
+
for (const decl of stmt.declarationList.declarations) if (ts.isIdentifier(decl.name) && decl.name.text === "config" && decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) return decl.initializer;
|
|
629
|
+
}
|
|
612
630
|
let found;
|
|
613
631
|
const visit = (node) => {
|
|
614
|
-
if (
|
|
615
|
-
|
|
632
|
+
if (found) return;
|
|
633
|
+
if (ts.isObjectLiteralExpression(node) && findProp(node, "namespace")) {
|
|
634
|
+
found = node;
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
ts.forEachChild(node, visit);
|
|
616
638
|
};
|
|
617
639
|
visit(sf);
|
|
618
640
|
return found;
|
|
619
641
|
}
|
|
620
|
-
function
|
|
621
|
-
|
|
622
|
-
|
|
642
|
+
function requireConfigObject() {
|
|
643
|
+
const configObj = findConfigObject(parse());
|
|
644
|
+
if (!configObj) throw new Error("Could not find Stencil config object in stencil.config.ts");
|
|
645
|
+
return configObj;
|
|
646
|
+
}
|
|
647
|
+
function findArray(propName) {
|
|
648
|
+
const sf = parse();
|
|
649
|
+
const configObj = findConfigObject(sf);
|
|
650
|
+
if (configObj) {
|
|
651
|
+
const init = findProp(configObj, propName)?.initializer;
|
|
652
|
+
return init && ts.isArrayLiteralExpression(init) ? init : void 0;
|
|
623
653
|
}
|
|
624
654
|
let found;
|
|
625
655
|
const visit = (node) => {
|
|
626
656
|
if (found) return;
|
|
627
|
-
if (ts.
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
657
|
+
if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text === propName && ts.isArrayLiteralExpression(node.initializer)) {
|
|
658
|
+
found = node.initializer;
|
|
659
|
+
return;
|
|
632
660
|
}
|
|
633
661
|
ts.forEachChild(node, visit);
|
|
634
662
|
};
|
|
635
663
|
visit(sf);
|
|
636
664
|
return found;
|
|
637
665
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
text = text.slice(0, lineStart) + text.slice(end);
|
|
658
|
-
} else {
|
|
659
|
-
let start = element.getStart();
|
|
660
|
-
let end = element.getEnd();
|
|
661
|
-
if (idx < arr.elements.length - 1) {
|
|
662
|
-
const trailingMatch = text.slice(end).match(/^,\s*/);
|
|
663
|
-
if (trailingMatch) end += trailingMatch[0].length;
|
|
664
|
-
} else if (idx > 0) {
|
|
665
|
-
const precedingMatch = text.slice(0, start).match(/,\s*$/);
|
|
666
|
-
if (precedingMatch) start -= precedingMatch[0].length;
|
|
667
|
-
}
|
|
668
|
-
text = text.slice(0, start) + text.slice(end);
|
|
666
|
+
/**
|
|
667
|
+
* Insert `code` as a new item of an array / object literal, matching the list's own layout
|
|
668
|
+
* (one item per line, or all on one line).
|
|
669
|
+
* @param list - The array or object literal to insert into.
|
|
670
|
+
* @param code - Source of the new item, indented relative to its own start.
|
|
671
|
+
* @param anchor - Item to insert after. Defaults to the last one.
|
|
672
|
+
*/
|
|
673
|
+
function insertItem(list, code, anchor) {
|
|
674
|
+
const items = listItems(list);
|
|
675
|
+
const [open, close] = ts.isArrayLiteralExpression(list) ? "[]" : "{}";
|
|
676
|
+
const multiLine = isMultiLine(list);
|
|
677
|
+
if (!multiLine && (code.includes("\n") || items.length === 0 && ts.isObjectLiteralExpression(list))) {
|
|
678
|
+
const baseIndent = indentAt(list.getStart());
|
|
679
|
+
const indent = baseIndent + " ";
|
|
680
|
+
const lines = items.map(nodeText);
|
|
681
|
+
const at = anchor ? items.indexOf(anchor) + 1 : lines.length;
|
|
682
|
+
lines.splice(at, 0, reindent(code, indent));
|
|
683
|
+
splice(list.getStart(), list.getEnd(), `${open}\n${indent}${lines.join(`,\n${indent}`)},\n${baseIndent}${close}`);
|
|
684
|
+
return;
|
|
669
685
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
function appendToArray(arr, code) {
|
|
673
|
-
if (arr.elements.length === 0) {
|
|
674
|
-
const insertPos = arr.getEnd() - 1;
|
|
675
|
-
text = text.slice(0, insertPos) + code + text.slice(insertPos);
|
|
686
|
+
if (items.length === 0) {
|
|
687
|
+
splice(list.getEnd() - 1, list.getEnd() - 1, code);
|
|
676
688
|
return;
|
|
677
689
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
const indent =
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
} else text = `${text.slice(0, insertPos)}${separator} ${code}${text.slice(insertPos)}`;
|
|
690
|
+
anchor ??= items[items.length - 1];
|
|
691
|
+
let pos = anchor.getEnd();
|
|
692
|
+
const trailingComma = text.slice(pos).match(/^\s*,/);
|
|
693
|
+
if (trailingComma) pos += trailingComma[0].length;
|
|
694
|
+
const before = trailingComma ? "" : ",";
|
|
695
|
+
const after = trailingComma ? "," : "";
|
|
696
|
+
if (multiLine) {
|
|
697
|
+
const indent = indentAt(items[0].getStart());
|
|
698
|
+
splice(pos, pos, `${before}\n${indent}${reindent(code, indent)}${after}`);
|
|
699
|
+
} else splice(pos, pos, `${before} ${code}${after}`);
|
|
689
700
|
}
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
let
|
|
694
|
-
if (
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
const newProp = `${propName}: [\n${elemIndent}${code.replace(/\n/g, `\n${elemIndent}`)},\n${propIndent}]`;
|
|
701
|
-
const lastProp = configObj.properties[configObj.properties.length - 1];
|
|
702
|
-
if (lastProp) {
|
|
703
|
-
let insertPos = lastProp.getEnd();
|
|
704
|
-
const trailingComma = text.slice(insertPos).match(/^\s*,/);
|
|
705
|
-
const separator = trailingComma ? "" : ",";
|
|
706
|
-
if (trailingComma) insertPos += trailingComma[0].length;
|
|
707
|
-
text = `${text.slice(0, insertPos)}${separator}\n${propIndent}${newProp}${text.slice(insertPos)}`;
|
|
708
|
-
} else {
|
|
709
|
-
const insertPos = configObj.getEnd() - 1;
|
|
710
|
-
text = `${text.slice(0, insertPos)}\n${propIndent}${newProp},\n${text.slice(insertPos)}`;
|
|
711
|
-
}
|
|
701
|
+
function removeItem(arr, element) {
|
|
702
|
+
const idx = arr.elements.indexOf(element);
|
|
703
|
+
let start = element.getStart();
|
|
704
|
+
let end = element.getEnd();
|
|
705
|
+
if (isMultiLine(arr)) {
|
|
706
|
+
start = text.lastIndexOf("\n", start);
|
|
707
|
+
end += text.slice(end).match(/^\s*,/)?.[0].length ?? 0;
|
|
708
|
+
} else if (idx < arr.elements.length - 1) end += text.slice(end).match(/^,\s*/)?.[0].length ?? 0;
|
|
709
|
+
else if (idx > 0) start -= text.slice(0, start).match(/,\s*$/)?.[0].length ?? 0;
|
|
710
|
+
splice(start, end, "");
|
|
712
711
|
}
|
|
712
|
+
function hasImport(moduleSpecifier) {
|
|
713
|
+
return parse().statements.some((s) => ts.isImportDeclaration(s) && ts.isStringLiteral(s.moduleSpecifier) && s.moduleSpecifier.text === moduleSpecifier);
|
|
714
|
+
}
|
|
715
|
+
function arrayProp(propName) {
|
|
716
|
+
const findElement = (arr, substring) => arr?.elements.find((element) => nodeText(element).includes(substring));
|
|
717
|
+
return {
|
|
718
|
+
contains(substring) {
|
|
719
|
+
const arr = findArray(propName);
|
|
720
|
+
return arr ? nodeText(arr).includes(substring) : false;
|
|
721
|
+
},
|
|
722
|
+
add(expression) {
|
|
723
|
+
const arr = findArray(propName);
|
|
724
|
+
if (arr) insertItem(arr, expression);
|
|
725
|
+
else insertItem(requireConfigObject(), `${propName}: [\n ${reindent(expression, " ")},\n]`);
|
|
726
|
+
},
|
|
727
|
+
replace(substring, expression) {
|
|
728
|
+
const element = findElement(findArray(propName), substring);
|
|
729
|
+
if (!element) return false;
|
|
730
|
+
splice(element.getStart(), element.getEnd(), reindent(expression, indentAt(element.getStart())));
|
|
731
|
+
return true;
|
|
732
|
+
},
|
|
733
|
+
remove(substring) {
|
|
734
|
+
const arr = findArray(propName);
|
|
735
|
+
const element = findElement(arr, substring);
|
|
736
|
+
if (!arr || !element) return false;
|
|
737
|
+
removeItem(arr, element);
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
const outputTargets = arrayProp("outputTargets");
|
|
743
|
+
const plugins = arrayProp("plugins");
|
|
713
744
|
return {
|
|
714
|
-
hasImport
|
|
715
|
-
return parse().statements.some((s) => ts.isImportDeclaration(s) && ts.isStringLiteral(s.moduleSpecifier) && s.moduleSpecifier.text === moduleSpecifier);
|
|
716
|
-
},
|
|
745
|
+
hasImport,
|
|
717
746
|
addImport(moduleSpecifier, namedImports) {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
text = insertPos > 0 ? text.slice(0, insertPos) + decl + text.slice(insertPos) : decl + "\n" + text;
|
|
724
|
-
},
|
|
725
|
-
outputTargetsContains(substring) {
|
|
726
|
-
const arr = findArray(parse(), "outputTargets");
|
|
727
|
-
return arr ? text.slice(arr.getStart(), arr.getEnd()).includes(substring) : false;
|
|
728
|
-
},
|
|
729
|
-
addOutputTarget(expression) {
|
|
730
|
-
const sf = parse();
|
|
731
|
-
const arr = findArray(sf, "outputTargets");
|
|
732
|
-
if (arr) appendToArray(arr, expression);
|
|
733
|
-
else addArrayProp(sf, "outputTargets", expression);
|
|
734
|
-
},
|
|
735
|
-
replaceOutputTarget(substring, expression) {
|
|
736
|
-
const arr = findArray(parse(), "outputTargets");
|
|
737
|
-
return arr ? replaceInArray(arr, substring, expression) : false;
|
|
738
|
-
},
|
|
739
|
-
removeOutputTarget(substring) {
|
|
740
|
-
const arr = findArray(parse(), "outputTargets");
|
|
741
|
-
return arr ? removeFromArray(arr, substring) : false;
|
|
747
|
+
if (hasImport(moduleSpecifier)) return;
|
|
748
|
+
const lastImport = parse().statements.filter(ts.isImportDeclaration).pop();
|
|
749
|
+
const decl = `import { ${namedImports.join(", ")} } from '${moduleSpecifier}';`;
|
|
750
|
+
if (lastImport) splice(lastImport.getEnd(), lastImport.getEnd(), `\n${decl}`);
|
|
751
|
+
else text = `\n${decl}\n${text}`;
|
|
742
752
|
},
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return arr ? removeFromArray(arr, substring) : false;
|
|
753
|
+
outputTargetsContains: outputTargets.contains,
|
|
754
|
+
addOutputTarget: outputTargets.add,
|
|
755
|
+
replaceOutputTarget: outputTargets.replace,
|
|
756
|
+
removeOutputTarget: outputTargets.remove,
|
|
757
|
+
pluginsContains: plugins.contains,
|
|
758
|
+
addPlugin: plugins.add,
|
|
759
|
+
replacePlugin: plugins.replace,
|
|
760
|
+
removePlugin: plugins.remove,
|
|
761
|
+
setProperty(name, expression) {
|
|
762
|
+
const configObj = requireConfigObject();
|
|
763
|
+
const existing = findProp(configObj, name);
|
|
764
|
+
if (existing) {
|
|
765
|
+
splice(existing.initializer.getStart(), existing.initializer.getEnd(), expression);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
insertItem(configObj, `${name}: ${expression}`, findProp(configObj, "namespace"));
|
|
760
769
|
},
|
|
761
770
|
async save() {
|
|
762
771
|
await writeFile(configPath, text, "utf8");
|
|
@@ -972,6 +981,7 @@ async function promptOutputs() {
|
|
|
972
981
|
hint: "app mode with dev server and optional PWA support"
|
|
973
982
|
}
|
|
974
983
|
],
|
|
984
|
+
initialValues: ["loader"],
|
|
975
985
|
required: false
|
|
976
986
|
});
|
|
977
987
|
cancelIfAborted(picks);
|
|
@@ -986,6 +996,11 @@ async function promptFeatures() {
|
|
|
986
996
|
label: "Signals",
|
|
987
997
|
hint: "signal-backed @Prop/@State for cross-framework reactive interop"
|
|
988
998
|
},
|
|
999
|
+
{
|
|
1000
|
+
value: "exportMaps",
|
|
1001
|
+
label: "Export maps",
|
|
1002
|
+
hint: "keep package.json \"exports\" in sync with your outputs and components on each build"
|
|
1003
|
+
},
|
|
989
1004
|
{
|
|
990
1005
|
value: "globalStyle",
|
|
991
1006
|
label: "Global style",
|
|
@@ -1003,6 +1018,7 @@ async function promptFeatures() {
|
|
|
1003
1018
|
const set = new Set(picks);
|
|
1004
1019
|
return {
|
|
1005
1020
|
signals: set.has("signals"),
|
|
1021
|
+
exportMaps: set.has("exportMaps"),
|
|
1006
1022
|
globalStyle: set.has("globalStyle"),
|
|
1007
1023
|
globalScript: set.has("globalScript")
|
|
1008
1024
|
};
|
|
@@ -1132,6 +1148,35 @@ async function promptAddCapabilities(installable, configurable) {
|
|
|
1132
1148
|
}
|
|
1133
1149
|
//#endregion
|
|
1134
1150
|
//#region src/wizard/project.ts
|
|
1151
|
+
const PACKAGE_MANAGERS = [
|
|
1152
|
+
"npm",
|
|
1153
|
+
"pnpm",
|
|
1154
|
+
"yarn",
|
|
1155
|
+
"bun"
|
|
1156
|
+
];
|
|
1157
|
+
/**
|
|
1158
|
+
* Resolve the package manager for `cwd`: a `packageManager` field / lockfile in the project
|
|
1159
|
+
* or its workspace wins, then whichever package manager launched this process, then npm.
|
|
1160
|
+
* @param cwd The directory to detect from. Parent directories are searched up to, but not
|
|
1161
|
+
* including, the home directory - a lockfile there doesn't describe this project.
|
|
1162
|
+
* @returns The package manager name.
|
|
1163
|
+
*/
|
|
1164
|
+
async function detectPackageManager$1(cwd) {
|
|
1165
|
+
const home = homedir();
|
|
1166
|
+
let dir = cwd;
|
|
1167
|
+
while (true) {
|
|
1168
|
+
const fromProject = await detectPackageManager(dir, {
|
|
1169
|
+
ignoreArgv: true,
|
|
1170
|
+
includeParentDirs: false
|
|
1171
|
+
});
|
|
1172
|
+
if (fromProject) return fromProject.name;
|
|
1173
|
+
const parent = dirname(dir);
|
|
1174
|
+
if (parent === dir || parent === home) break;
|
|
1175
|
+
dir = parent;
|
|
1176
|
+
}
|
|
1177
|
+
const invoker = process.env.npm_config_user_agent?.split("/")[0];
|
|
1178
|
+
return PACKAGE_MANAGERS.find((name) => name === invoker) ?? "npm";
|
|
1179
|
+
}
|
|
1135
1180
|
/**
|
|
1136
1181
|
* Extracts the stable, plugin-relevant fields from a fully-resolved compiler config.
|
|
1137
1182
|
* @param validated The fully-resolved compiler config.
|
|
@@ -1148,7 +1193,8 @@ function toProjectConfig(validated) {
|
|
|
1148
1193
|
globalScript: validated.globalScript,
|
|
1149
1194
|
globalStyle: validated.globalStyle,
|
|
1150
1195
|
compat: validated.compat,
|
|
1151
|
-
signalBacking: validated.signalBacking
|
|
1196
|
+
signalBacking: validated.signalBacking,
|
|
1197
|
+
generateExportMaps: validated.generateExportMaps
|
|
1152
1198
|
};
|
|
1153
1199
|
}
|
|
1154
1200
|
/**
|
|
@@ -1209,7 +1255,7 @@ async function isExistingStencilProject(dir) {
|
|
|
1209
1255
|
}
|
|
1210
1256
|
//#endregion
|
|
1211
1257
|
//#region src/wizard/splash.ts
|
|
1212
|
-
const CLI_VERSION = "5.0.0-beta.
|
|
1258
|
+
const CLI_VERSION = "5.0.0-beta.16";
|
|
1213
1259
|
const isTTY = process.stdout.isTTY;
|
|
1214
1260
|
const noColor = !isTTY || "NO_COLOR" in process.env;
|
|
1215
1261
|
const RESET = noColor ? "" : "\x1B[0m";
|
|
@@ -3785,8 +3831,8 @@ function workspaceBuildScript(pm, coreName) {
|
|
|
3785
3831
|
*/
|
|
3786
3832
|
async function scaffoldWorkspaceRoot(cwd, projectName, coreName) {
|
|
3787
3833
|
await mkdir(join(cwd, "packages"), { recursive: true });
|
|
3788
|
-
const pm = await detectPackageManager(cwd);
|
|
3789
|
-
const usePnpmYaml = pm
|
|
3834
|
+
const pm = await detectPackageManager$1(cwd);
|
|
3835
|
+
const usePnpmYaml = pm === "pnpm";
|
|
3790
3836
|
const pkgPath = join(cwd, "package.json");
|
|
3791
3837
|
let pkg;
|
|
3792
3838
|
try {
|
|
@@ -3798,7 +3844,7 @@ async function scaffoldWorkspaceRoot(cwd, projectName, coreName) {
|
|
|
3798
3844
|
pkg.version ??= "0.0.1";
|
|
3799
3845
|
pkg.private = true;
|
|
3800
3846
|
pkg.scripts = {
|
|
3801
|
-
build: workspaceBuildScript(pm
|
|
3847
|
+
build: workspaceBuildScript(pm, coreName),
|
|
3802
3848
|
...pkg.scripts
|
|
3803
3849
|
};
|
|
3804
3850
|
if (!usePnpmYaml) pkg.workspaces = ["packages/*"];
|
|
@@ -3854,15 +3900,24 @@ async function verifyInstalled(rootDir, packageNames) {
|
|
|
3854
3900
|
function clearInheritedProductionEnv() {
|
|
3855
3901
|
if (process.env.NODE_ENV === "production") delete process.env.NODE_ENV;
|
|
3856
3902
|
}
|
|
3903
|
+
const OUTPUT_TYPES = {
|
|
3904
|
+
loader: "loader-bundle",
|
|
3905
|
+
standalone: "standalone",
|
|
3906
|
+
ssr: "ssr",
|
|
3907
|
+
"ssr-wasm": "ssr-wasm",
|
|
3908
|
+
www: "www"
|
|
3909
|
+
};
|
|
3857
3910
|
function outputKeysToTargets(keys) {
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3911
|
+
return keys.length > 0 ? keys.map((k) => ({ type: OUTPUT_TYPES[k] })) : [{ type: "loader-bundle" }];
|
|
3912
|
+
}
|
|
3913
|
+
/**
|
|
3914
|
+
* Reads which outputs a config file declares.
|
|
3915
|
+
* @param configPath Absolute path to the `stencil.config.ts`.
|
|
3916
|
+
* @returns The output keys present in its `outputTargets` array.
|
|
3917
|
+
*/
|
|
3918
|
+
async function readConfigOutputKeys(configPath) {
|
|
3919
|
+
const editor = await openStencilConfig(configPath);
|
|
3920
|
+
return Object.keys(OUTPUT_TYPES).filter((key) => [`'`, `"`].some((q) => editor.outputTargetsContains(`type: ${q}${OUTPUT_TYPES[key]}${q}`)));
|
|
3866
3921
|
}
|
|
3867
3922
|
async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
3868
3923
|
clearInheritedProductionEnv();
|
|
@@ -3895,8 +3950,9 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3895
3950
|
namespace,
|
|
3896
3951
|
outputs,
|
|
3897
3952
|
signals: features.signals,
|
|
3953
|
+
exportMaps: features.exportMaps,
|
|
3898
3954
|
docs
|
|
3899
|
-
}) ?? (needsStencilConfig(selectedIntegrations) ? `import { Config } from '@stencil/core';\n\nexport const config: Config = {\n namespace: '${namespace}',\n
|
|
3955
|
+
}) ?? (needsStencilConfig(selectedIntegrations) ? `import type { Config } from '@stencil/core';\n\nexport const config: Config = {\n namespace: '${namespace}',\n};\n` : null);
|
|
3900
3956
|
const summaryLines = [
|
|
3901
3957
|
`Template: component-starter`,
|
|
3902
3958
|
`Name: ${projectName}`,
|
|
@@ -3910,6 +3966,7 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3910
3966
|
if (selectedIntegrations.length > 0) summaryLines.push(`Add: ${selectedIntegrations.map((i) => i.displayName).join(", ")}`);
|
|
3911
3967
|
p.note(summaryLines.join("\n"), "Summary");
|
|
3912
3968
|
const coreDir = monorepo ? join(cwd, "packages", coreName) : cwd;
|
|
3969
|
+
const pm = await detectPackageManager$1(cwd);
|
|
3913
3970
|
const s1 = p.spinner();
|
|
3914
3971
|
s1.start("Scaffolding project files");
|
|
3915
3972
|
if (monorepo) await scaffoldWorkspaceRoot(cwd, projectName, coreName);
|
|
@@ -3928,7 +3985,8 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3928
3985
|
s2.start("Installing dependencies");
|
|
3929
3986
|
await nypm.installDependencies({
|
|
3930
3987
|
cwd,
|
|
3931
|
-
silent: true
|
|
3988
|
+
silent: true,
|
|
3989
|
+
packageManager: pm
|
|
3932
3990
|
});
|
|
3933
3991
|
s2.stop("Dependencies installed");
|
|
3934
3992
|
await verifyInstalled(coreDir, ["@stencil/core"]);
|
|
@@ -3955,17 +4013,24 @@ async function taskInit(coreCompiler, strictConfig, loadProjectConfig) {
|
|
|
3955
4013
|
...toProjectConfig(resolvedValidated),
|
|
3956
4014
|
rootDir: coreDir
|
|
3957
4015
|
} : defaultProjectConfig(coreDir, { namespace });
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
4016
|
+
let ranWizard = false;
|
|
4017
|
+
for (const d of discovered) if (selectedPkgs.has(d.packageName) && d.plugin.init?.run) {
|
|
4018
|
+
ranWizard = true;
|
|
4019
|
+
await d.plugin.init.run({
|
|
4020
|
+
isNewProject: true,
|
|
4021
|
+
prompts: p,
|
|
4022
|
+
nypm,
|
|
4023
|
+
config: projectConfig,
|
|
4024
|
+
workspaceRoot: monorepo ? cwd : void 0,
|
|
4025
|
+
ts,
|
|
4026
|
+
openStencilConfig: () => openStencilConfig(join(projectConfig.rootDir, "stencil.config.ts"))
|
|
4027
|
+
});
|
|
4028
|
+
}
|
|
4029
|
+
if (ranWizard && configSource) {
|
|
4030
|
+
const finalOutputs = await readConfigOutputKeys(join(coreDir, "stencil.config.ts"));
|
|
4031
|
+
await applyPackageJsonFields(coreDir, generatePackageJsonFields(finalOutputs));
|
|
4032
|
+
}
|
|
3967
4033
|
}
|
|
3968
|
-
const pm = (await nypm.detectPackageManager(cwd))?.name ?? "npm";
|
|
3969
4034
|
const devDir = monorepo ? `packages/${coreName}` : null;
|
|
3970
4035
|
const devCmd = `${pm} run dev`;
|
|
3971
4036
|
p.outro(devDir ? `Your project is ready!\n cd ${devDir}\n ${devCmd}` : `Your project is ready! Run: ${devCmd}`);
|
|
@@ -4021,7 +4086,7 @@ async function addCapabilities(cwd, strictConfig) {
|
|
|
4021
4086
|
ts,
|
|
4022
4087
|
openStencilConfig: () => openStencilConfig(join(projectConfig.rootDir, "stencil.config.ts"))
|
|
4023
4088
|
});
|
|
4024
|
-
p.outro(
|
|
4089
|
+
p.outro(`Done! Run ${await detectPackageManager$1(cwd)} run dev to continue.`);
|
|
4025
4090
|
}
|
|
4026
4091
|
function toNamespace(name) {
|
|
4027
4092
|
const base = name.replace(/^@[^/]+\//, "");
|
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.16",
|
|
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/dev-server": "5.0.0-beta.16",
|
|
46
|
+
"@stencil/templates": "5.0.0-beta.16"
|
|
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.16"
|
|
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.16"
|
|
55
55
|
},
|
|
56
56
|
"volta": {
|
|
57
57
|
"extends": "../../package.json"
|