Skip to content

Commit

Permalink
fix: relative path also need to share
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 committed Aug 23, 2024
1 parent 472341b commit f5919c1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/loaders/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ function emitDemo(
demoDepsMap[demo.id] ??= {};
Object.keys(demo.resolveMap).forEach((key, index) => {
const specifier = `${demo.id.replace(/-/g, '_')}_deps_${index}`;
if (key !== entryFileName && !isRelativePath(key)) {
if (shareDepsMap[key]) {
demoDepsMap[demo.id][key] = shareDepsMap[key];
if (key !== entryFileName) {
const normalizedKey = isRelativePath(key)
? winPath(demo.resolveMap[key])
: key;

if (!shareDepsMap[normalizedKey]) {
demoDepsMap[demo.id][normalizedKey] = specifier;
shareDepsMap[normalizedKey] = specifier;
} else {
demoDepsMap[demo.id][key] = specifier;
shareDepsMap[key] = specifier;
demoDepsMap[demo.id][normalizedKey] = shareDepsMap[normalizedKey];
}
} else if (isRelativePath(key)) {
demoDepsMap[demo.id][winPath(demo.resolveMap[key])] = specifier;
}
});
}
Expand Down

0 comments on commit f5919c1

Please sign in to comment.