Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
@stencil/[email protected]
Current Behavior
During stencil build --dev --watch --docs, a TypeScript-only edit can remove the component's CSS Custom Properties section from readme.md and empty its JSON styles array. The stylesheet remains unchanged, and the rebuild succeeds.
Reverting the TypeScript edit does not restore the documentation; editing the stylesheet does.
Editing a shared utility removed CSS sections from 28 READMEs in our library, causing unrelated Git changes and branch-switching conflicts.
Reproduced with one Stencil watcher, successful builds, and no Storybook.
Expected Behavior
TypeScript-only edits should preserve CSS documentation in README and JSON output, matching a fresh build.
System Info
System: node 24.18.0
Platform: darwin (25.5.0)
CPU Model: Apple M4 Pro (14 cpus)
Compiler: /Users/nirazul/Repositories/fro/desi-code/stzh-components/node_modules/@stencil/core/compiler/stencil.js
Build: 1789171487
Stencil: 4.45.0 🎱
TypeScript: 5.8.3
Rollup: 4.44.0
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0Steps to Reproduce
Ideally, check out the reproduction link. Else, follow these steps:
Use the following configuration and component. The fixture used plain CSS with the Sass plugin enabled.
stencil.config.ts:
import { Config } from '@stencil/core';
import { sass } from '@stencil/sass';
export const config: Config = {
namespace: 'cssdocsprobe',
buildDist: true,
plugins: [sass()],
outputTargets: [
{ type: 'dist' },
{ type: 'dist-custom-elements' },
{ type: 'docs-readme', footer: '' },
{ type: 'docs-json', file: 'stencil-docs.json' },
],
};src/utils.ts:
export const label = 'hello';src/components/stzh-alpha/stzh-alpha.tsx:
import { Component, h } from '@stencil/core';
import { label } from '../../utils';
@Component({ tag: 'stzh-alpha', styleUrl: 'stzh-alpha.css' })
export class Alpha {
render() {
return <div>{label}</div>;
}
}src/components/stzh-alpha/stzh-alpha.css:
/**
* @prop --probe-color: Probe color
* @prop --probe-size: Probe size
*/
:host {
color: var(--probe-color);
font-size: var(--probe-size);
}- Run
npx stencil build --dev --watch --docs --max-workers=0. - After the initial build, verify both properties appear in the README and JSON
stylesarray. - Append
// probe editto the.tsxfile, leaving CSS unchanged. After rebuilding, the README CSS section is gone andstylesis[]. - Revert the comment. After rebuilding, documentation remains missing.
- Append a comment to the CSS file. After rebuilding, documentation returns.
Editing src/utils.ts can also affect importing components. The tested fixture had two such components with separate stylesheets.
Observed results
| State | CSS documentation |
|---|---|
| Initial build | Both properties present |
| Component TSX comment added | No properties; README CSS section removed |
| TSX comment reverted | Still no properties |
| Stylesheet transformed again | Properties restored |
Code Reproduction URL
Additional Information
Investigation
Compiler tracing showed that TypeScript edits can recreate component metadata with empty styleDocs. Rollup then reuses the cached stylesheet transform without replaying its documentation side effect.
extTransformsPlugin populates documentation during transformation:
cmp.styleDocs ||= [];
mergeIntoWith(
cmp.styleDocs,
cssTransformResults.styleDocs,
(docs) => `${docs.name},${docs.mode}`,
);Its transform result contains no documentation metadata, and it has no shouldTransformCachedModule hook to restore cached contributions.
Both forcing stylesheet transforms and an experimental metadata-replay patch prevented the loss. The latter preserved transform caching.
Related upstream reports
- #3034 / #3374: similar loss, fixed by preventing unintended double full builds.
- #5883 / #6579: preservation for docs-only generation.
- #5653: merging documentation from multiple stylesheets.
These fixes are already present in 4.45.0 and do not address this watch-cache behavior.
Activity