Skip to content

Fix subpath imports of additional module types#12851

Merged
jamesopstad merged 2 commits into
mainfrom
james/subpath-imports
Mar 20, 2026
Merged

Fix subpath imports of additional module types#12851
jamesopstad merged 2 commits into
mainfrom
james/subpath-imports

Conversation

@jamesopstad
Copy link
Copy Markdown
Contributor

@jamesopstad jamesopstad commented Mar 11, 2026

Fixes #10879.

Fix a bug that prevented using subpath imports for additional module types

You can now use subpath imports for additional module types (.html, .txt, .sql, .bin, .wasm) by defining them in your package.json imports field:

// package.json
{
	"imports": {
		"#templates/page": "./src/templates/page.html",
	},
}
import page from "#templates/page";

export default {
	fetch() {
		return new Response(page, {
			headers: { "Content-Type": "text/html" },
		});
	},
} satisfies ExportedHandler;

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bug fix

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 11, 2026

✅ All changesets look good

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 11, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12851

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 73e65fe

@jamesopstad jamesopstad force-pushed the james/subpath-imports branch from 0a14838 to 1fc4bda Compare March 11, 2026 18:01
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 73e65fe

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

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

@jamesopstad jamesopstad force-pushed the james/subpath-imports branch from 1fc4bda to e384293 Compare March 11, 2026 19:23
@jamesopstad jamesopstad force-pushed the james/subpath-imports branch 4 times, most recently from 91f2622 to 153f958 Compare March 20, 2026 10:20
Comment thread packages/vite-plugin-cloudflare/src/plugins/additional-modules.ts
@jamesopstad jamesopstad marked this pull request as ready for review March 20, 2026 10:28
@jamesopstad jamesopstad requested a review from a team as a code owner March 20, 2026 10:28
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 20, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Approving but I'd like to understand why you were able to move the URL cleaning to after the module matching.

Comment thread packages/vite-plugin-cloudflare/src/plugins/additional-modules.ts
Comment thread packages/vite-plugin-cloudflare/src/plugins/additional-modules.ts
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Mar 20, 2026
@jamesopstad jamesopstad force-pushed the james/subpath-imports branch from 153f958 to 73e65fe Compare March 20, 2026 12:56
@jamesopstad jamesopstad merged commit 86a40f0 into main Mar 20, 2026
62 of 64 checks passed
@jamesopstad jamesopstad deleted the james/subpath-imports branch March 20, 2026 14:59
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Mar 20, 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.

Vite plugin breaks .html subpath imports

3 participants