Skip to content

Commit

Permalink
fix: normalize dep ids in StatsMap (#6)
Browse files Browse the repository at this point in the history
This PR ensures a consistent representation of module ids in the statsMap. The updated code normalizes the depId before processing it.

It also hopefully closes #5
  • Loading branch information
dannytce committed Apr 24, 2023
1 parent 8afda3e commit 5d44638
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default function pluginTurbosnap({
importers?: readonly string[]
): Module {
return {
id: normalize(filename),
name: normalize(filename),
id: filename,
name: filename,
reasons: createReasons(importers),
};
}
Expand All @@ -96,11 +96,14 @@ export default function pluginTurbosnap({
mod.importedIds
.concat(mod.dynamicallyImportedIds)
.filter((name) => isUserCode(name))
.forEach((depId) => {
.forEach((depIdUnsafe) => {
const depId = normalize(depIdUnsafe);
if (statsMap.has(depId)) {
const m = statsMap.get(depId);
if (m) {
m.reasons = (m.reasons ?? []).concat(createReasons([mod.id]));
m.reasons = (m.reasons ?? [])
.concat(createReasons([mod.id]))
.filter((r) => r.moduleName !== depId);
statsMap.set(depId, m);
}
} else {
Expand Down

0 comments on commit 5d44638

Please sign in to comment.