Astro Info
Astro v6.1.3
Vite v7.3.1
Node v25.8.2
System macOS (x64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare (v13.1.7)
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When a .ts file default-imports .astro components (the same pattern used by @storyblok/astro's virtual:import-storyblok-components), astro build logs errors like:
[ERROR] No matching export in "html:/path/to/Component.astro" for import "default"
The astro-frontmatter-scan esbuild plugin (in @astrojs/cloudflare) registers its onLoad handler without a namespace filter:
// esbuild-plugin-astro-frontmatter.js
build.onLoad({ filter: /\.astro$/ }, async (args) => { ... });
This intercepts .astro files in both the file and html esbuild namespaces. When a .ts file imports a .astro file, esbuild resolves that .astro import in the html namespace. The plugin extracts only the frontmatter (which has no export default), so the default import fails.
The build ultimately succeeds because Vite falls back when dep scanning fails ("Skipping dependency pre-bundling"), but the errors are noisy and dep pre-bundling is skipped entirely, which may hurt performance.
What's the expected result?
No errors during dependency scanning. The astro-frontmatter-scan plugin should scope its onLoad to the file namespace, and provide a separate handler for the html namespace that appends export default {} — matching what Vite's own html-type loader would have done.
Potential fix
Add a namespace filter to the existing handler and add a second handler for the html namespace:
// Scope to "file" namespace (original behavior):
build.onLoad({ filter: /\.astro$/, namespace: "file" }, async (args) => ({
contents: extractFrontmatter(args.path),
loader: "ts",
}));
// "html" namespace: append a default export so default imports resolve:
build.onLoad({ filter: /\.astro$/, namespace: "html" }, async (args) => ({
contents: extractFrontmatter(args.path) + "\nexport default {};",
loader: "ts",
}));
Link to Minimal Reproducible Example
https://github.com/adamchal/cloudflare-frontmatter-scan
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When a
.tsfile default-imports.astrocomponents (the same pattern used by@storyblok/astro'svirtual:import-storyblok-components),astro buildlogs errors like:The
astro-frontmatter-scanesbuild plugin (in@astrojs/cloudflare) registers itsonLoadhandler without anamespacefilter:This intercepts
.astrofiles in both thefileandhtmlesbuild namespaces. When a.tsfile imports a.astrofile, esbuild resolves that.astroimport in thehtmlnamespace. The plugin extracts only the frontmatter (which has noexport default), so the default import fails.The build ultimately succeeds because Vite falls back when dep scanning fails ("Skipping dependency pre-bundling"), but the errors are noisy and dep pre-bundling is skipped entirely, which may hurt performance.
What's the expected result?
No errors during dependency scanning. The
astro-frontmatter-scanplugin should scope itsonLoadto thefilenamespace, and provide a separate handler for thehtmlnamespace that appendsexport default {}— matching what Vite's own html-type loader would have done.Potential fix
Add a
namespacefilter to the existing handler and add a second handler for thehtmlnamespace:Link to Minimal Reproducible Example
https://github.com/adamchal/cloudflare-frontmatter-scan
Participation