fix(pack): bundle direct tsdown picomatch require#1732
Merged
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
caf086f to
4e0ce48
Compare
fengmk2
commented
Jun 1, 2026
Member
Author
|
@cursor review |
vite-plus
@voidzero-dev/vite-plus-core
@voidzero-dev/vite-plus-prompts
@voidzero-dev/vite-plus-test
@voidzero-dev/vite-plus-cli-darwin-arm64
@voidzero-dev/vite-plus-cli-darwin-x64
@voidzero-dev/vite-plus-cli-linux-arm64-gnu
@voidzero-dev/vite-plus-cli-linux-arm64-musl
@voidzero-dev/vite-plus-cli-linux-x64-gnu
@voidzero-dev/vite-plus-cli-linux-x64-musl
@voidzero-dev/vite-plus-cli-win32-arm64-msvc
@voidzero-dev/vite-plus-cli-win32-x64-msvc
@voidzero-dev/vite-plus-darwin-arm64
@voidzero-dev/vite-plus-darwin-x64
@voidzero-dev/vite-plus-linux-arm64-gnu
@voidzero-dev/vite-plus-linux-arm64-musl
@voidzero-dev/vite-plus-linux-x64-gnu
@voidzero-dev/vite-plus-linux-x64-musl
@voidzero-dev/vite-plus-win32-arm64-msvc
@voidzero-dev/vite-plus-win32-x64-msvc
commit: |
Member
Author
|
@cursor review |
Brooooooklyn
approved these changes
Jun 1, 2026
Member
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 03f5f91. Configure here.
03f5f91 to
97317a7
Compare
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
Fixes the bundled
tsdownbuild so directcreateRequire(...)("picomatch")calls are rewritten to the bundled local CJS entry, matching the existing handling for assignedrequirecalls.This prevents
vp packfrom depending on an undeclared runtimepicomatchresolution when installed with pnpmhoist: false.Root Cause
The core package build step already scans bundled tsdown output for third-party CJS requires and creates local bundled entry files. It handled patterns like:
but missed direct-call patterns like:
As a result,
picomatchremained a runtime package lookup from@voidzero-dev/vite-plus-core/dist/tsdown/main-*.js.Validation
pnpm -F @voidzero-dev/vite-plus-core buildpnpm -F vite-plus snap-test-global command-pack-picomatch-hoist-falsegit diff --check -- packages/core/build-support/find-create-require.ts packages/cli/snap-tests-global/command-pack-picomatch-hoist-falseFixes #1731
Note
Medium Risk
Changes core build-time AST rewriting for bundled tsdown CJS requires; incorrect detection could break pack/runtime resolution, but scope is limited to the existing replaceThirdPartyCjsRequires path.
Overview
Extends the tsdown re-bundle step’s createRequire scanner so inline
createRequire(...)("picomatch")(and similar) calls get rewritten to local bundled CJS entry paths, not onlyconst require = createRequire(...); require("pkg").The AST helpers now return flat RequireCall lists, share literal-argument extraction, and add findDirectCreateRequireCalls for both static-import and getBuiltinModule createRequire patterns.
Adds a global snap fixture command-pack-picomatch-hoist-false (pnpm hoist: false) to assert vp pack completes without relying on hoisted picomatch.
Reviewed by Cursor Bugbot for commit 03f5f91. Configure here.