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

feat: chunk importmap #16552

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
refactor: use MagicString::replace instead of String::replace
bhbs committed Oct 20, 2024
commit 553e503114517e8b7a53ee84ec0ecf85764e84ee
14 changes: 7 additions & 7 deletions packages/vite/src/node/plugins/chunkImportMap.ts
Original file line number Diff line number Diff line change
@@ -64,13 +64,13 @@ export function chunkImportMapPlugin(): Plugin {
)
})

const codeProcessed = augmentFacadeModuleIdHash(code)
return {
code: codeProcessed,
map: new MagicString(codeProcessed).generateMap({
hires: 'boundary',
}),
}
const s = new MagicString(code)
// note that MagicString::replace is used instead of String::replace
s.replace(
hashPlaceholderRE,
(match) => hashPlaceholderToFacadeModuleIdHashMap.get(match) ?? match,
)
return { code: s.toString(), map: s.generateMap({ hires: 'boundary' }) }
},
}
}