Repository navigation
Description
(please note - this is a live document. I'm adding more things as I work on them)
Over the past couple of months I've been working hard getting Stencil core into a better place; squashing lots of long-standing, annoying bugs (this is continuing) plus adding long .... long requested features that Stencil should have had earlier (extends, Mixin, @Prop get / set, runtime custom @Decorators to name a few).
As I look to v5 I'm looking at consolidation, organisation and deprecation - this will include breaking changes.
Stencil has always been pretty stable when it comes to it's API.
Whilst this is nice from a upgrade POV it has come at the cost of technical debt - Stencil recently had it's 10th birthday 🎂 - 10 years worth of technical debt!
In this issue I want to publicly make known what is currently just in my head (or actively being worked on) and let's discuss it here.
BREAKING CHANGE - Integrated testing removal
Back in the days of 2016, setting up testing for front-end things was hard. The original authors wanted a first class, seamless testing experience which involved a hard-coupling with a custom Jest runner and environment, in combination with a custom Puppeteer setup.
This coupling has hamstrung Stencil core and it's users in many ways.
- Stencil core needs to offer a different, custom Jest setup for every major version of Jest. When this became too burdensome to maintain, users became locked to Jest v291
- Stencil's
--spectests do a 'compile lite' on-the-fly for a given component class, then bootstrap it in Stencil's integrated node-dom -MockDoc. This whole process is increasingly problematic:- it reaches into Stencil's internals to work which is prone to error and is fundamentally not representative of the final output.
- is very difficult to make work with classes that can now use
extends(optionally in combination with Mixin) - doesn't give devs the option to use their 'node dom' of choice (e.g. happy-dom, JSDOM)
- Stencil's
--e2etests are hard baked to use Puppeteer which doesn't have the same DevX around browser testing as newer options like Cypress and Playwright.
Migration pathway
- For
--specstyle tests, migrate to using https://github.com/stenciljs/vitest. It has a similar API to the current Jest integration but gives devs far greater control. Test against different bundles / outputs, test in a real browser (a11y tests, visual regressions etc), or pick your node-dom of choice. - For
--e2estyle tests I would probably say that many library authors actually want 'component' tests - isolated testing of their components that just happen to run in a browser - again - use https://github.com/stenciljs/vitest. For those cases where actual e2e tests are required (routing, full applications, proper onload initialisation, SSR) use https://github.com/stenciljs/playwright
BREAKING CHANGE - @Component API
The @Component API is convoluted and not very amenable to updates or changes.
Current
interface ComponentConfig {
tag: string;
/* not relevant unless you use `shadow` */
formAssociated?: boolean;
/* don't use shadowDOM < use scoped classes instead */
scoped?: boolean;
/* use shadowDOM if true ... use nothing if false. Or you can omit to use nothing // then you can also have scoped */
shadow?: boolean | {
delegatesFocus?: boolean, slotAssignment?: 'manual' | 'named'
}
// .. some other things around styling / assets that make sense //
}Proposed
interface ComponentConfig {
tag: string;
encapsulation?:
| { type: 'shadow'; mode?: 'open' | 'closed'; delegatesFocus?: boolean; slotAssignment?: 'manual' | 'named' }
| { type: 'none'; patches?: ('all' | 'children' | 'clone' | 'insert')[] }
| { type: 'scoped'; patches?: ('all' | 'children' | 'clone' | 'insert')[] };
// ^ nb - these patches can be applied globally via `config.extras` as they now
// other unrelated config
}Whilst this is slightly more verbose I think it's much clearer around intent plus much easier to add more options in future. Feedback welcome.
formAssociation will move into the @AttachInternals decorator options
Migration pathway
A new stencil migrate CLI option will be added to update from old > new
BREAKING CHANGE - CommonJS
Stencil itself will migrate it's compiled source from CJS to ESM.
User's dist and dist-hydrate-script output targets now are opt-in via a cjs: true config option within stencil.config.
Migration pathway
Add cjs: true to both dist and dist-hydrate-script outputs to continue getting commonjs output. Additionally, read the specific breaking changes below regarding dist-hydrate-script.
BREAKING CHANGE - ES5 / Polyfills removal
Removal of all options around old polyfills / shims and ES5, 'system' modules.
Migration pathway
Users should 1) remove any imports and calls to applyPolyfills() from their dist output and 2) remove the es5 config option their stencil.config
BREAKING CHANGE - internal structure
Many internal paths will be moved / renamed / become their own packages
@stencil/core/internal→@stencil/core/runtime@stencil/core/internal/client→@stencil/core/runtime/client@stencil/core/internal/hydrate→@stencil/core/runtime/server@stencil/core/cli→@stencil/cli@stencil/core/dev-server→@stencil/dev-server@stencil/core/mock-doc→@stencil/mock-doc
BREAKING CHANGE - openBrowser
The dev-server will no longer open the browser by default.
Migration pathway
- No need to pass in
--no-openanymore. - Pass in
--open(in the cli) oropenBrowserto thedevServerconfig options, for previous auto-open behaviour
BREAKING CHANGE - @Watch initialisation
The documentation around Stencil's lifecycle (https://stenciljs.com/docs/component-lifecycle#component-lifecycle-methods) is quite clear; watchers should, by default, not fire until the component has been fully rendered. At present - especially within the dist output, watch methods can be called during every lifecycle stage.
In v5 @Watch methods adhere to the documentation. Whilst this is strictly a fix, the current behaviour is so long-standing users may have started to rely on it.
Migration pathway
If you need to call watch methods before the component is completely ready, manually call them within lifecycle methods.
Alternatively, use the immediate flag - @Watch({ immediate: true }).
BREAKING CHANGE - Rollup replaced with Rolldown
In v5 Rollup was removed and replaced with Rolldown; all references to rollup* in stencil.config have been replaced accordingly.
Migration pathway
Replace any rollup* references with rolldown* in stencil.config (running stencil migrate will automatically do this).
If referencing any rollup types or internals, make sure to find out what the equivalents are in rolldown.
A number of supported rollup options have no new equivalents (so should be removed) whilst others have new names; running stencil migrate will automatically do handle this for you.
BREAKING CHANGES - dist-hydrate-script output
- Output name has changed from
dist-hydrate-scripttossr(read about all core output targets renamed below). - The output no-longer writes a
package.jsonfile - The default
hydrate.jsis now esm whilst commonJS is opt-in (viacjs: true) and outputs ashydrate.cjs - The exported
hydrateDocumenthas been renamed tossrDocument(hydrateDocumentis still exported asdeprecatedfor now) - All config options with
*hydrate(beforeHydrate/afterHydrate) have been renamed to*ssr(*hydrateare still exported asdeprecatedoptions for now) - To make the output environment agnostic (not just Node.js) the
streamToString()return type has been changed from Node.jsReadableto web-standardReadableStream<string>which works in Node 22+, Cloudflare Workers, Deno, Bun, and all WinterCG runtimes.
Migration pathway
Users must make sure to adjust their package.json exports accordingly - pointing to updated file names.
BREAKING CHANGES - remove buildDist and buildDocs global config options.
The buildDist and buildDocs global configuration options are
- not particularly clear in intent
- pretty nuclear (e.g. users are forced via
buildDocsto build ALL docs outputs during dev) - In the case of
buildDistis slightly inconsistent (other flags can overrule whether outputs are built or not)
A new, per output target has been added skipInDev: boolean allowing devs granular control over what is built during --dev / devMode. By default everything else is skipInDev: true except for the dist browser bundle (and related www output)
Migration pathway
buildDist and buildDocs are detected during cli tasks and users are invited to automatically migrate (using stencil migrate)
BREAKING CHANGES - core output targets renamed
dist and dist-custom-elements are not at all obvious what they are or what they do. The naming comes from original decisions made about the project; dist always designed to be the 'main' target, dist-custom-elements being a later addition when users requested standalone / cherry-pickable components.
These original decisions resulted in dist-custom-elements always seeming like an afterthought; some work being copied (like type generation) whilst other work (like globalStyles) being completely omitted. With this in-mind, the 2 targets have become equal in weighting with other implicit outputs now being explicitly configurable (if required, but not necessary).
TLDR:
dist>loader-bundle. Default output dir wasdistnowdist/loader-bundledist-custom-elements>standalone. Default output dir wascustom-elementsnow isdist/standalonedist-hydrate-script>ssr. Default output dir washydratenow isdist/ssr- new (optional)
typesoutput. Customisable withskipInDevanddiroptions - defaults todist/types. Is auto-generated in production builds. - new (optional)
collectionis now an explicit output. Customisable withskipInDevanddiroptions - defaults todist/collection. Is auto-generated in production builds. dist.typesDirremoved. Usetypes.dirdist.collectionsDirremoved. Usecollection.dirdist-custom-elements.isPrimaryPackageOutputTargetremoved. Choose your own default export inpackage.json(cli hints will guide you to choose one depending on your outputs).dist-custom-elements.generateTypeDeclarationsremoved. Auto generated and written totypes.dirdist.esmLoaderPathrenamed toloaderPath. Path is now calculated fromdist/loader-bundleinstead ofdist(so useloaderPath: '../'to recreate old behaviour)
Migration pathway
Deprecated outputs are detected during cli tasks and users are invited to automatically migrate (using stencil migrate).
Be mindful of the new default output directories - you may need to update package.json exports or explicitly set the dir in each output if you want to retain old / legacy paths.
For the dist cdn path, if you want to retain the same path as before (because the default path is now dist/loader-bundle (was dist)) set buildDir: '../'
BREAKING CHANGES - prod / dev
- The
--prodcli flag has been removed (was redundant as prod builds are the default without explicit--devflag) - The
devModeconfig option has been removed. Antithetical to usual safety norms - it should be explicit and obvious to devs when they're opting into a dev build - not hidden in a config option.
Migration pathway
Devs should remove --prod from their cli commands. Won't error - just not required.
stencil migrate will automatically remove devMode from stencil.config. Devs should use the --dev cli flag.
BREAKING CHANGE - module extensions
With cjs being a fringe requirement and (therefore becoming opt-in in Stencil), type: module is now strongly recommended and old file extension formats (*.cjs.js / *.esm.js) will be standardised to *.cjs (should you opt-in to cjs) and *.js)
Migration pathway
Devs will need to update properties in their package.json. Extra warnings are raised when key package.json fields point to non-existing paths.
note - because the browser loader-bundle output is public facing, references to it may not be controlled by library maintainers. Therefore the current main entrypoint - path/to/loader/NAMESPACE.esm.js - will not be removed and kept as a forwarding module.
BREAKING CHANGE - extras.addGlobalStyleToComponents removed
In v5 globalStyle has been elevated to it's own configurable output target (and you can have multiple now!). Although the current globalStyle config property is still available for ease of use, the extras.addGlobalStyleToComponents has been removed.
Migration pathway
A new inject property is available on any global-style output target:
{
type: 'global-style',
inject: 'client' // 'all' | 'none' < default
...
} Explicit extras.addGlobalStyleToComponents is detected during cli tasks and users are invited to automatically migrate (using stencil migrate) which will create an explicit global-style output target with corresponding inject setting.
BREAKING CHANGE - JSX types
Previously, JSX.Element was undefined in the h namespace, causing ts to silently fall back to any for JSX expressions (which surfaced as no-unsafe-return errors in strict @typescript-eslint setups, for example).
3 type-level changes:
h.JSX.Element > VNode (was FunctionalComponent<...>)
Host / Fragment > (props) => VNode(wasFunctionalComponent<...>) FunctionalComponent>VNode | null(wasVNode | VNode[] | null`)
Migration pathway
No runtime changes.
If you have a FunctionalComponent<T> that returns an array (via utils.map or similar), wrap the result in a fragment instead:
// Before
const MyList: FunctionalComponent<Props> = (props, children, utils) => utils.map(children, transform);// After
const MyList: FunctionalComponent<Props> = (props, children, utils) => <>{utils.map(children, transform)}</>;BREAKING CHANGE - extras.*
The extras section of stencil.config has been renamed compat
experimentalSlotFixes (and slotChildNodesFix, scopedSlotTextContentFix, appendChildSlotFix)
experimentalSlotFixes: true used to set slotChildNodesFix, scopedSlotTextContentFix and appendChildSlotFix to true too ... but you could also set those individually?
This has now become:
lightDomPatches: boolean | {
slotChildNodes: boolean,
slotCloneNode: boolean,
slotDomMutations: boolean,
slotTextContent: boolean,
}Additionally:
lightDomPatchesistrueby default (but will only be bundled if you use lightDOM components with slots)insertAdjacentTextandinsertAdjacentElementpatched methods have been removed to save on runtime bytes.
enableImportInjection default
This option was previously opt-in. It's now opt-out.
Deprecated tagNameTransform, experimentalImportInjection, experimentalScopedSlotChanges
These deprecated options have now been removed.
Any unique functionality previously covered via experimentalScopedSlotChanges is now within lightDomPatches options.
Migration pathway
extras > compat and explicit *fix options can be auto-migrated by stencil migrate
BREAKING CHANGE - hashFile* settings moved from global to output targets options
hashFileNames and hashFileNameLength were top level configuration options, but they only really make sense for outputs that are:
- to be loaded directly in the browser / in a CDN and
- naturally have a single entry point
Therefore these options have been moved into the loader-bundle and www outputs.
Migration pathway
Any explicit hashFile* options can be auto migrated into appropriate output targets via stencil migrate
BREAKING CHANGE - collection importing / rebundling
In v4, importing any module / utility / type from a 3rd party node_module stencil lib would re-bundle the whole library.
Although this behaviour wasn't documented (documentation mentioned only importing as a sideEffect import "@ionic/core") users may have come to rely upon it.
Migration pathway
Users now have 2 options to re-bundle a 3rd party Stencil lib:
- The documented import from a stencil lib as a sideEffect -
import "@ionic/core" - A new top-level stencil.config option
collections: []has been added
BREAKING CHANGE - dist-custom-elements: externalRuntime (now standalone)
externalRuntime now defaults to false (was true). Component bundles are now self-contained - the runtime is included as a local shared chunk rather than left as an external @stencil/core/runtime/client import.
Setting externalRuntime: true is only recommended if you intend on having multiple Stencil component libraries (or components from different libraries) on the same page to limit the bytes sent to the end-user via multiple runtimes.
Migration pathway
Opt back in by setting externalRuntime: true. Run stencil migrate to remove any now-redundant externalRuntime: false from your config.
BREAKING CHANGE - www: serviceWorker
serviceWorker now defaults to null (was 'create Workbox-powered service worker' by default).
Migration pathway
Opt back in by setting serviceWorker: true for the auto-service worker creation.
Run stencil migrate to remove any now-redundant serviceWorker: null from your config.
BREAKING CHANGE - componentShouldUpdate Batching
componentShouldUpdate now fires once per render cycle instead of once per changed @Prop/@State. The callback signature changed from (newVal, oldVal, propName) to a single changes argument (a map of every prop/state name that changed since the last render to its { newVal, oldVal }).
@Prop() prop1;
componentShouldUpdate(changes) {
if (changes['prop1'].newVal === changes['prop1'].oldVal) {
return false;
}
}Alternatively, you can get stricter typing via ComponentShouldUpdateChanges
@Prop() prop1;
componentShouldUpdate(changes: ComponentShouldUpdateChanges<this>) {
if (changes['unknown'].newVal === changes['unknown'].oldVal) { // << will throw
return false;
}
}Migration pathway
Users should update any componentShouldUpdate methods to accept the single changes argument (optionally typed as ComponentShouldUpdateChanges<this> for per-prop typing) and 2) rewrite any per-prop branching logic to key off changes[propName] instead of the old propName parameter.
Additionally, a compiler warning will throw when more than one argument is passed to componentShouldUpdate
BREAKING CHANGE - <my-button thing="false"> now means myBtn.thing === true
< v5 Stencil had special boolean handling where setting an attribute to "false" (string) would set the property to false. This handling goes against standards and therefore expectations and so have been removed in v5. In dev a warning will be thrown when attempting to set a boolean with "false"
Migration pathway
Users can recreate the old behaviour with a custom deserializer:
@Prop() disabled: boolean;
@AttrDeserialize('disabled')
parseDisabled(attr: string | null) {
return attr !== null && attr !== 'false';
}More TBD
This is a live document ... I'm adding more things as I work on them
Activity
[-]v5 Breaking Changes Proposals / Discussion[/-][+]V5 Breaking Changes Proposals / Discussion[/+][-]V5 Breaking Changes Proposals / Discussion[/-][+]v5 Breaking Changes Proposals / Discussion[/+]guilhermegia commentedon Feb 4, 2026
@johnjenkins What you think about Components test using playwright? https://playwright.dev/docs/test-components
Compared to vitest
johnjenkins commentedon Feb 4, 2026
👋 I'm not against it - just requires the extra work to make an integration :) (I've just had a brief look and doesn't seem too hard).
If it's something you're interested in, perhaps it makes sense to add it over at https://github.com/stenciljs/playwright - feel free to raise a feature request.
theo-staizen commentedon Feb 4, 2026
I have one question about encapsulation:
Currently our components do not use shadow or scoped styles, but we do use slots in multiple places (96 slots in 36 components), meaning our typical components look something like this (i.e. the defaults)
The reasons for this decision (granted it was over 5 years ago)
Will the proposed changes still support this use case (slots + no shadow + no scoped css)?
johnjenkins commentedon Feb 4, 2026
Yes!
^ no change required for you. That'll still be the default.
The explicit equivalent would be:
kristilw commentedon Mar 3, 2026
Was just looking at the state of issue 6373 , any chance that might get fixed properly? We had a discussion on it here, and it boiled down to the order of the lifecycle events not being that well defined, and fixing it would probably cause some breaking changes that would be better suited for a major release.
theo-staizen commentedon Mar 4, 2026
(Sorry to cut you off, kristilw)
Given the recent addition of the
autoLoaderprop ofdist-custom-elementsand the fact that some of the framework output-targets only work withdist-custom-elements, I was wondering if there is any intent of deprecating/removingdist, either in this version or a future major.In which case, I was also wondering wondering what would happen to other functionality that is unique to
dist, such as the output of global styles css file (currently underdist/[namespace]/[namespace].css), which is currently missing fromdist-custom-elements?.P.s: Currently, I have to keep both, if i want stencil to compile my styles (
dist) and use react-output-target (dist-custom-elements) ? Is this intentional or just an accidental omission?johnjenkins commentedon Mar 4, 2026
@kristilw - thanks for reminding me. Yes - I'll try and roll in any changes / inconsistencies around that in.
@theo-staizen - unifying / deprecating
distis something I mentioned in the other thread here :).Speaking frankly though, I don't think it can be deprecated for v5; it's dug too deep into Stencil (at present) to remove. It's the basis of
www, and so the basis of 'apps',SSGand the dev-server (and so end-to-end testing too)... also, I wouldn't be comfortable to remove it until a lot more testing has been done around the newautoLoader.The fact that some wrappers only work with
dist-custom-elementswas a decision taken primarily for server-side rendering I believe; the explicit imports make it much easier to reason and bundle certain things.For this reason, the
autoLoaderwould not help; there's no easy way to know - ahead of time - what any given framework module is bundling.Generally speaking, there is no reason that
distdoesn't work for the vast majority of users, use-cases and framework integrations - if I ever get any more time / inclination I'm thinking of re-addingdistas an option.That's an oversite - I'd love it if you could raise an issue so I don't forget it 🙏
mpesic commentedon Mar 5, 2026
@johnjenkins would it be possible to decouple building of global CSS (
globalStyle) from thedist?dogoku commentedon Mar 5, 2026
@johnjenkins here you go #6630
@mpesic also added your suggestion. feel free to add your thoughts
p.s: just realized, i used my personal account (i'm theo-staizen)
mpesic commentedon Mar 11, 2026
How about adding support for scoped registries in
dist-custom-elementsand elsewhere?Currently the
defineCustomElement()method on compiled components references the global registry.https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/CustomElementRegistry
https://developer.chrome.com/blog/scoped-registries?hl=en
johnjenkins commentedon Mar 11, 2026
yep! Can you add a feature request so I don't forget? 🙏
11 remaining items
hyyan commentedon Apr 20, 2026
Thanks to the team for putting so much into v5 and for being transparent with this tracker. Most of what's here we're aligned with. I want to share feedback specifically on the
--specrunner removal, coming from a team that has been building and shipping a Stencil based web component library for over five years, currently at 70+ components in production.Scope clarification:
--e2eremoval is fine from our side. Our own experience with it was unreliable enough that we moved to a Playwright setup a while back. No concerns there.For
--specthough, we'd like to respectfully push back. Our ask is that the integrated spec test runner stays as a maintained option for running Stencil tests, alongside@stencil/vitest, not removed in v5.1. The motivation is maintainer facing, and that's a fair concern, but the cost lands on every downstream user. Reading through the thread, nobody is asking for
--specto go away. The reasons given are all Stencil core maintenance, especially the Jest v29 lock in. We understand the burden, it's real. But the tradeoff being proposed is "we reduce core maintenance by having every Stencil consumer rewrite their spec tests." That's a very asymmetric trade, and we'd love to see alternatives explored first. ExtractingnewSpecPageas a runner agnostic library would decouple Stencil core from any specific Jest version and keep the API users have built on top of.2. The actual migration cost is high for mature libraries, and we have serious doubts it can be meaningfully automated. Our library has close to 200 spec files. Every
newSpecPagecall has to be rewritten by hand torender(<jsx/>). HTML template literals need JSX transcription. Snapshot baselines regenerate under a different serializer, so the snapshot contracts we've built up over years get replaced file by file, and every diff has to be reviewed manually to confirm nothing semantically changed.The v5 proposal mentions a
stencil migrateCLI for other renames (@ComponentAPI,buildDist/buildDocs), and it's reasonable to imagine extending it to tests. But from attempting the migration on our own codebase this week, we have real doubts that the test migration can be automated in a useful way:newSpecPage({ html: '...' })frequently contain interpolations (${variable}), conditional branches, and nested component trees built up in helper functions. Transcribing these to JSX is context dependent, not mechanical.components: [X, Y]arrays are gone. Components auto-register via a setup file instead. A codemod can strip the array, but it can't tell which components the test actually depended on vs. which were imported defensively.donecallback patterns and Jasmine-style.and.callThrough()require real async rewrites, not text substitution.A codemod that handles the very obvious cases (import swap,
page.rootInstance→page.instance) would still help, but the bulk of the per-file work is inherently manual. That changes the math on the migration budget significantly compared to other v5 breaking changes.3.
@stencil/vitestis very new, and the migration surfaces things that aren't solved yet. It is still early in its lifecycle. We attempted the migration this week and hit:writeTaskunderjsdomsurfaces race conditions that MockDoc's synchronous scheduler hid. Some of our previously green tests started failing not because the test logic was wrong, but because component cleanup code raced against pending write tasks.These are solvable, but they're not solved today. Removing the incumbent in favor of a replacement that's still finding its feet means every downstream team hits these rough edges at the same time.
4. "Not representative of the final output" is a narrower problem than removing
--spec. Sync, isolated spec tests aren't supposed to be representative of the final output. That's what browser-mode tests are for, and that path still exists through@stencil/vitestor@stencil/playwright. Determinism and speed are the whole point of--spec.Our ask: don't remove
--specin v5. Keep it as a maintained option alongside@stencil/vitest. If the Jest version coupling is the real pain, one alternative worth exploring is extractingnewSpecPageas a runner agnostic library that works with Jest or Vitest. Stencil core stops owning the Jest environment, users keep their test suites, and the lock-in problem goes away for the core team.The migration paths proposed so far aren't enough to justify the removal. A
stencil migrate --testscodemod would help on the margins, but as described above, the bulk of the per-file work is inherently manual.@stencil/vitestis still early enough that the migration surfaces unsolved rough edges. Neither path closes the gap for teams with large, mature spec suites. They just shift the cost from "impossible" to "extremely expensive."We're genuinely invested in Stencil's success, we've bet a lot on it over the last five years. That's why we're flagging this now, while v5 is still in proposal stage. A breaking change that forces every Stencil consumer to rewrite their test suite is not something that should ship with the current migration story.
Thanks for considering the feedback.
mpesic commentedon Apr 20, 2026
FWIW, we migrated from Jest 29 to Jest 30 using https://github.com/stenciljs/jest-stencil-runner and it went fairly smooth.
hyyan commentedon Apr 21, 2026
Thanks @mpesic, very useful. We tried the migration today on our spec suite (Stencil to jest-stencil-runner on Jest 30). It works, around 80% of tests pass as is.
Along the way we hit a handful of parity gaps between jest-stencil-runner and the integrated Jest 29 runner. Nothing blocking, but enough that consumers shouldn't have to rediscover them. I'll be filing them on stenciljs/jest-stencil-runner and opening PRs where I can, to keep the fixes in one place.
johnjenkins commentedon Apr 21, 2026
hey @hyyan - thanks for your feedback and thank you so much for the contribution to the jest-runner! - Really appreciated.
A few responses:
Maintenance burden: Stencil is maintained by one person part-time. The integrated test runner forces CJS output, blocks dependency updates (Jest 29 lock-in), and couples testing to compiler internals. Every Stencil user pays for this - the whole project moves slower and stays stuck on older patterns.
"nobody asked for this": not quite right - this issue - was raised 5 years ago and has 68 upvotes. It's been thought about / worked on for around 9 months (originally by @christian-bromann) ... not especially publicly - but it's not an off-the-cuff decision. Christian made the standalone jest runner in preparation.
End of the day - no other modern framework ships a baked-in test runner like this. There's never a perfect time for these kinds of changes, but every day we wait, more tests get written, making migration more expensive later.
On migration difficulty: You're right that it's context-dependent and not auto-migratable. But hard migrations don't mean we preserve broken architecture indefinitely.
A few clarifications:
The jest-stencil-runner will still exist post v5. It reaches into internals so it'll break on v5, but I'll help get something working if there's community interest.
@stencil/vitest is getting on-the-fly transpilation via the Stencil Vitest plugin for sync testing similar to Jest. Bugs will be ironed out before v5 ships.
On snapshot serializers: it uses a different (agnostic) technique so has different output. It therefore can work with any node-dom or real-dom. Diffs are expected - that's just reality of the change, not something that can be "fixed".
Not sure if you realised (it’s not documented so why would you 😄) - the vitest lib render method also accepts strings / template literals if that’s what you prefer.
v5 won't ship until the vitest package is in a stable spot. If you hit specific blockers with @stencil/vitest, file them at https://github.com/stenciljs/vitest/issues feedback helps smooth the transition for everyone.
I do understand this is painful for mature test suites. But the alternative - maintaining bespoke testing infrastructure that forces project-wide compromises - isn't sustainable. This is what major versions are for.
johnjenkins commentedon Apr 21, 2026
@scriptcoded
Traditionally - everything was
distwhich just meant 'everything you need to distribute'...Some of these names aren't quite accurate, but you get the idea:
dist-types- .. types :Ddist-collection- transpiled meta or whateverdist-esm- esm modules for bundlersdist-cjs- cjs modulese4 for bundlersdist-esm-browser- esm modules for browsersdist-es5-browser- system modules for old browsersdist-global-styles- global stylesheets... there might be some more I missed. But yes -
dist-collectionis a child of the overarching 'dist'Lib-A, produces dist-* components and dist-collection - with this, the dist-* components never refer to dist-collection - no. The source of truth is your raw typescript files.
Lib-B installing and importing lib-A though - raw typescript files are no longer available so 'dist-collection' is the source of truth.
dist-custom-elements-bundlecame along (then changed todist-custom-elements) .. which could theoretically be your only output - but it's weird:dist-types- but have no control over it.dist-global-styles? No.dist-collectionis used to build out 3rd party components in both a consuming lib's dist and dist-custom-elements .. so the nesting is misleadingI want to elevate
dist-collection(how aboutstencil-artifacts? < it's not just transpiled code - it's json files too?),dist-typesanddist-global-stylesto be shared outputs. This makes more sense conceptually - they should exist independent of how you distribute your components.scriptcoded commentedon Apr 21, 2026
@johnjenkins Now I follow, thank you for taking the time to explain. Hopefully this might help others understand the internals better in the future as well.
I think
stencil-artifactsis a good middle ground. It's a bit vague, but so are the others. So without really having any say in this, I'm happy with these names 😄johnjenkins commentedon Apr 23, 2026
@scriptcoded - I went withstencil-rebundlein the end. Thanks for your input!After sitting with this for a bit, I reverted back to
collection... it's fine and not worth the churn :Djohnjenkins commentedon May 18, 2026
Stencil's injection of pre-first-render (pre hydration) css
<style>tags is a bit flawed right?<my-components>but anything server rendered, not so much.standalone) bundle at all.How would people feel if that moved into a (dynamically generated) style sheet with the ability to inject it into a
globalStylesheet (via virtual@importstatement)?Or do people think it weakens the 'lazy-loader' concept; relying on another asset /
<link>to function?theo-staizen commentedon May 18, 2026
Talking from a perspective of using components in SPAs (react, angular or otherwise), we already depend on a global css file to inject all our css variables, css reset,
.hydratedstyles, etc.If that use-case works as is or it's just adding one line to the global css file, but it will make life easier for people using SSR, then I don't see a problem.
(I hope I understood your question... cause i'm like 50% certain I didn't 😅 )
johnjenkins commentedon May 18, 2026
@theo-staizen - I think you understood! (and well-done - I don't think I was very clear)
v5 will get the global-style injection no-matter what (via #6724) - you add
@import "stencil-hydrate"to a stylesheet, the .hydrated styles get added and the<style>injection logic gets tree-shaken away.My question relates to the fallback behaviour if you don't use
@import "stencil-hydrate".As it stands:
<style>)stencil-hydrate.cssasset (because there's not a natural place to add that<style>injection logic).So my next thought was .. maybe just generate the
stencil-hydrate.cssasset for use with both outputs and drop the current<style>injection, as fundamentally... it's a better pattern for "styles we need before js"Burzmalian commentedon Jun 1, 2026
Not sure if the the section for BREAKING CHANGES - dist-hydrate-script output covers this, so i wrote up a discussion:
#6743
currently the hydrate script is not tree shakable, would be cool to add that.
m13v commentedon Jun 4, 2026
most puppeteer e2e flake is hand-rolled waitForSelector retries; playwright's auto-waiting locators retire that whole class on migration.
axelfriberg commentedon Jul 29, 2026
With TypeScript 7 now being officially released I was wondering if would be in scope for V5 to upgrade to the latest TS version inside the stencil compiler to also help speed up build times. As far as I can tell the Stencil compiler bundles its own TS currently at version 5.8.3. Would it be reasonable to include an upgrade to TS 7 with the Stencil 5 release? Is this something on your radar @johnjenkins ?
johnjenkins commentedon Aug 3, 2026
hey @axelfriberg - yes whilst working on v5 I've looked into this... couple of things to note.
Suffice to say - it's something I want to transition to as soon as possible! 🙂
johnjenkins commentedon Nov 23, 2026
Thanks everyone for being patient around this!
We've moved to release-candidate stage now 🥳:
stencil migrate)We're looking to release asap in the new year, but don't expect much to change now. I'd encourage people to try it out and report anything they find.
Thanks for using Stencil ❤️
p.s. I'm still looking for sponsors for my work on Stencil. If you / your company use Stencil to make money and think it's maintenance is important, please consider becoming a sponsor