Skip to content

v5 Breaking Changes Proposals / Discussion #6584

Open

Description

@johnjenkins

(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 --spec tests 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:
    1. it reaches into Stencil's internals to work which is prone to error and is fundamentally not representative of the final output.
    2. is very difficult to make work with classes that can now use extends (optionally in combination with Mixin)
    3. doesn't give devs the option to use their 'node dom' of choice (e.g. happy-dom, JSDOM)
  • Stencil's --e2e tests 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

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-open anymore.
  • Pass in --open (in the cli) or openBrowser to the devServer config 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-script to ssr (read about all core output targets renamed below).
  • The output no-longer writes a package.json file
  • The default hydrate.js is now esm whilst commonJS is opt-in (via cjs: true) and outputs as hydrate.cjs
  • The exported hydrateDocument has been renamed to ssrDocument (hydrateDocument is still exported as deprecated for now)
  • All config options with *hydrate (beforeHydrate / afterHydrate) have been renamed to *ssr (*hydrate are still exported as deprecated options for now)
  • To make the output environment agnostic (not just Node.js) the streamToString() return type has been changed from Node.js Readable to web-standard ReadableStream<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

  1. not particularly clear in intent
  2. pretty nuclear (e.g. users are forced via buildDocs to build ALL docs outputs during dev)
  3. In the case of buildDist is 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 was dist now dist/loader-bundle
  • dist-custom-elements > standalone. Default output dir was custom-elements now is dist/standalone
  • dist-hydrate-script > ssr. Default output dir was hydrate now is dist/ssr
  • new (optional) types output. Customisable with skipInDev and dir options - defaults to dist/types. Is auto-generated in production builds.
  • new (optional) collection is now an explicit output. Customisable with skipInDev and dir options - defaults to dist/collection. Is auto-generated in production builds.
  • dist.typesDir removed. Use types.dir
  • dist.collectionsDir removed. Use collection.dir
  • dist-custom-elements.isPrimaryPackageOutputTarget removed. Choose your own default export in package.json (cli hints will guide you to choose one depending on your outputs).
  • dist-custom-elements.generateTypeDeclarations removed. Auto generated and written to types.dir
  • dist.esmLoaderPath renamed to loaderPath. Path is now calculated from dist/loader-bundle instead of dist (so use loaderPath: '../' 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 --prod cli flag has been removed (was redundant as prod builds are the default without explicit --dev flag)
  • The devMode config 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:

  • lightDomPatches is true by default (but will only be bundled if you use lightDOM components with slots)
  • insertAdjacentText and insertAdjacentElement patched 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:

  1. to be loaded directly in the browser / in a CDN and
  2. 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:

  1. The documented import from a stencil lib as a sideEffect - import "@ionic/core"
  2. 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

Footnotes

    • I know this exists to allow for Jest to be updated however it has all of the same problems... but worse a) because core changes are not synced to the downstream package and b) has no e2e solution
    ↩

