@stencil/core 5.0.0-rc.5 → 5.0.0-rc.7

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.
@@ -1845,7 +1845,7 @@ const validateComponentTag = (tag) => {
1845
1845
  };
1846
1846
  //#endregion
1847
1847
  //#region src/version.ts
1848
- const version = "5.0.0-rc.5";
1848
+ const version = "5.0.0-rc.7";
1849
1849
  //#endregion
1850
1850
  //#region src/compiler/events.ts
1851
1851
  const buildEvents = () => {
@@ -3888,6 +3888,24 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
3888
3888
  */
3889
3889
  const isJsDocComment = (commentText) => commentText.startsWith("*") || commentText.startsWith("!");
3890
3890
  /**
3891
+ * An explicit `@prop` annotation tag in a CSS docstring. `@cssprop`/`@cssproperty` are also
3892
+ * recognized as synonyms (the more common names in other web-component-analyzer/docgen
3893
+ * ecosystems).
3894
+ */
3895
+ const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
3896
+ /**
3897
+ * An annotation tag that documents something by name (`@prop --x`, `@slot name`, ...) rather
3898
+ * than describing the node below its comment.
3899
+ */
3900
+ const CSS_ANNOTATION_TAG_RE = /@(?:component|cssproperty|cssprop|prop|attr|slot)\b/;
3901
+ /**
3902
+ * Whether a comment describes the node immediately following it (a declaration, rule or
3903
+ * at-rule). A comment holding annotation tags documents the things it names instead.
3904
+ * @param commentText a postcss `Comment` node's `.text`
3905
+ * @returns `true` if the comment is a JSDoc-style description of the next node
3906
+ */
3907
+ const isNodeDocComment = (commentText) => isJsDocComment(commentText) && !CSS_ANNOTATION_TAG_RE.test(commentText);
3908
+ /**
3891
3909
  * Strip the leading `*`/`!` marker and per-line `*` prefixes, returning trimmed lines.
3892
3910
  * @param commentText a postcss `Comment` node's `.text`
3893
3911
  * @returns the comment's lines, delimiters and leading `*`s stripped
@@ -4001,7 +4019,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
4001
4019
  const child = children[i];
4002
4020
  if (child.type !== "decl" || !child.prop.startsWith("--") || hasName(child.prop)) continue;
4003
4021
  const prev = children[i - 1];
4004
- if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
4022
+ if (!prev || prev.type !== "comment" || !isNodeDocComment(prev.text)) continue;
4005
4023
  styleDocs.push({
4006
4024
  name: child.prop,
4007
4025
  docs: normalizeJsDocText(prev.text),
@@ -4015,7 +4033,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
4015
4033
  if (!propName.startsWith("--")) return;
4016
4034
  const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
4017
4035
  const prev = node.prev();
4018
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
4036
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
4019
4037
  const existing = styleDocs.find((styleDoc) => styleDoc.name === propName);
4020
4038
  if (existing) {
4021
4039
  existing.docs ||= docs;
@@ -4068,12 +4086,6 @@ const CSS_DOC_START = /\/\*(\*|!)/;
4068
4086
  * Closing syntax for a CSS docstring
4069
4087
  */
4070
4088
  const CSS_DOC_END = "*/";
4071
- /**
4072
- * The `@prop` annotation we support within CSS docstrings. `@cssprop`/`@cssproperty` are also
4073
- * recognized as synonyms (the more common names in other web-component-analyzer/docgen
4074
- * ecosystems).
4075
- */
4076
- const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
4077
4089
  //#endregion
4078
4090
  //#region src/compiler/sys/browser-stubs/browserslist.ts
4079
4091
  const browserslist = (_query) => [];
@@ -1,3 +1,3 @@
1
- import { A as version, C as hasStencilHydrateImport, D as parseCssOnlyComponents, E as replaceStencilHydrateImport, M as scopeCss, O as buildId, S as hasStencilGlobalsImport, T as replaceStencilGlobalsImport, _ as cmpMetaToDocsComponent, a as createPrerenderer, b as buildHydrateCss, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as generateManifest, h as generateComponentTypesFile, i as createSystem, j as versions, k as vermoji, l as createWorkerMessageHandler, m as validateHydrated, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as getScopeId, w as replaceStencilCssComponentsImport, x as hasStencilCssComponentsImport, y as foldBuildFlags } from "../compiler-CxfLkFCX.mjs";
1
+ import { A as version, C as hasStencilHydrateImport, D as parseCssOnlyComponents, E as replaceStencilHydrateImport, M as scopeCss, O as buildId, S as hasStencilGlobalsImport, T as replaceStencilGlobalsImport, _ as cmpMetaToDocsComponent, a as createPrerenderer, b as buildHydrateCss, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as generateManifest, h as generateComponentTypesFile, i as createSystem, j as versions, k as vermoji, l as createWorkerMessageHandler, m as validateHydrated, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as getScopeId, w as replaceStencilCssComponentsImport, x as hasStencilCssComponentsImport, y as foldBuildFlags } from "../compiler-CH-Qh_aM.mjs";
2
2
  import { a as LOG_LEVELS, i as CustomElementsExportBehaviorOptions } from "../node-Bsfi3pOs.mjs";
3
3
  export { CustomElementsExportBehaviorOptions, LOG_LEVELS, buildHydrateCss, buildId, cmpMetaToDocsComponent, createCompiler, createPrerenderer, createSystem, createWorkerContext, createWorkerMessageHandler, foldBuildFlags, generateComponentTypesFile, generateManifest, getScopeId, hasStencilCssComponentsImport, hasStencilGlobalsImport, hasStencilHydrateImport, loadConfig, nodeRequire, optimizeCss, optimizeJs, parseCssOnlyComponents, replaceStencilCssComponentsImport, replaceStencilGlobalsImport, replaceStencilHydrateImport, scopeCss, transpile, transpileSync, ts, validateConfig, validateHydrated, vermoji, version, versions };
@@ -461,9 +461,9 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
461
461
  };
