Skip to content

Turbopack: read package.json main and alias fields through typed projections - #100980

Draft
lukesandberg wants to merge 1 commit into
claude/typed-next-config-jsonfrom
claude/typed-package-json-fields
Draft

lukesandberg wants to merge 1 commit into
claude/typed-next-config-jsonfrom
claude/typed-package-json-fields

Conversation

@lukesandberg

@lukesandberg lukesandberg commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When resolving into a package, the main fields (main, module, ...) and the alias field (browser) were read straight from the parsed package.json. Any edit to that file, such as to scripts or dependencies, therefore invalidated those resolutions.

They now go through per-field tasks, like the exports and imports fields already do:

  • package_json_string_field(path, field) returns the field's string
  • package_json_alias_field(path, field) returns the alias entries as typed values: false means ignore, a string is a request to resolve instead, and anything else is kept as JSON text for the existing error

Resolution 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

  • New test test_package_json_string_field_invalidation: an edit to scripts doesn't re-run a reader of main, and a change to main does
  • cargo test -p turbopack-tests --test execution -- resolving: 33 passed, including alias_field, self_reference and exports_field_pattern
  • cargo check --workspace --tests, cargo clippy -p turbopack-core --tests: clean
  • cargo test -p turbopack-core --lib: the 25 resolve:: temp-dir tests that fail on macOS fail identically on the base branch; everything else passes
@github-actions github-actions Bot added created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js. labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 48d26f2

@lukesandberg
lukesandberg force-pushed the claude/typed-package-json-fields branch from 51ade42 to 4d9c99d Compare October 31, 2026 00:08

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent reviewed 4d9c99d and found no issues.

@lukesandberg
lukesandberg force-pushed the claude/typed-package-json-fields branch from 4d9c99d to fe5ff45 Compare October 31, 2026 03:45

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent reviewed fe5ff45 and found no issues.

@lukesandberg
lukesandberg force-pushed the claude/typed-package-json-fields branch from fe5ff45 to bac066a Compare October 31, 2026 06:08

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent reviewed bac066a and found no issues.

…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
lukesandberg force-pushed the claude/typed-package-json-fields branch from bac066a to 48d26f2 Compare October 31, 2026 06:26

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent reviewed 48d26f2 and found no issues.

This branch has not been deployed

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

Labels

created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js.

1 participant