Skip to content

Commit

Permalink
Merge pull request #1856 from NullVoxPopuli/make-babel-standalone-vit…
Browse files Browse the repository at this point in the history
…e-compatible

Make the transform function (which uses @babel/standalone) compatible…
  • Loading branch information
NullVoxPopuli authored Nov 5, 2024
2 parents 65d758f + 18e9e3e commit 0e4d107
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ember-repl/addon/src/compile/formats/gjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ async function transform(
name: string,
options: any = {}
): Promise<ReturnType<Babel['transform']>> {
let babel = (await import('@babel/standalone')) as Babel;
// @babel/standalone is a CJS module....
// so we have to use the default export (which is all the exports)
let maybeBabel = (await import('@babel/standalone')) as any;
// Handle difference between vite and webpack in consuming projects...
let babel: Babel = 'default' in maybeBabel ? maybeBabel.default : maybeBabel;

return babel.transform(intermediate, {
filename: `${name}.js`,
Expand Down

0 comments on commit 0e4d107

Please sign in to comment.