Repository navigation
Turbopack: read package.json main and alias fields through typed projections - #100980
Draft
lukesandberg wants to merge 1 commit into
Draft
lukesandberg wants to merge 1 commit into
lukesandberg wants to merge 1 commit into
Conversation
Contributor
Tests PassedCommit: 48d26f2 |
lukesandberg
force-pushed
the
claude/typed-package-json-fields
branch
from
October 31, 2026 00:08
51ade42 to
4d9c99d
Compare
lukesandberg
force-pushed
the
claude/typed-package-json-fields
branch
from
October 31, 2026 03:45
4d9c99d to
fe5ff45
Compare
lukesandberg
force-pushed
the
claude/typed-package-json-fields
branch
from
October 31, 2026 06:08
fe5ff45 to
bac066a
Compare
…ections Resolving a main field (main, module, ...) or an alias field (browser) read the whole parsed package.json, so any edit to it, such as to scripts or dependencies, invalidated those resolutions. Read them through per-field tasks, like the exports and imports fields: package_json_string_field returns the field's string and package_json_alias_field the alias entries as typed values.
lukesandberg
force-pushed
the
claude/typed-package-json-fields
branch
from
October 31, 2026 06:26
bac066a to
48d26f2
Compare
This branch has not been deployed
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.
Summary
When resolving into a package, the main fields (
main,module, ...) and the alias field (browser) were read straight from the parsedpackage.json. Any edit to that file, such as toscriptsordependencies, therefore invalidated those resolutions.They now go through per-field tasks, like the
exportsandimportsfields already do:package_json_string_field(path, field)returns the field's stringpackage_json_alias_field(path, field)returns the alias entries as typed values:falsemeans ignore, a string is a request to resolve instead, and anything else is kept as JSON text for the existing errorResolution now depends only on these small cells, so an edit to an unrelated field stops at them. Behavior is unchanged, including the "invalid alias field value" issue.
Verification
test_package_json_string_field_invalidation: an edit toscriptsdoesn't re-run a reader ofmain, and a change tomaindoescargo test -p turbopack-tests --test execution -- resolving: 33 passed, includingalias_field,self_referenceandexports_field_patterncargo check --workspace --tests,cargo clippy -p turbopack-core --tests: cleancargo test -p turbopack-core --lib: the 25resolve::temp-dir tests that fail on macOS fail identically on the base branch; everything else passes