462
462
  //#endregion
463
463
  //#region src/version.ts
464
- const version = "5.0.0-rc.5";
465
- const buildId = "1795169814";
466
- const vermoji = "🗻";
464
+ const version = "5.0.0-rc.7";
465
+ const buildId = "1795178487";
466
+ const vermoji = "⛳️";
467
467
  /**
468
468
  * Get the installed version of a tool/dependency.
469
469
  * Handles packages with exports maps that point to subdirectories.
@@ -1527,6 +1527,24 @@ const propertyToStyleDoc = (prop) => ({
1527
1527
  */
1528
1528
  const isJsDocComment = (commentText) => commentText.startsWith("*") || commentText.startsWith("!");
1529
1529
  /**
1530
+ * An explicit `@prop` annotation tag in a CSS docstring. `@cssprop`/`@cssproperty` are also
1531
+ * recognized as synonyms (the more common names in other web-component-analyzer/docgen
1532
+ * ecosystems).
1533
+ */
1534
+ const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
1535
+ /**
1536
+ * An annotation tag that documents something by name (`@prop --x`, `@slot name`, ...) rather
1537
+ * than describing the node below its comment.
1538
+ */
1539
+ const CSS_ANNOTATION_TAG_RE = /@(?:component|cssproperty|cssprop|prop|attr|slot)\b/;
1540
+ /**
1541
+ * Whether a comment describes the node immediately following it (a declaration, rule or
1542
+ * at-rule). A comment holding annotation tags documents the things it names instead.
1543
+ * @param commentText a postcss `Comment` node's `.text`
1544
+ * @returns `true` if the comment is a JSDoc-style description of the next node
1545
+ */
1546
+ const isNodeDocComment = (commentText) => isJsDocComment(commentText) && !CSS_ANNOTATION_TAG_RE.test(commentText);
1547
+ /**
1530
1548
  * Strip the leading `*`/`!` marker and per-line `*` prefixes, returning trimmed lines.
1531
1549
  * @param commentText a postcss `Comment` node's `.text`
1532
1550
  * @returns the comment's lines, delimiters and leading `*`s stripped
@@ -1706,7 +1724,7 @@ const parseCssComponentFile = async (filePath, cssText) => {
1706
1724
  if (!propName.startsWith("--")) continue;
1707
1725
  const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
1708
1726
  const prev = nodes[i - 1];
1709
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1727
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1710
1728
  for (const def of defs.values()) {
1711
1729
  const existing = def.properties.find((p) => p.name === propName);
1712
1730
  if (existing) {
@@ -1751,7 +1769,7 @@ const collectAutoDetectedSlots = (container, def) => {
1751
1769
  for (const name of names) {
1752
1770
  if (def.slots.some((s) => s.name === name)) continue;
1753
1771
  const prev = nested.prev();
1754
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1772
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1755
1773
  def.slots.push({
1756
1774
  name,
1757
1775
  docs,
@@ -1857,7 +1875,7 @@ const collectAutoDetectedAttributes = (selector, def) => {
1857
1875
  const collectAttributeRuleDocs = (container, defFor, out) => {
1858
1876
  for (const node of container.nodes) {
1859
1877
  const prev = node.prev();
1860
- if (node.type !== "rule" || prev?.type !== "comment" || !isJsDocComment(prev.text)) continue;
1878
+ if (node.type !== "rule" || prev?.type !== "comment" || !isNodeDocComment(prev.text)) continue;
1861
1879
  let selectors;
1862
1880
  try {
1863
1881
  selectors = parseSelectorList(node.selector);
@@ -1887,7 +1905,7 @@ const collectAutoDetectedCustomProperties = (container, def) => {
1887
1905
  if (child.type !== "decl" || !child.prop.startsWith("--")) continue;
1888
1906
  if (def.properties.some((p) => p.name === child.prop)) continue;
1889
1907
  const prev = children[i - 1];
1890
- if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
1908
+ if (!prev || prev.type !== "comment" || !isNodeDocComment(prev.text)) continue;
1891
1909
  def.properties.push({
1892
1910
  name: child.prop,
1893
1911
  docs: normalizeJsDocText(prev.text),
@@ -2065,28 +2083,40 @@ const scanFiles = async (config, compilerCtx, buildCtx, cache, filePaths) => {
2065
2083
  }));
2066
2084
  };
2067
2085
  /**
2068
- * Load a CSS-only component source file's text. A plain `.css` file is read as-is; any other
2069
- * `STYLE_EXT` extension is run through the configured `plugins` first (e.g. `@stencil/sass`
2070
- * compiling `.scss` to CSS) - the same pipeline `collectCssOnlyComponentStyles` uses to emit
2071
- * this file's CSS, so discovery parses exactly what gets shipped.
2086
+ * Load a CSS-only component source file's text. Only files whose raw source contains
2087
+ * `@component` are considered - a definition belongs to the file that literally contains it,
2088
+ * so preprocessor partials and importers are never compiled standalone here. A plain `.css`
2089
+ * file is returned as-is; any other `STYLE_EXT` extension is run through the configured
2090
+ * `plugins` first (e.g. `@stencil/sass` compiling `.scss` to CSS) - the same pipeline
2091
+ * `collectCssOnlyComponentStyles` uses to emit this file's CSS, so discovery parses exactly
2092
+ * what gets shipped.
2072
2093
  *
2073
2094
  * @param config the validated Stencil config
2074
2095
  * @param compilerCtx the compiler context, used to read the file and register watch files
2075
2096
  * @param buildCtx the current build context, used for plugin transform diagnostics
2076
2097
  * @param filePath absolute path to the source file to load
2077
- * @returns the (possibly preprocessed) CSS text, or `null` if the file couldn't be loaded
2098
+ * @returns the (possibly preprocessed) CSS text, or `null` if the file couldn't be loaded or
2099
+ * has no `@component` marker
2078
2100
  */
