Skip to content

Commit

Permalink
Assume source maps exist in node-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Apr 4, 2024
1 parent f6c9317 commit 08acc22
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/node-loader/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ export function createLoader(options) {
if (url.protocol === 'file:' && regex.test(url.pathname)) {
const value = await fs.readFile(url)
const file = await process(new VFile({value, path: url}))
let source = String(file)
/* c8 ignore start -- not sure how to test this. */
if (file.map) {
source +=

return {
format: 'module',
shortCircuit: true,
source:
String(file) +
'\n//# sourceMappingURL=data:application/json;base64,' +
Buffer.from(JSON.stringify(file.map)).toString('base64') +
'\n'
}
/* c8 ignore stop */

return {format: 'module', shortCircuit: true, source}
}

return nextLoad(href, context)
Expand Down

0 comments on commit 08acc22

Please sign in to comment.