feat(cli-build): derive vendor import-map entry points from package.json exports#1222
Draft
stipsan wants to merge 2 commits into
Draft
feat(cli-build): derive vendor import-map entry points from package.json exports#1222stipsan wants to merge 2 commits into
stipsan wants to merge 2 commits into
Conversation
…son exports Replace hardcoded VENDOR_IMPORTS subpath tables with resolution from each package's package.json exports, applying browser bundler conditions (browser/import/default). styled-components keeps a browser-field fallback since it does not yet use exports. CJS wrapper entries are followed when extracting named exports for the vendor build plugin. Fixes #1209
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 11.13 MB | - |
| Bundled (gzip) | 2.10 MB | - |
| Import time | 863ms | +2ms, +0.3% |
bin:sanity
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 1023 B | - |
| Internal (gzip) | 486 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.95s | -2ms, -0.1% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against main (cdd349bf)
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 96.3 KB | - |
| Internal (gzip) | 22.7 KB | - |
| Bundled (raw) | 21.70 MB | - |
| Bundled (gzip) | 3.45 MB | - |
| Import time | 772ms | +4ms, +0.6% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against main (cdd349bf)
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 908 B | - |
| Internal (gzip) | 483 B | - |
| Bundled (raw) | 931 B | - |
| Bundled (gzip) | 491 B | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Contributor
Coverage Delta
Comparing 3 changed files against main @ Overall Coverage
|
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.
Description
Vendor import-map entry points for
react,react-dom, andstyled-componentswere hardcoded per package/version/subpath inbuildVendorDependencies.ts. When upstream packages add newexportssubpaths, studios cannot use them until we manually update the table and cut a CLI release.This PR resolves vendor entry points automatically from each package's
package.json:react/react-dom: enumerate subpaths fromexports, resolving targets with browser bundler conditions (browser→import→default).styled-components: special-case fallback using the webpack-style top-levelbrowserfield (picksmodule, then applies the browser remap), since it does not yet useexports.react/index.js→cjs/react.production.js) are followed when extracting named exports for the vendor build plugin.Version range checks remain in place; only the subpath table is derived dynamically.
Fixes #1209
What to review
resolveVendorEntryPoints.ts— export resolution logic and styled-components browser-field fallbackresolveCjsNamedExportsSource.ts— production CJS wrapper following for named-export extractionbuildVendorDependencies.ts— wiring: version validation + dynamic entry-point resolutionreact/react-dom/styled-componentspackage.json filesbuildVendorDependencies.test.tsintegration tests (named exports, external require rewrite, styled-components)Testing
resolveVendorEntryPoints.test.ts— export condition resolution, react/react-dom/styled-components entry-point derivationresolveCjsNamedExportsSource.test.ts— CJS wrapper following for named-export extractionbuildVendorDependencies.test.ts— end-to-end vendor build (react, react-dom, styled-components named exports + no runtimerequireshims)pnpm check:types --filter=@sanity/cli-buildpnpm lintin@sanity/cli-buildpnpm knip --workspace @sanity/cli-build