Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use full filename for svelte.compile #700

Merged
merged 9 commits into from
Aug 6, 2023
5 changes: 5 additions & 0 deletions .changeset/grumpy-trains-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

fix links in error handling (console and vite overlay)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { VERSION } from 'svelte/compiler';
function normalizeSnapshot(result: string) {
// during dev, the import is rewritten but can vary on the v= hash. replace with stable short import
return result
.replace(
/\/\* .* generated by Svelte v\d\.\d+\.\d+(?:-[a-z]+\.\d+)? \*\//g,
'/* src/Dummy.svelte generated by Svelte vXXX */'
) // ensure generated svelte compiler comment is stable
.replace(/\.js\?v=[0-9a-f]{8}/g, '.js?v=XXX') // vite import analysis import rewrite version query
.replace(/generated by Svelte v\d\.\d+\.\d+(?:-[a-z]+\.\d+)?/g, 'generated by Svelte vXXX') // compiler version comment
.replace(/"total": *\d+\.\d+/g, '"total":0.123456789'); // svelte compile stats
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-svelte/src/utils/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const _createCompileSvelte = (makeHot) => {
/** @type {import('../index.d.ts').CompileOptions} */
const compileOptions = {
...options.compilerOptions,
filename: normalizedFilename, // use normalized here to avoid bleeding absolute fs path
filename,
generate: ssr ? 'ssr' : 'dom'
};
if (isSvelte3) {
Expand Down