Skip to content

Commit

Permalink
Fix old node
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 6, 2022
1 parent 3788468 commit 0232e1f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/babel-core/src/config/files/import-meta-resolve.ts
Expand Up @@ -11,14 +11,16 @@ try {

// import.meta.resolve is only available in ESM, but this file is compiled to CJS.
// We can extract ir using dynamic import.
const resolveP =
import_ && import_("data:text/javascript,export default import.meta.resolve");
const resolveP = import_
? import_("data:text/javascript,export default import.meta.resolve").then(
// Since import.meta.resolve is unstable and only available when
// using the --experimental-import-meta-resolve flag, we almost
// always use the polyfill for now.
m => m.default || polyfill,
() => polyfill,
)
: Promise.resolve(polyfill);

export default async function getImportMetaResolve(): Promise<
ImportMeta["resolve"]
> {
// Since import.meta.resolve is unstable and only available when
// using the --experimental-import-meta-resolve flag, we almost
// always use the polyfill for now.
return (await resolveP).default || polyfill;
export default function getImportMetaResolve(): Promise<ImportMeta["resolve"]> {
return resolveP;
}

0 comments on commit 0232e1f

Please sign in to comment.