Skip to content

fix(core): allow duplicate qwik via shared singletons#8609

Open
wmertens wants to merge 1 commit intobuild/v2from
singletons
Open

fix(core): allow duplicate qwik via shared singletons#8609
wmertens wants to merge 1 commit intobuild/v2from
singletons

Conversation

@wmertens
Copy link
Copy Markdown
Member

@wmertens wmertens commented May 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 2, 2026 22:01
@wmertens wmertens requested a review from a team as a code owner May 2, 2026 22:01
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: 5d43200

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@maiieul maiieul moved this from Backlog to Waiting For Review in Qwik Development May 2, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 2, 2026

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8609

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8609

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8609

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8609

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8609

commit: 429bef5

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors selected mutable runtime state into a version-aware global singleton registry so same-version Qwik copies can share state, primarily to support externalized third-party Qwik libraries on the server without tripping duplicate-runtime issues.

Changes:

  • Added a new shared/singletons registry on globalThis.__qwik__ and moved several runtime registries/state holders to use it.
  • Updated server/testing symbol resolution and build-time allowlists so the new singleton/version plumbing can be imported in server/optimizer builds.
  • Added/updated tests and a changeset describing the shared-singleton behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/submodule-server.ts Allows core/version imports in the server submodule build.
scripts/submodule-optimizer.ts Allows core/version imports in the optimizer submodule build.
packages/qwik/src/testing/platform.ts Switches test symbol lookup to the shared singleton registry.
packages/qwik/src/server/qwik-copy.ts Re-exports the singleton accessor for server runtime code.
packages/qwik/src/server/platform.unit.ts Updates server platform tests to use _regSymbol/new global state.
packages/qwik/src/server/platform.ts Switches server symbol lookup/chunk mapping checks to shared singletons.
packages/qwik/src/core/use/use-locale.ts Moves locale and async-local storage handles into singleton-backed state.
packages/qwik/src/core/shared/singletons.ts Introduces the new global singleton registry and duplicate-version check.
packages/qwik/src/core/shared/serdes/inflate.ts Moves deserialization loading state into the singleton registry.
packages/qwik/src/core/shared/serdes/deser-proxy.ts Moves deserializer proxy cache into the singleton registry.
packages/qwik/src/core/shared/serdes/allocate.ts Moves deserialization resolver/store-target maps into the singleton registry.
packages/qwik/src/core/shared/qrl/qrl.ts Registers inline QRL symbols via the singleton-backed registry.
packages/qwik/src/core/shared/qrl/qrl-class.ts Reads the singleton-backed deserialization loading state.
packages/qwik/src/core/index.ts Replaces inline duplicate-import guard with singleton module side effect import.
.changeset/shared-singletons-global.md Records the patch release note for shared global singletons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/qwik/src/core/shared/qrl/qrl.ts Outdated
Comment thread packages/qwik/src/server/platform.unit.ts
Comment on lines +19 to +35
if (isServer) {
// We can only have 1 Qwik version
const existing = QWIK.version;
if (existing) {
if (existing !== version) {
// Server allows only one Qwik version per process; same-version coexistence is fine
// and gets to share the singleton state.
qError(QError.duplicateQwik, [existing, version]);
}
} else {
QWIK.version = version;
}
singletons = QWIK.singletons ||= {};
} else {
// On the client, we can have multiple Qwik versions coexisting, but they don't share state.
singletons = QWIK[version] ||= {};
}
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 429bef5

@wmertens
Copy link
Copy Markdown
Member Author

wmertens commented May 3, 2026

hmm _captures is also a singleton, we need to change it to a holder object

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

Labels

None yet

Projects

Status: Waiting For Review

Development

Successfully merging this pull request may close these issues.

3 participants