Skip to content

Commit

Permalink
fix: use pathToFileURL to ensure windows compatibility (#38)
Browse files Browse the repository at this point in the history
* fix: use pathToFileURL to ensure windows compatibility

see #29 (comment)

* add changeset
  • Loading branch information
dominikg authored Apr 29, 2021
1 parent 50b76f8 commit 5aef91c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brave-boxes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

fix: ensure esm config loading works on windows
3 changes: 2 additions & 1 deletion packages/vite-plugin-svelte/src/utils/loadSvelteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import fs from 'fs';
import { pathToFileURL } from 'url';
import { log } from './log';
import { Options } from './options';
import { ResolvedConfig } from 'vite';
Expand All @@ -21,7 +22,7 @@ export async function loadSvelteConfig(
// try to use dynamic import for svelte.config.js first
if (configFile.endsWith('.js') || configFile.endsWith('.mjs')) {
try {
return await dynamicImportDefault(configFile);
return await dynamicImportDefault(pathToFileURL(configFile).href);
} catch (e) {
log.debug(`failed to import config ${configFile}`, e);
err = e;
Expand Down

0 comments on commit 5aef91c

Please sign in to comment.