Skip to content

Rebase absolute module specifiers under preserve_file_names - #15440

Merged
NuroDev merged 4 commits into
cloudflare:mainfrom
HuzaifaAbdulRehman:fix/15292-preserve-file-names-absolute-imports
Sep 18, 2026
Merged

NuroDev merged 4 commits into
cloudflare:mainfrom
HuzaifaAbdulRehman:fix/15292-preserve-file-names-absolute-imports

Conversation

@HuzaifaAbdulRehman

@HuzaifaAbdulRehman HuzaifaAbdulRehman commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15292.

With preserve_file_names, absolute non-JavaScript imports kept their build-machine paths. Rebasing them to a bare basename fixed portability but made different absolute files with the same basename collapse into one module.

Absolute imports now use ./<content-hash>/<basename>. This keeps each name portable and distinct while preserving the original basename. Relative imports and the public configuration surface are unchanged.

Test Plan

  • pnpm --filter wrangler test run src/__tests__/deploy/formats.test.ts -t 'should (rebase absolute non-js imports|keep absolute imports with matching basenames distinct)' (2 passed)

  • pnpm --filter wrangler check:type

  • oxlint --deny-warnings --type-aware on both changed files

  • oxfmt --check on both changed files

  • Tests

    • Tests included/updated
  • Public documentation

    • Documentation not necessary because: this fixes module naming without changing configuration.

With preserve_file_names enabled, a non-JavaScript module imported by an
absolute path kept that path as its module name. The deployed Worker then
carried a build-machine filesystem path and the module was never written
to --outdir, so a dry run passed while the upload failed with 10021.

Both onResolve sites now rebase an absolute specifier to ./<basename> and
leave relative specifiers alone.

Fixes cloudflare#15292
@changeset-bot

changeset-bot Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 762b7c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 31, 2026
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team August 31, 2026 11:19
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/silly-donkeys-smell.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/formats.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/module-collection.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15440

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15440

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15440

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15440

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15440

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15440

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15440

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15440

miniflare

npm i https://pkg.pr.new/miniflare@15440

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15440

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15440

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15440

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15440

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15440

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15440

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15440

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15440

wrangler

npm i https://pkg.pr.new/wrangler@15440

commit: 762b7c6

@github-project-automation github-project-automation Bot moved this from Untriaged to In Review in workers-sdk Sep 8, 2026
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/silly-donkeys-smell.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/formats.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/module-collection.ts: [@cloudflare/wrangler]

Different absolute modules could collapse when their basenames matched.
Content-hash directories keep generated names portable and distinct.
@HuzaifaAbdulRehman

Copy link
Copy Markdown
Contributor Author

These failures are outside this change; the changed Wrangler test file passed all 31 tests on Windows. I cannot rerun upstream jobs. Could someone rerun them?

@workers-devprod

workers-devprod commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk Sep 18, 2026
@NuroDev
NuroDev enabled auto-merge (squash) September 18, 2026 15:09
@NuroDev
NuroDev merged commit 43b1f85 into cloudflare:main Sep 18, 2026
60 of 61 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[wrangler] preserve_file_names keeps absolute non-JavaScript imports in the Worker bundle

3 participants