Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: demo relative path also need to share #2190

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里改完似乎前后不等价,修改前 entryFileName 会进 demoDepsMap,修改后不会了,但应该修改前是不符合预期的

Ps: 感觉这里的逻辑看起来有点吃力,可能前面 PR 忘了,建议补点注释

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对 ,修改前有问题~, 好的, 我后面补充上来~

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
Loading