Skip to content

Commit 5aef91c

Browse files
authored
fix: use pathToFileURL to ensure windows compatibility (#38)
* fix: use pathToFileURL to ensure windows compatibility see #29 (comment) * add changeset
1 parent 50b76f8 commit 5aef91c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/brave-boxes-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
fix: ensure esm config loading works on windows

packages/vite-plugin-svelte/src/utils/loadSvelteConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path';
22
import fs from 'fs';
3+
import { pathToFileURL } from 'url';
34
import { log } from './log';
45
import { Options } from './options';
56
import { ResolvedConfig } from 'vite';
@@ -21,7 +22,7 @@ export async function loadSvelteConfig(
2122
// try to use dynamic import for svelte.config.js first
2223
if (configFile.endsWith('.js') || configFile.endsWith('.mjs')) {
2324
try {
24-
return await dynamicImportDefault(configFile);
25+
return await dynamicImportDefault(pathToFileURL(configFile).href);
2526
} catch (e) {
2627
log.debug(`failed to import config ${configFile}`, e);
2728
err = e;

0 commit comments

Comments
 (0)