2079
2101
  const loadCssOnlyComponentSource = async (config, compilerCtx, buildCtx, filePath) => {
2080
- if (filePath.toLowerCase().endsWith(".css")) try {
2081
- return await compilerCtx.fs.readFile(filePath);
2102
+ let rawText;
2103
+ try {
2104
+ rawText = await compilerCtx.fs.readFile(filePath);
2082
2105
  } catch {
2083
2106
  return null;
2084
2107
  }
2108
+ if (!rawText.includes("@component")) return null;
2109
+ if (filePath.toLowerCase().endsWith(".css")) return rawText;
2085
2110
  const transformResults = await runPluginTransforms(config, compilerCtx, buildCtx, filePath);
2086
2111
  if (!transformResults) return null;
2087
- if (typeof transformResults === "string") return transformResults;
2088
- for (const dep of transformResults.dependencies ?? []) compilerCtx.addWatchFile(dep);
2089
- return transformResults.code ?? null;
2112
+ const code = typeof transformResults === "string" ? transformResults : transformResults.code;
2113
+ if (typeof transformResults !== "string") for (const dep of transformResults.dependencies ?? []) compilerCtx.addWatchFile(dep);
2114
+ if (code != null && !code.includes("@component")) {
2115
+ const warn = buildWarn(buildCtx.diagnostics);
2116
+ warn.messageText = `"${relative$1(config.rootDir, filePath)}" contains "@component" but its preprocessed output does not, so no CSS-only components were discovered in it. Is the preprocessor stripping comments (e.g. sass \`outputStyle: 'compressed'\`)?`;
2117
+ warn.absFilePath = filePath;
2118
+ }
2119
+ return code ?? null;
2090
2120
  };
2091
2121
  const flattenCache = (cache) => Array.from(cache.values()).flat();
2092
2122
  /**
@@ -25398,7 +25428,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
25398
25428
  const child = children[i];
25399
25429
  if (child.type !== "decl" || !child.prop.startsWith("--") || hasName(child.prop)) continue;
25400
25430
  const prev = children[i - 1];
25401
- if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
25431
+ if (!prev || prev.type !== "comment" || !isNodeDocComment(prev.text)) continue;
25402
25432
  styleDocs.push({
25403
25433
  name: child.prop,
25404
25434
  docs: normalizeJsDocText(prev.text),
@@ -25412,7 +25442,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
25412
25442
  if (!propName.startsWith("--")) return;
25413
25443
  const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
25414
25444
  const prev = node.prev();
25415
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
25445
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
25416
25446
  const existing = styleDocs.find((styleDoc) => styleDoc.name === propName);
25417
25447
  if (existing) {
25418
25448
  existing.docs ||= docs;
@@ -25465,12 +25495,6 @@ const CSS_DOC_START = /\/\*(\*|!)/;
25465
25495
  * Closing syntax for a CSS docstring
25466
25496
  */
25467
25497
  const CSS_DOC_END = "*/";
25468
- /**
25469
- * The `@prop` annotation we support within CSS docstrings. `@cssprop`/`@cssproperty` are also
25470
- * recognized as synonyms (the more common names in other web-component-analyzer/docgen
25471
- * ecosystems).
25472
- */
25473
- const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
25474
25498
  //#endregion
25475
25499
  //#region src/compiler/style/css-to-esm.ts
25476
25500
  /**
@@ -1,4 +1,4 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-CxfLkFCX.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-CH-Qh_aM.mjs";
2
2
  import { t as createNodeSys } from "../../node-Bsfi3pOs.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
@@ -33,7 +33,7 @@ import "@rollup/pluginutils";
33
33
  import { createHash } from "crypto";
34
34
  import { afterAll, vi } from "vitest";
35
35
  //#region src/version.ts
36
- const version = "5.0.0-rc.5";
36
+ const version = "5.0.0-rc.7";
37
37
  const MEMBER_FLAGS = {
38
38
  String: 1,
39
39
  Number: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-rc.5",
3
+ "version": "5.0.0-rc.7",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -126,9 +126,9 @@
126
126
  "terser": "^5.50.0",
127
127
  "tinyglobby": "^0.2.17",
128
128
  "typescript": ">5.0.0 <7.0.0",
129
- "@stencil/cli": "5.0.0-rc.5",
130
- "@stencil/dev-server": "5.0.0-rc.5",
131
- "@stencil/mock-doc": "5.0.0-rc.5"
129
+ "@stencil/cli": "5.0.0-rc.7",
130
+ "@stencil/mock-doc": "5.0.0-rc.7",
131
+ "@stencil/dev-server": "5.0.0-rc.7"
132
132
  },
133
133
  "devDependencies": {
134
134
  "@ionic/prettier-config": "^4.0.0",