Skip to content

Commit

Permalink
sourcemap initModule
Browse files Browse the repository at this point in the history
  • Loading branch information
FuPeiJiang committed Feb 20, 2023
1 parent 6c50119 commit 95b89cf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vite/src/node/ssr/ssrModuleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,18 @@ async function instantiateModule(
ssrImportKey,
ssrDynamicImportKey,
ssrExportAllKey,
'"use strict";' + result.code + `\n//# sourceURL=${mod.url}`,
`"use strict";\n${result.code}\n//# ${
result.map && result.map.mappings
? `sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(
JSON.stringify({
...result.map,
mappings: `;;;${result.map.mappings}`,
}),
).toString(
'base64',
)}\n//# sourceURL=vite-internal:///./${mod.url.replace(/^\/+/, '')}`
: `sourceURL=${mod.url}`
}`,
)
await initModule(
context.global,
Expand Down

0 comments on commit 95b89cf

Please sign in to comment.