Skip to content

Commit

Permalink
fix: use the resolved vite root (#247)
Browse files Browse the repository at this point in the history
* fix: use the resolved vite root

Although vite-plugin-svelte needs to infer a root in order to pre-scan
svelte dependencies, it should use the root returned in configResolved
to ensure compatibility with backend integrations and other plugins that
might modify the root.

Since vite-plugin-svelte uses `enforce: 'pre'`, it's not viable for
other plugins to workaround this by using `enforce: 'pre'`, since the
behavior would become order-dependent on how the user applies the
plugins, which is error-prone and would result in a bad user experience.

* chore: add changeset
  • Loading branch information
ElMassimo authored Jan 6, 2022
1 parent 9416dd2 commit e050541
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-tigers-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

use the resolved vite root to support backend integrations
1 change: 1 addition & 0 deletions packages/vite-plugin-svelte/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export function resolveOptions(
...defaultOptions.compilerOptions,
...preResolveOptions.compilerOptions
},
root: viteConfig.root,
isProduction: viteConfig.isProduction
};
addExtraPreprocessors(merged, viteConfig);
Expand Down

0 comments on commit e050541

Please sign in to comment.