mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #847] fix(plugins): resolve optimized imports past local barrels #895
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#895
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/847
Author: @llc1123
Created: 4/15/2026
Status: 🔄 Open
Base:
main← Head:fix/issue-845-optimize-imports📝 Commits (10+)
012c532fix(plugins): resolve optimized imports past local barrelse8079c8test: cover antd App Router build regressione9fe4c3fix(plugins): parse JSX before optimize-import rewriting68e0efftest: cover JSX-bearing optimize-import transforms34ef836test: strengthen optimize-imports build assertions1c2d1eefix(plugins): avoid phantom fallback exportsda5fd92fix(plugins): guard export-map reentry during barrel analysis9caf7fetest: split optimize-imports transform coverage2394156test: split optimize-imports export-map basics5109d7btest: split optimize-imports export-map recursion cases📊 Changes
10 files changed (+1200 additions, -732 deletions)
View changed files
📝
packages/vinext/src/plugins/optimize-imports.ts(+312 -37)➕
tests/optimize-imports-build.test.ts(+188 -0)➕
tests/optimize-imports-export-map-bindings.test.ts(+56 -0)➕
tests/optimize-imports-export-map-failures.test.ts(+48 -0)➕
tests/optimize-imports-export-map-recursion.test.ts(+117 -0)➕
tests/optimize-imports-export-map-reexports.test.ts(+67 -0)➕
tests/optimize-imports-export-map-wildcards.test.ts(+100 -0)➕
tests/optimize-imports-plugin.test.ts(+127 -0)➕
tests/optimize-imports-regressions.test.ts(+159 -0)📝
tests/optimize-imports.test.ts(+26 -695)📄 Description
Summary
optimize-importsso optimized package imports keep following local re-export chains to the concrete leaf module instead of stopping at an intermediate barrel likeantd/es/button/index.jsexport *boundaries inside optimized packages before downstream graph analysis so@vitejs/plugin-rscno longer sees the issue-845 client-boundary shapeantdrepro pathValidation
./node_modules/.bin/vp test run tests/optimize-imports.test.ts -t "multi-hop antd barrel"./node_modules/.bin/vp test run tests/optimize-imports-build.test.tsIssue
Fixes #845.
Current solution
The bug happened because
vinext:optimize-importsused to stop at an intermediate local barrel (antd/es/button/index.js). That file is a"use client"boundary withexport *, so@vitejs/plugin-rsclater failed withunsupported ExportAllDeclaration.The fix keeps the rewrite generic rather than
antd-specific:.jsleaf fails, so the local-barrel walk can still reach the leaf moduleThis means the app import now rewrites to the concrete leaf module instead of leaking the intermediate
export *barrel into the RSC build.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.