Repository navigation
Conversation
🦋 Changeset detectedLatest commit: efadc13 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
I'm Bonk, and I've done a quick review of your PR. Adds pnpm-safe symlink canonicalization for Vitest module resolution.
|
There was a problem hiding this comment.
Superseded by the review of
efadc13d.
This review, of 2743bc8a
✅ Approved — No issues found. The real-path mapping only runs when resolve.preserveSymlinks is on, maps each id once for both import and require(), and is covered by tests.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
The changeset is present and appropriate for a bug fix. Risk: low.
🔒 Security: ✅ LGTM
The change only maps module ids that Vite has already resolved to their real paths under node_modules. It adds no new input, endpoint or secret.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The real-path mapping is applied exactly once per resolution: by the pre-order resolveId hook for import, and by the module fallback service for require(). Virtual, relative and cloudflare:test ids are unaffected, query suffixes are kept, and the test mocks were updated for the new config field.
⚡ Performance: ✅ LGTM
The cost is one synchronous realpathSync per resolved id under node_modules, and only when preserveSymlinks is enabled.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 2743bc8a
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
With `resolve.preserveSymlinks: true` in a pnpm project, tests fail to start with `No such module ".../node_modules/vitest/dist/chai"`. The plugin sends every dependency through Vite, including Vitest itself. With `preserveSymlinks`, Vite loads each package from its symlink in `node_modules`. pnpm puts a package's own dependencies only next to the package's real location, so Vite can't find them from the symlink. With `preserveSymlinks` enabled: - Files under `node_modules` resolve to their real path, if the real path is also under `node_modules`. Packages linked from outside `node_modules` (`npm link`, `file:`) keep their symlinked path, so they still find peer dependencies in the project. - This applies to both `import` and `require()`. - `fs.realpathSync` from `node:fs` finds real paths. Bazel's rules_js patches this function to keep paths inside the sandbox, and it keeps mapped drive letters on Windows. Projects without `preserveSymlinks` behave as before. The plugin's `resolveId` hook now runs before the hooks of other plugins, but it returns the same results. Related: CC-9111
2743bc8 to
efadc13
Compare
There was a problem hiding this comment.
✅ Approved — No issues found. The real-path mapping runs only when resolve.preserveSymlinks is enabled, it keeps query and hash suffixes, and tests cover it.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
The pull request includes a changeset, which fits a bug fix. Risk: low.
🔒 Security: ✅ LGTM
The change only rewrites module ids that Vite has already resolved. It keeps the rewritten path only when that path is still under node_modules, and it adds no new input, endpoint or secret.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
Each resolution is mapped to its real path exactly once: by the pre-order resolveId hook for import, and by the module fallback service for require(). realPackagePath keeps ?query and #hash suffixes and, like Vite, first tries a # as part of the file name. It falls back to the original id when the real path leaves node_modules.
⚡ Performance: ✅ LGTM
The new cost is one synchronous realpathSync per resolved id under node_modules, and only when preserveSymlinks is enabled. Vite caches the extra this.resolve call that uses skipSelf.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: efadc13d
With
resolve.preserveSymlinks: truein a pnpm project, tests fail to start withNo such module ".../node_modules/vitest/dist/chai". The plugin sends every dependency through Vite, including Vitest itself. WithpreserveSymlinks, Vite loads each package from its symlink innode_modules. pnpm puts a package's own dependencies only next to the package's real location, so Vite can't find them from the symlink.With
preserveSymlinksenabled:node_modulesresolve to their real path, if the real path is also undernode_modules. Packages linked from outsidenode_modules(npm link,file:) keep their symlinked path, so they still find peer dependencies in the project.importandrequire().fs.realpathSyncfromnode:fsfinds real paths. Bazel's rules_js patches this function to keep paths inside the sandbox, and it keeps mapped drive letters on Windows.Projects without
preserveSymlinksbehave as before. The plugin'sresolveIdhook now runs before the hooks of other plugins, but it returns the same results.Related: CC-9111