Fix module resolution for relative require() inside CJS deps when the project path contains spaces - #15119
Fix module resolution for relative require() inside CJS deps when the project path contains spaces#15119dario-piotrowicz wants to merge 1 commit into
require() inside CJS deps when the project path contains spaces#15119Conversation
|
✅ All changesets look good |
|
pnpm isn't readily available and installing deps would be slow/network-dependent. My review can proceed based on static analysis, which is thorough. Let me finalize. Review SummaryThe change is well-designed and well-documented. Key findings:
No actionable issues found. The logic is sound, the retry is properly guarded, the test is a meaningful regression guard, and the changeset is appropriate. LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
I am slightly worried by the approach of "just trying" to decode it - there might be cases where this hits a corner case that is broken. In this PR (#14882) I used a prefix based approach to a similar problem (since we have control over both sides) that means we know exactly whether we need to decode things or not. Can we consider that approach? |
…he project path contains spaces
1524417 to
25fd996
Compare
🦋 Changeset detectedLatest commit: 25fd996 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 |
|
We recently landed #14994, a large change to Miniflare's configuration internals that touched ~177 files across the repo. Leaving this PR on its old base was likely to cause conflicts, so we've rebased it onto the latest Your local copy of this branch is now out of date. Before you push again, please reset to the new version: git fetch origin
git checkout dario/vitest-spaces
git reset --hard origin/dario/vitest-spacesBecause the base moved a long way, it's also worth reinstalling before you carry on — the lockfile changed: pnpm installSorry for the interruption. If the rebase looks wrong, or CI now fails in a way that seems related to the Miniflare config change rather than your own work, comment here and we'll help get it sorted. |
Fixes #15048
When a project lives under a directory with a space in its name, externalized CommonJS dependencies that use relative
require()calls (e.g.require("./lib/impl.js")) would fail with "No such module" because workerd percent-encodes the space as%20in the module name, and subsequent relative imports inherit that encoding. The module fallback handler now retries resolution with decoded paths when the percent-encoded path doesn't exist on disk.A picture of a cute animal (not mandatory, but encouraged)