Activity

  1. changed the title [-]v5 Breaking Changes Proposals / Discussion[/-] [+]V5 Breaking Changes Proposals / Discussion[/+] on Feb 4, 2026
  2. pinned this issue on Feb 4, 2026
  3. changed the title [-]V5 Breaking Changes Proposals / Discussion[/-] [+]v5 Breaking Changes Proposals / Discussion[/+] on Feb 4, 2026
  4. guilhermegia commented on Feb 4, 2026

    @guilhermegia
  5. johnjenkins commented on Feb 4, 2026

    @johnjenkins
    ContributorAuthor

    @johnjenkins What you think about Components test using playwright? https://playwright.dev/docs/test-components

    👋 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.

  6. theo-staizen commented on Feb 4, 2026

    @theo-staizen

    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)

    @Component({
      tag: 'stz-dialog',
      styleUrl: './stz-dialog.scss'
    })
    export class StzDialog {
      // ...
      render() {
        return (
          <Host class="stz-dialog" role="dialog" aria-hidden={String(!this.isVisible)} data-animate-out={this.animateOut}>
            <div class="stz-dialog-overlay"></div>
            <div class="stz-dialog-content" >
              <div class="stz-dialog-header">
                <slot name="header"></slot>
              </div>
              <div class="stz-dialog-body">
                <slot name="body"></slot>
                <slot />
              </div>
              <div class="stz-dialog-footer">
                <div><slot name="other-actions"></slot></div>
                <div><slot name="key-actions"></slot></div>
              </div>
              {this.closeButton && (
                <stz-button size="small" class="stz-dialog-close-button" data-dialog-action="cancel">
                  <stz-icon icon={faTimes}></stz-icon>
                </stz-button>
              )}
            </div>
          </Host >
        );
      }
    }

    The reasons for this decision (granted it was over 5 years ago)

    • QAs were complaining it was harder to target elements in Shadow DOM
    • We actually like global styles (shocking, I know) and we are happy with "BEM-like" class names
    • We use slots extensively, because it is the easiest way to mix stencil components with other frameworks.

    Will the proposed changes still support this use case (slots + no shadow + no scoped css)?

  7. johnjenkins commented on Feb 4, 2026

    @johnjenkins
    ContributorAuthor

    Will the proposed changes still support this use case (slots + no shadow + no scoped css)?

    Yes!

    @Component({
      tag: 'stz-dialog',
      styleUrl: './stz-dialog.scss'
    })

    ^ no change required for you. That'll still be the default.

    The explicit equivalent would be:

    @Component({
      tag: 'stz-dialog',
      styleUrl: './stz-dialog.scss',
      encapsulation: {
        type: 'none',
      }
    })
  8. kristilw commented on Mar 3, 2026

    @kristilw
    Contributor

    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.

  9. theo-staizen commented on Mar 4, 2026

    @theo-staizen

    (Sorry to cut you off, kristilw)

    Given the recent addition of the autoLoader prop of dist-custom-elements and the fact that some of the framework output-targets only work with dist-custom-elements, I was wondering if there is any intent of deprecating/removing dist, 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 under dist/[namespace]/[namespace].css), which is currently missing from dist-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?

  10. johnjenkins commented on Mar 4, 2026

    @johnjenkins
    ContributorAuthor

    @kristilw - thanks for reminding me. Yes - I'll try and roll in any changes / inconsistencies around that in.

    @theo-staizen - unifying / deprecating dist is 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', SSG and 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 new autoLoader.

    The fact that some wrappers only work with dist-custom-elements was 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 autoLoader would 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 dist doesn'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-adding dist as an option.

    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?

    That's an oversite - I'd love it if you could raise an issue so I don't forget it 🙏

  11. deleted a comment from on Mar 5, 2026
  12. mpesic commented on Mar 5, 2026

    @mpesic
    Contributor

    @johnjenkins would it be possible to decouple building of global CSS (globalStyle) from the dist?

  13. dogoku commented on Mar 5, 2026

    @dogoku

    @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)

  14. mpesic commented on Mar 11, 2026

    @mpesic
    Contributor
  15. johnjenkins commented on Mar 11, 2026

    @johnjenkins
    ContributorAuthor

    How about adding support for scoped registries in dist-custom-elements and elsewhere?

    yep! Can you add a feature request so I don't forget? 🙏

  16. 11 remaining items

  17. hyyan commented on Apr 20, 2026

    @hyyan
    Contributor

    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 --spec tests 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:

      1. it reaches into Stencil's internals to work which is prone to error and is fundamentally not representative of the final output.
      2. is very difficult to make work with classes that can now use extends (optionally in combination with Mixin)
      3. doesn't give devs the option to use their 'node dom' of choice (e.g. happy-dom, JSDOM)

    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 --spec runner 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: --e2e removal 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 --spec though, 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 --spec to 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. Extracting newSpecPage as 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 newSpecPage call has to be rewritten by hand to render(<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 migrate CLI for other renames (@Component API, 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:

    • HTML template literals in 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.
    • JSX and HTML diverge on boolean attributes, self-closing tags, and event handler syntax. A naive codemod will produce subtly wrong JSX.
    • Per-test 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.
    • Some tests surface race conditions under the new async scheduler (MockDoc sync vs. real rAF) that require small production code fixes, not test code fixes. A codemod can't do that.
    • done callback 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/vitest is 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:

    • Snapshot serializer differs from the jest serializer, so every file regenerates with new content on first run. Not wrong, but it requires a manual visual audit per file.
    • Async writeTask under jsdom surfaces 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/vitest or @stencil/playwright. Determinism and speed are the whole point of --spec.

    Our ask: don't remove --spec in v5. Keep it as a maintained option alongside @stencil/vitest. If the Jest version coupling is the real pain, one alternative worth exploring is extracting newSpecPage as 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 --tests codemod would help on the margins, but as described above, the bulk of the per-file work is inherently manual. @stencil/vitest is 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.

  18. mpesic commented on Apr 20, 2026

    @mpesic
    Contributor

    Extracting newSpecPage as a runner agnostic library would decouple Stencil core from any specific Jest version and keep the API users have built on top of.

    FWIW, we migrated from Jest 29 to Jest 30 using https://github.com/stenciljs/jest-stencil-runner and it went fairly smooth.

  19. hyyan commented on Apr 21, 2026

    @hyyan
    Contributor

    Extracting newSpecPage as a runner agnostic library would decouple Stencil core from any specific Jest version and keep the API users have built on top of.

    FWIW, we migrated from Jest 29 to Jest 30 using https://github.com/stenciljs/jest-stencil-runner and it went fairly smooth.

    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.

  20. johnjenkins commented on Apr 21, 2026

    @johnjenkins
    ContributorAuthor

    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.

  21. johnjenkins commented on Apr 21, 2026

    @johnjenkins
    ContributorAuthor

    @scriptcoded

    Further questions just to fully understand:

    I am confused as to why dist-collection is called what it is, but I assume that's to indicate that it's "a child" of the dist output target?

    Traditionally - everything was dist which just meant 'everything you need to distribute'...
    Some of these names aren't quite accurate, but you get the idea:

    • dist-types - .. types :D
    • dist-collection - transpiled meta or whatever
    • dist-esm - esm modules for bundlers
    • dist-cjs - cjs modulese4 for bundlers
    • dist-esm-browser - esm modules for browsers
    • dist-es5-browser - system modules for old browsers
    • dist-global-styles - global stylesheets

    ... there might be some more I missed. But yes - dist-collection is a child of the overarching 'dist'

    Will stencil read the transpiled output to produce the bundled output? In other words, does dist have a direct dependency on the collection output?

    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-bundle came along (then changed to dist-custom-elements) .. which could theoretically be your only output - but it's weird:

    • You still need dist-types - but have no control over it.
    • dist-global-styles? No.
    • dist-collection is used to build out 3rd party components in both a consuming lib's dist and dist-custom-elements .. so the nesting is misleading

    I want to elevate dist-collection (how about stencil-artifacts ? < it's not just transpiled code - it's json files too?), dist-types and dist-global-styles to be shared outputs. This makes more sense conceptually - they should exist independent of how you distribute your components.

  22. scriptcoded commented on Apr 21, 2026

    @scriptcoded

    @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-artifacts is 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 😄

  23. johnjenkins commented on Apr 23, 2026

    @johnjenkins
    ContributorAuthor

    @scriptcoded - I went with stencil-rebundle in 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 :D

  24. johnjenkins commented on May 18, 2026

    @johnjenkins
    ContributorAuthor

    Stencil's injection of pre-first-render (pre hydration) css <style> tags is a bit flawed right?

    1. Works for client-side SPA injected <my-components> but anything server rendered, not so much.
    2. Has no equivalent concept in the 'dist-custom-elements' (soon to be 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 globalStyle sheet (via virtual @import statement)?

    Or do people think it weakens the 'lazy-loader' concept; relying on another asset / <link> to function?

  25. theo-staizen commented on May 18, 2026

    @theo-staizen

    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, .hydrated styles, 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 😅 )

  26. johnjenkins commented on May 18, 2026

    @johnjenkins
    ContributorAuthor

    @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:

    • the lazy-loader falls back to the current behaviour (injected <style>)
    • standalone falls back to a newly generated stencil-hydrate.css asset (because there's not a natural place to add that <style> injection logic).

    So my next thought was .. maybe just generate the stencil-hydrate.css asset for use with both outputs and drop the current <style> injection, as fundamentally... it's a better pattern for "styles we need before js"

  27. Burzmalian commented on Jun 1, 2026

    @Burzmalian
    Contributor

    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.

  28. m13v commented on Jun 4, 2026

    @m13v

    most puppeteer e2e flake is hand-rolled waitForSelector retries; playwright's auto-waiting locators retire that whole class on migration.

  29. axelfriberg commented on Jul 29, 2026

    @axelfriberg

    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 ?

  30. johnjenkins commented on Aug 3, 2026

    @johnjenkins
    ContributorAuthor

    hey @axelfriberg - yes whilst working on v5 I've looked into this... couple of things to note.

    1. Nothing is bundled / baked into Stencil core v5 as it was previously - deps are just treated normally with supported ranges
    2. We cannot support ts 7 (yet) as there's no upgrade path for the programmatic API which Stencil uses. This has been tipped for release in 7.1 🤞

    Suffice to say - it's something I want to transition to as soon as possible! 🙂

  31. johnjenkins commented on Nov 23, 2026

    @johnjenkins
    ContributorAuthor

    Thanks everyone for being patient around this!
    We've moved to release-candidate stage now 🥳:

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions