Skip to content

Commit

Permalink
fix: handling special characters in specifier (#2197)
Browse files Browse the repository at this point in the history
* fix: import specifier

* fix: winpath
  • Loading branch information
Jinbao1001 authored Sep 13, 2024
1 parent cfccffc commit 701b3a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/loaders/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function emitDemo(
const entryFileName = Object.keys(demo.asset.dependencies)[0];
demoDepsMap[demo.id] ??= {};
Object.keys(demo.resolveMap).forEach((key, index) => {
const specifier = `${demo.id.replace(/-/g, '_')}_deps_${index}`;
const specifier = `${demo.id.replace(/[^\w\d]/g, '_')}_deps_${index}`;
if (key !== entryFileName) {
const normalizedKey = isRelativePath(key)
? winPath(demo.resolveMap[key])
Expand Down
3 changes: 2 additions & 1 deletion src/loaders/post-raw/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { winPath } from '@umijs/utils';
/**
* loader for mako dumi-raw watch-parent
*/
export default function postRawLoader(this: any, raw: string) {
return `
import '${this.resourcePath}?watch=parent';
import '${winPath(this.resourcePath)}?watch=parent';
${raw};
`;
}

0 comments on commit 701b3a8

Please sign in to comment.