Repository navigation
Resolve values without promises unless an import has to be loaded - #133
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
nstepien
force-pushed
the
sync-resolution
branch
from
November 7, 2026 04:25
ee05e67 to
ec73ab2
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resolveValue and resolveBinding return the value itself when it does not depend on an import that has to be loaded first. The binding cache still holds values, not promises, as a cycle would wait for its own promise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nstepien
force-pushed
the
sync-resolution
branch
from
November 7, 2026 04:55
ec73ab2 to
402dc97
Compare
nstepien
marked this pull request as ready for review
November 7, 2026 04:59
nstepien
added a commit
that referenced
this pull request
Nov 7, 2026
Main reworked the import handling underneath this branch: imports read from the top-level statements (#127), parses cached while pending (#128), imports as bindings of the module-level scope with default imports through `*default*` (#131), values resolved without promises (#133), and TypeScript namespaces given a scope of their own (#130). src/index.ts was taken from main and this branch's features ported onto it: - Namespace imports are `NamespaceImport` bindings, and member chains (`ns.a.b`) resolve through the exports of each namespace. - Exports are `moduleExports` (local, re-export, namespace) plus `exportStarSources`, read from the top-level statements, and `resolveExport` follows them with ESM precedence and ambiguity. Exporting an imported binding re-exports it, as in the spec. Exported functions, classes, enums, and destructured bindings are recorded, so that they take precedence over `export *`. - Type-only imports and exports are skipped through `importKind` and `exportKind`, as the module record is no longer read. - Main's `isCssTag`, `bindingValues`, and `MaybePromise` resolution are kept. An import resolves through `resolveExport` and imports the stylesheet of the module that declares the value. Main's decisions win where they differ from this branch: - TypeScript namespaces are not supported: the namespace-name and `import x =` bindings are dropped, along with the typed fixture's namespace cases, as main's namespace test covers containment. Enums still shadow. - Templates exported by default get no `default` name, so their class names hash like main's. Main's import-forms test now extracts the namespace member and the re-export it skipped. Two fixture cases cover the export of a namespace import and a member of a local object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolveValueandresolveBindingwere async, so every interpolation went through a promise, even a literal or aconstdeclared in the module. They now return the value itself, and only return a promise when an import has to be loaded first. Cached bindings, literals, and localconstbindings resolve synchronously.The binding cache still holds values, not promises: while a binding resolves, it is cached as unknown, and its value replaces it once resolved. A cached promise would make a cycle wait for itself.
AGENTS.mdand the comment onbindingValuesnow say so.Benchmarks
Medians with Vite 8.3.5, #131 against this branch. The JS, CSS, and final source maps are identical.
tokens.tssrcAlternatives
WeakMaps keyed by AST nodes, goes stale in the dev server: editingtokens.tskeeps the parse of a module that exports one of its values again, so the old value stays cached. A transform that reads a cached value would also skip importing the stylesheet of its module and registering itself as a dependent for HMR. And concurrent transforms would see the bindings that others are resolving as cycles.This also enables the
prefer-constlint rule, which the code already follows.denyWarningsmakes it fail the lint like the other rules.The tests pass unchanged, and the only uncovered line is the same as in #131.
🤖 Generated with Claude Code