From 08acc226ff49e8d77185ee1a90e2885c08204ded Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 4 Apr 2024 16:14:49 +0200 Subject: [PATCH] Assume source maps exist in node-loader --- packages/node-loader/lib/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/node-loader/lib/index.js b/packages/node-loader/lib/index.js index 6bcca33d6..4acd3dfbd 100644 --- a/packages/node-loader/lib/index.js +++ b/packages/node-loader/lib/index.js @@ -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)