StencilJS production build omits lazy-loaded chunks referenced in chunk manifest
0 reputation · 03 May 2021, 08:39 UTC
Goal
Achieve a reliable production deployment where all lazy-loaded components defined in the StencilJS chunk manifest are emitted and load correctly at runtime.
Constraints and uncertainty
The compiler's static analysis cannot resolve dynamic import expressions that use variables (for example import("./components/" + name)), so those chunks are not emitted in a production build even though the development server compiles them on demand. The generated stencil-chunk-manifest.json still references the missing chunks, causing 404 errors when the hydration script requests them. Output target configuration adds another variable: the www target uses content-hashed filenames while dist-custom-elements uses deterministic names, so mixing targets without aligned basePath and buildDir settings produces manifest mismatches. Stencil v4's migration to Vite also changed the chunk generation pipeline, and legacy Rollup plugins may emit manifests that the new runtime cannot consume.
Questions
- What is the recommended pattern to enumerate every lazy-loaded component so the static analyzer emits all required chunks?
- How should
basePathandbuildDirbe coordinated across multipleoutputTargetsto guarantee a single, consistent manifest at deploy time? - Are there version-pinning or migration steps that prevent legacy Rollup plugins from producing manifests incompatible with the Vite-based runtime?