Skip to content

Fixes#8560

Open
wmertens wants to merge 2 commits intobuild/v2from
fixes
Open

Fixes#8560
wmertens wants to merge 2 commits intobuild/v2from
fixes

Conversation

@wmertens
Copy link
Copy Markdown
Member

@wmertens wmertens commented Apr 15, 2026

  • AsyncSignal: don't trigger .loading for sync functions
  • optimizer: don't change let counter to const counter

@wmertens wmertens requested a review from a team as a code owner April 15, 2026 20:13
Copilot AI review requested due to automatic review settings April 15, 2026 20:13
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: 85cf4ed

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

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

Updates Qwik core async-signal loading publication behavior and extends the optimizer’s root-variable migration to preserve declaration kinds while adding a new diagnostic for unsafe shared mutable root bindings across segments.

Changes:

  • AsyncSignal: only publish loading=true to subscribers when computation is actually async (QRL resolve or promise-returning compute).
  • Optimizer: preserve original let/var/const when migrating module-scope vars into segment modules; introduce diagnostic C06 SharedMutableRootVar.
  • Add optimizer tests + snapshots covering (a) error on shared module-scope let used by both root + segment, and (b) preserving let when migrated into a segment.

Reviewed changes

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

Show a summary per file
File Description
packages/qwik/src/core/reactive-primitives/impl/async-signal-impl.ts Adjusts when loading state is published to avoid transient loading states for sync resolves.
packages/optimizer/core/src/parse.rs Emits new shared-mutable-root-var error and preserves original var decl kind when migrating.
packages/optimizer/core/src/dependency_analysis.rs Tracks original var declaration kind (let/var/const) in dependency metadata.
packages/optimizer/core/src/errors.rs Adds new diagnostic rule/code mapping (SharedMutableRootVarC06).
packages/optimizer/core/src/test.rs Adds new regression tests for shared mutable root let and let-preservation on migration.
packages/optimizer/core/src/snapshots/* Adds snapshots for the new optimizer tests.
.changeset/loose-lemons-read.md Declares a minor optimizer release for the migration behavior change.

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

Comment thread packages/optimizer/core/src/parse.rs Outdated
Comment on lines +1008 to +1012
// Emit errors for mutable module-scope bindings (`let` / `var`) that are referenced
// by a segment but cannot be migrated (shared with main module or other segments).
// Extracted segments live in separate ES modules; they would receive a read-only
// import binding and could not write back to the parent module's `let`/`var`.
{
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This diagnostic currently triggers for any module-scope let/var referenced by a segment but not migrated. root_var_usage is built from local_idents/scoped_idents (reads as well as writes), so this will also error for read-only references where importing a let binding is valid. Consider tightening the condition to only error when the identifier is mutated inside a segment (e.g. update/assignment ops), or adjust the diagnostic/message to match the intended restriction.

Copilot uses AI. Check for mistakes.
Comment on lines 142 to 146
is_imported: false,
is_exported: user_exported.contains(&var_id),
depends_on: Vec::new(),
var_kind: Some(var_decl.kind),
},
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

var_kind is only populated for ModuleItem::Stmt(Stmt::Decl(Decl::Var)) declarations. export let/var/const ... is represented as ModuleDecl::ExportDecl, so those bindings will end up with var_kind: None (and often a synthetic decl/span), which can make migrated declarations default to const and can also cause the new shared-mutable diagnostic to be skipped. Consider handling ExportDecl var declarations in the same way as non-exported ones (both for var_kind and for capturing the original decl/span).

Copilot uses AI. Check for mistakes.
'@qwik.dev/optimizer': minor
---

FEAT: module-scoped `let` identifiers retain `let` when migrating
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This changeset describes the let-preservation behavior, but this PR also introduces a new optimizer error (C06 / SharedMutableRootVar) for shared mutable module-scope bindings captured by segments. Consider mentioning the new diagnostic/behavior change here as well so consumers understand the new failure mode when upgrading.

Suggested change
FEAT: module-scoped `let` identifiers retain `let` when migrating
FEAT: module-scoped `let` identifiers retain `let` when migrating.
This change also introduces optimizer error `C06` / `SharedMutableRootVar` for
shared mutable module-scope bindings captured by segments, so consumers may see
a new failure mode when upgrading.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 85cf4ed

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

@qwik.dev/core

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

@qwik.dev/router

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

eslint-plugin-qwik

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

create-qwik

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

@qwik.dev/optimizer

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

commit: 85cf4ed

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