Stencil build fails in CI with an invalid component tag diagnostic — how should logs be triaged?
0 reputation · 16 Jan 2025, 11:16 UTC
0 reputation · 16 Jan 2025, 11:16 UTC
A Stencil component library builds locally but the deployment pipeline fails during stencil build, and the only visible signal is a non-zero exit code from the CLI. The goal is to reliably identify, from CI logs alone, whether the failure is a compiler diagnostic — such as the validation error raised when an @Component tag is not lowercase or contains no dash — or something in the hosting layer, like a missing www output folder from the wrong output target.
The constraint is that the pipeline currently greps the log for a specific error message string, and that check stopped matching after a Stencil major version upgrade even though builds still fail for real reasons. Diagnostic wording and codes do not appear to be guaranteed stable across versions, and dev-mode (stencil start) output seems to differ slightly from production build output.
Assume a recent Stencil 4.x toolchain.
What log markers (file paths, line/column info, severity levels) are dependable for distinguishing Stencil compiler diagnostics from bundler or hosting errors? Does --debug / --log produce a structured build log suitable for automation? Is there a version-stable way to assert "build failed due to a component validation error" without hard-coding message text?
30775 reputation · 16 Jan 2025, 15:38 UTC
For Stencil 4.x a compiler diagnostic and a hosting/output error are distinguishable in CI by phase and log shape, not by a stable English sentence. Grepping for a specific message will break on major upgrades because wording changes. Use exit code + structural markers.
[error] src/components/foo/foo.tsx:12:3. The file path, line and column are emitted by the compiler.src/ tree and the @Component decorator.stencil build --debug and --verbose increase internal logging. Output remains human-readable console text, not structured JSON. There is no documented stable machine-readable log format for automation in 4.x.The diagnostic you saw for an invalid component tag — tag must be lowercase, contain a hyphen, and not be a reserved HTML tag — is emitted by the compiler. After a major version upgrade the wording and sometimes the code label change, so a string match stops working even though the failure is real.
stencil build --verbose 2>&1; echo "EXIT=$?"Non-zero exit with an early
[error] block referencing src/ is a compiler diagnostic.[error] or [warn] line contains a project source path and :line:col.@Component, tag, transpile, or rollup for bundling.www folder.dist/www, dist/, or a deploy step, with no source file path.[error] AND a src/ file path with :\d+:\d+tag: in the @Component decorator.This pattern is version-stable because file path + line/col formatting has been consistent in 4.x, while the English sentence is not.
npm ci && stencil build --verbose and diff the first error block with CI.tag value. It must be lowercase, hyphenated, and not a reserved tag.www folder is usually a wrong outputTargets.dist path, not a compiler error.One missing detail that changes the recommendation: the exact Stencil version and your outputTargets config. If you are using a custom output target or a monorepo with hoisted @stencil/core, the phase ordering can shift and the file path pattern needs adjustment.
Use comments to ask for clarification. Post a solution as an answer.
30,775 reputation · 16 Jan 2025, 22:07 UTC
When a Stencil 4.x build aborts in CI, the most reliable signal is the presence of a compiler‑specific code field in the JSON log produced by stencil build --log json. This field contains a machine‑readable identifier such as invalid-component-tag and persists across minor releases, unlike the human‑readable message text which changes on major upgrades. To triage, first run the build with --log json and pipe the output through jq to check .type == "compiler" && .severity == "error" && .code != null. If the check passes, the failure stems from a component validation error; otherwise it is a bundler or hosting issue. Remember to strip ANSI escape sequences and normalize line endings before parsing, otherwise jq may fail.