From 66cb727db33987262757c5dd846bfe27bcf8099f Mon Sep 17 00:00:00 2001 From: Clement Yan Date: Tue, 28 Feb 2023 00:23:12 +0800 Subject: [PATCH] fix: resolve @babel/plugin-syntax-dynamic-import from @babel/preset-env --- src/transpiler/babel.ts | 3 ++- src/util/path/path-util.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/transpiler/babel.ts b/src/transpiler/babel.ts index ba01a4da..c77b7cc1 100644 --- a/src/transpiler/babel.ts +++ b/src/transpiler/babel.ts @@ -52,7 +52,8 @@ export function getForcedBabelOptions({cwd}: GetForcedBabelOptionsOptions): Tran sourceType: "module", plugins: [ // Needed to make babel understand dynamic imports - resolveModule("@babel/plugin-syntax-dynamic-import") + // TODO: Add @babel/plugin-syntax-dynamic-import as an optional peer for next major + resolveModule("@babel/plugin-syntax-dynamic-import", resolveModule("@babel/preset-env")) ] }; } diff --git a/src/util/path/path-util.ts b/src/util/path/path-util.ts index 65ffde52..e87b87f4 100644 --- a/src/util/path/path-util.ts +++ b/src/util/path/path-util.ts @@ -20,7 +20,7 @@ import {ensureArray} from "../ensure-array/ensure-array.js"; import {createRequire} from "module"; // Until import.meta.resolve becomes stable, we'll have to do this instead -export const resolveModule = createRequire(import.meta.url).resolve; +export const resolveModule = (id: string, from: string = import.meta.url) => createRequire(from).resolve(id); export function isTypeScriptLib(p: string): boolean { return p.startsWith(`lib.`) && p.endsWith(D_TS_EXTENSION);