Fix module resolution for relative require() inside CJS deps when the project path contains spaces - #15156
Conversation
🦋 Changeset detectedLatest commit: c5b7fb2 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 |
|
✅ All changesets look good |
|
Dependencies aren't installed. I've done a thorough static analysis of the logic, which is sound. Let me verify my understanding of one potential concern by re-reading the decode function's safety claim regarding double-encoded The decode: The implementation is correct, well-documented, and thoroughly tested with regression tests covering the space case, space+literal-%, the redirect Location path, and the echoed-specifier decode path. The changeset is appropriately scoped as a patch to the correct package. No logic bugs, security issues, backward-compat violations, or incorrect API behavior found. 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 |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Thanks! 😄 Sorry however I converted the PR to draft as I think it wasn't completely fixing the issue, I'll double check whether these changes need some tweaking, sorry for not having done this earlier! 🙇 |
…he project path contains spaces
eb008cb to
1355f70
Compare
|
@petebacondarwin sorry I've fixed the implementation (the previous iteration didn't really work 😓), could you have another look? 🙏 |
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" becauseworkerdpercent-encodes the space as%20in the module name, and subsequent relative imports inherit that encoding. The module fallback handler now marks paths containing spaces with the same sentinel prefix already used for non-ASCII paths, so the encoding can be deterministically reversed on the way back.A picture of a cute animal (not mandatory, but encouraged)