From cdfd61ac567479def66e4b840f5c55a25189ee98 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 8 Mar 2022 11:27:46 +0100 Subject: [PATCH] Fix ESM loader for Node 16- and React 18 Related-to: https://github.com/wooorm/xdm/commit/a778c57. Related-to: https://github.com/mdx-js/mdx/pull/1808. --- lib/integration/node.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/integration/node.js b/lib/integration/node.js index ca0ea28..1228bca 100644 --- a/lib/integration/node.js +++ b/lib/integration/node.js @@ -88,9 +88,15 @@ export function createLoader(options = {}) { } const file = await process(new VFile({value, path: new URL(context.url)})) + let source = String(file) + + if (fixRuntimeWithoutExportMap) { + source = String(file).replace(/\/jsx-runtime(?=["'])/g, '$&.js') + } + // V8 on Erbium. /* c8 ignore next 2 */ - return {source: String(file).replace(/\/jsx-runtime(?=["'])/g, '$&.js')} + return {source} } /* c8 ignore end */ }