@stencil/cli 5.0.0-beta.11 → 5.0.0-beta.13

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
@@ -362,6 +362,16 @@ interface WizardContext {
362
362
  */
363
363
  ts: typeof import('typescript');
364
364
  }
365
+ /**
366
+ * What `stencil generate` is creating - passed to each {@link WizardFileTemplate.template}.
367
+ */
368
+ interface GeneratedComponentInfo {
369
+ /**
370
+ * `true` for a CSS-only component: a `@component`-marked stylesheet with no JS class, so there's
371
+ * nothing to import - refer to it by tag name.
372
+ */
373
+ cssOnly: boolean;
374
+ }
365
375
  /**
366
376
  * A single file a plugin can offer during `stencil generate`.
367
377
  */
@@ -381,7 +391,7 @@ interface WizardFileTemplate {
381
391
  /**
382
392
  * Returns the file content. `className` is the PascalCase form of `tagName`.
383
393
  */
384
- template: (tagName: string, className: string) => string;
394
+ template: (tagName: string, className: string, component: GeneratedComponentInfo) => string;
385
395
  /** Pre-selected in the generate prompt. Defaults to `true`. */
386
396
  selectedByDefault?: boolean;
387
397
  }
@@ -391,6 +401,8 @@ interface WizardFileTemplate {
391
401
  interface GenerateContext {
392
402
  /** The dash-case component tag name entered by the user. */
393
403
  tagName: string;
404
+ /** `true` when generating a CSS-only component - e.g. to leave out templates that need a JS class. */
405
+ cssOnly: boolean;
394
406
  /** Resolved project config. See {@link ProjectConfig} for available fields. */
395
407
  config: ProjectConfig;
396
408
  /** Clack prompts - use instead of importing `@clack/prompts` directly for consistent UX. */
@@ -457,4 +469,4 @@ interface StencilWizardPlugin {
457
469
  init?: WizardInitContribution;
458
470
  }
459
471
  //#endregion
460
- export { BOOLEAN_CLI_FLAGS, type ConfigFlags, type GenerateContext, type ProjectConfig, type StencilConfigEditor, type StencilWizardPlugin, type TaskCommand, type WizardContext, type WizardFileTemplate, type WizardGenerateContribution, type WizardInitContribution, createConfigFlags, parseFlags, run, runTask };
472
+ export { BOOLEAN_CLI_FLAGS, type ConfigFlags, type GenerateContext, type GeneratedComponentInfo, type ProjectConfig, type StencilConfigEditor, type StencilWizardPlugin, type TaskCommand, type WizardContext, type WizardFileTemplate, type WizardGenerateContribution, type WizardInitContribution, createConfigFlags, parseFlags, run, runTask };
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ import { getPackageInfo } from "local-pkg";
13
13
  import { existsSync } from "node:fs";
14
14
  import { homedir } from "node:os";
15
15
  import { dirname as dirname$1, isAbsolute, join as join$1, relative as relative$1 } from "path";
16
- import { generateIndexHtml, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getPreviewHtmlBoilerplate, getStyleBoilerplate, getTemplatePath, getUsageExampleBoilerplate, toPascalCase } from "@stencil/templates";
16
+ import { generateIndexHtml, generatePackageJsonFields, generateStencilConfig, getComponentBoilerplate, getCssOnlyComponentBoilerplate, getPreviewHtmlBoilerplate, getStyleBoilerplate, getTemplatePath, getUsageExampleBoilerplate, toPascalCase } from "@stencil/templates";
17
17
  import { start } from "@stencil/dev-server";
18
18
  //#region src/config-flags.ts
19
19
  /**
@@ -1210,7 +1210,7 @@ async function isExistingStencilProject(dir) {
1210
1210
  }
1211
1211
  //#endregion
1212
1212
  //#region src/wizard/splash.ts
1213
- const CLI_VERSION = "5.0.0-beta.11";
1213
+ const CLI_VERSION = "5.0.0-beta.13";
1214
1214
  const isTTY = process.stdout.isTTY;
1215
1215
  const noColor = !isTTY || "NO_COLOR" in process.env;
1216
1216
  const RESET = noColor ? "" : "\x1B[0m";
@@ -3841,26 +3841,48 @@ const taskGenerate = async (config, flags) => {
3841
3841
  config.logger.error(tagError);
3842
3842
  return config.sys.exit(1);
3843
3843
  }
3844
- const styleOptions = [
3845
- {
3846
- value: "css",
3847
- label: "CSS (.css)"
3848
- },
3849
- ...[...new Set(generateContribs.flatMap((c) => c.styleExtensions ?? []))].map((ext) => ({
3850
- value: ext,
3851
- label: `${ext.toUpperCase()} (.${ext})`
3852
- })),
3853
- {
3854
- value: "",
3855
- label: "None"
3856
- }
3857
- ];
3858
- const stylePick = await p.select({
3859
- message: "Stylesheet format:",
3860
- options: styleOptions
3844
+ const componentType = await p.select({
3845
+ message: "Component type:",
3846
+ options: [{
3847
+ value: "component",
3848
+ label: "Component",
3849
+ hint: "@Component decorator, TSX"
3850
+ }, {
3851
+ value: "css-only",
3852
+ label: "CSS-only component",
3853
+ hint: "pure CSS, no JS class or runtime"
3854
+ }]
3861
3855
  });
3862
- cancelIfAborted(stylePick);
3863
- const styleExtension = stylePick || void 0;
3856
+ cancelIfAborted(componentType);
3857
+ const isCssOnly = componentType === "css-only";
3858
+ if (isCssOnly && config.enableCssOnlyComponents === false) p.note("`enableCssOnlyComponents` is disabled in your stencil.config - this component will not be discovered until it is re-enabled.", "Warning");
3859
+ const styleExtOptions = [{
3860
+ value: "css",
3861
+ label: "CSS (.css)"
3862
+ }, ...[...new Set(generateContribs.flatMap((c) => c.styleExtensions ?? []))].map((ext) => ({
3863
+ value: ext,
3864
+ label: `${ext.toUpperCase()} (.${ext})`
3865
+ }))];
3866
+ let styleExtension;
3867
+ let cssOnlyExtension = "css";
3868
+ if (isCssOnly) {
3869
+ const stylePick = await p.select({
3870
+ message: "Stylesheet format:",
3871
+ options: styleExtOptions
3872
+ });
3873
+ cancelIfAborted(stylePick);
3874
+ cssOnlyExtension = stylePick;
3875
+ } else {
3876
+ const stylePick = await p.select({
3877
+ message: "Stylesheet format:",
3878
+ options: [...styleExtOptions, {
3879
+ value: "",
3880
+ label: "None"
3881
+ }]
3882
+ });
3883
+ cancelIfAborted(stylePick);
3884
+ styleExtension = stylePick || void 0;
3885
+ }
3864
3886
  const demoPick = await p.select({
3865
3887
  message: "Demo:",
3866
3888
  options: [
@@ -3883,6 +3905,7 @@ const taskGenerate = async (config, flags) => {
3883
3905
  cancelIfAborted(demoPick);
3884
3906
  const generateCtx = {
3885
3907
  tagName: componentName,
3908
+ cssOnly: isCssOnly,
3886
3909
  config: toProjectConfig(config),
3887
3910
  prompts: p,
3888
3911
  nypm
@@ -3906,20 +3929,26 @@ const taskGenerate = async (config, flags) => {
3906
3929
  const outDir = join(srcDir, "components", dir, componentName);
3907
3930
  const className = toPascalCase(componentName);
3908
3931
  const filesToWrite = [];
3909
- filesToWrite.push({
3910
- absPath: normalizePath(join(outDir, `${componentName}.tsx`)),
3911
- content: getComponentBoilerplate(componentName, styleExtension)
3912
- });
3913
- if (styleExtension) filesToWrite.push({
3914
- absPath: normalizePath(join(outDir, `${componentName}.${styleExtension}`)),
3915
- content: getStyleBoilerplate(styleExtension)
3932
+ if (isCssOnly) filesToWrite.push({
3933
+ absPath: normalizePath(join(outDir, `${componentName}.${cssOnlyExtension}`)),
3934
+ content: getCssOnlyComponentBoilerplate(componentName, cssOnlyExtension)
3916
3935
  });
3936
+ else {
3937
+ filesToWrite.push({
3938
+ absPath: normalizePath(join(outDir, `${componentName}.tsx`)),
3939
+ content: getComponentBoilerplate(componentName, styleExtension)
3940
+ });
3941
+ if (styleExtension) filesToWrite.push({
3942
+ absPath: normalizePath(join(outDir, `${componentName}.${styleExtension}`)),
3943
+ content: getStyleBoilerplate(styleExtension)
3944
+ });
3945
+ }
3917
3946
  for (const ext of pickedExtensions) {
3918
3947
  const tmpl = allFileTemplates.find((ft) => ft.extension === ext);
3919
3948
  const absPath = normalizePath(join(outDir, tmpl.subdirectory ?? "", `${componentName}.${ext}`));
3920
3949
  filesToWrite.push({
3921
3950
  absPath,
3922
- content: tmpl.template(componentName, className)
3951
+ content: tmpl.template(componentName, className, { cssOnly: isCssOnly })
3923
3952
  });
3924
3953
  }
3925
3954
  if (demoPick === "usage") filesToWrite.push({
@@ -4234,7 +4263,7 @@ async function writeStencilConfig(rootDir, content) {
4234
4263
  async function writeGlobalStyle(rootDir) {
4235
4264
  const path = join(rootDir, "src", "global.css");
4236
4265
  await mkdir(dirname(path), { recursive: true });
4237
- await writeIfAbsent(path, `@import "stencil-globals";\n@import "stencil-hydrate";\n`);
4266
+ await writeIfAbsent(path, `@import "stencil-component-globals";\n@import "stencil-hydrate";\n`);
4238
4267
  }
4239
4268
  async function writeGlobalScript(rootDir) {
4240
4269
  const path = join(rootDir, "src", "global.ts");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/cli",
3
- "version": "5.0.0-beta.11",
3
+ "version": "5.0.0-beta.13",
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/dev-server": "5.0.0-beta.11",
46
- "@stencil/templates": "5.0.0-beta.11"
45
+ "@stencil/templates": "5.0.0-beta.13",
46
+ "@stencil/dev-server": "5.0.0-beta.13"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsdown": "^0.22.14",
50
50
  "vitest": "^4.1.10",
51
- "@stencil/core": "5.0.0-beta.11"
51
+ "@stencil/core": "5.0.0-beta.13"
52
52
  },
53
53
  "peerDependencies": {
54
- "@stencil/core": "^5.0.0 || 5.0.0-beta.11"
54
+ "@stencil/core": "^5.0.0 || 5.0.0-beta.13"
55
55
  },
56
56
  "volta": {
57
57
  "extends": "../../package.json"