Skip to content

Commit 313d683

Browse files
authored
fix: Normalize paths in Windows (#33)
1 parent 0548cb3 commit 313d683

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,27 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (
2424
enforce: 'pre',
2525

2626
transformInclude(id) {
27-
const { file, query } = parse_ID(id);
27+
const { file, query } = parse_ID(normalizePath(id));
2828
return query.raw == null && filter(file);
2929
},
3030
transform(code, id) {
31-
return transform(code, id, opts, isWebpack);
31+
return transform(code, normalizePath(id), opts, isWebpack);
3232
},
3333
};
3434
};
3535

3636
function resolveOptions(opts: Options): ResolvedOptions {
3737
return {
38-
root: opts.root ?? process.cwd(),
38+
root: normalizePath(opts.root ?? process.cwd()),
3939
sourceMap: opts.sourceMap ?? false,
4040
babelParserPlugins: opts.babelParserPlugins ?? [],
4141
include: opts.include ?? /\.(vue|jsx|tsx|mdx)$/,
4242
exclude: opts.exclude ?? /\/node_modules\//,
4343
};
4444
}
4545

46+
function normalizePath(path: string) {
47+
return path.replace(/\\/g, '/');
48+
}
49+
4650
export default /* #__PURE__ */ createUnplugin(unpluginFactory);

0 commit comments

Comments
 (0)