From 1b02c091013459355f4549e400fead7b11120be3 Mon Sep 17 00:00:00 2001 From: janwirth Date: Tue, 23 Nov 2021 12:32:22 +0100 Subject: [PATCH] Fix #5 --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c421292..33e74dd 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,8 @@ const babelCore = require("@babel/core"); const Module = require("module").Module; const fs = require("fs"); -function transpile(code) { - return babelCore.transformSync(code, { +function transpile(code, filename) { + return babelCore.transformSync(code, {filename, plugins: [ require.resolve("@babel/plugin-proposal-export-namespace-from"), require.resolve("@babel/plugin-transform-modules-commonjs") @@ -28,7 +28,7 @@ module.exports = { if (error.code === "ERR_REQUIRE_ESM") { // NOTE: We completely bypass the default internal loader, as we cannot patch the `type: module` check out of that. Please open a PR if you have a better solution! let code = fs.readFileSync(filename, "utf8"); - let transpiledCode = transpile(code); + let transpiledCode = transpile(code, filename); mod._compile(transpiledCode.code, filename); } else { throw error; -- 2.40.1