Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-scss-virtual-sourcemap-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix a spurious `Sourcemap for "<template>.marko-virtual.scss" points to missing source files` warning in dev when a `.marko` template has a `<style>` block. The dep optimizer compiled templates with `sourceMaps: "inline"`, which drops the extracted style block's separate sourcemap; the shared compiler cache then left the dev server serving the virtual CSS with no map to trace back to its template, so the style preprocessor emitted a self-referential map to the (non-existent) virtual file. The optimizer now uses `sourceMaps: "both"` so the separate map is retained, and the entry compile configs no longer force `sourceMaps: false` (the compiler now skips the entry wrapper's own map on its side), so CSS sourcemaps survive.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
clientEntryConfig = {
...baseConfig,
output: "hydrate",
sourceMaps: false,
// `sourceMaps` stays on so extracted `<style>` maps survive; the
// compiler skips the entry wrapper's own (meaningless) map.
// Also keep the AST here so the page entry's own side effect imports
// (eg the assets a server only page links in) are captured too.
ast: isBuild,
Expand All @@ -390,17 +391,17 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
} as any;
serverEntryConfig = {
...serverConfig,
// Legacy server entry: a plain `html` wrapper the compiler can't
// distinguish from a real template, so suppress its map here.
sourceMaps: false,
};
serverEntryLinkConfig = {
...serverConfig,
entry: "page",
sourceMaps: false,
};
clientLoadEntryConfig = {
...clientConfig,
entry: "load",
sourceMaps: false,
};

compiler.configure(baseConfig);
Expand Down
4 changes: 3 additions & 1 deletion src/rolldown-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default function rolldownPlugin(
const baseConfig: compiler.Config = {
...config,
hot: false,
sourceMaps: "inline",
// `both`, not `inline`: virtual files (eg `<style>` blocks) reach the dev
// server via shared `virtualFiles`, which needs the map `inline` drops.
sourceMaps: "both",
};
return [
{
Expand Down
Loading