From e134738ae5dae12a5ab5132d122a380c85bbdfbc Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:40:06 -0500 Subject: [PATCH 1/3] Make the transform function (which uses @babel/standalone) compatible with vite --- packages/ember-repl/addon/src/compile/formats/gjs/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts index 5262245ee..8daa3c91b 100644 --- a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts +++ b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts @@ -89,7 +89,9 @@ async function transform( name: string, options: any = {} ): Promise> { - 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 babel = (await import('@babel/standalone')).default as Babel; return babel.transform(intermediate, { filename: `${name}.js`, From 8cf9077eee78756f10068f1ece833e050eac3f6f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:57:31 -0500 Subject: [PATCH 2/3] Make the transform function (which uses @babel/standalone) compatible with vite --- packages/ember-repl/addon/src/compile/formats/gjs/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts index 8daa3c91b..855ef2fc5 100644 --- a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts +++ b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts @@ -91,7 +91,9 @@ async function transform( ): Promise> { // @babel/standalone is a CJS module.... // so we have to use the default export (which is all the exports) - let babel = (await import('@babel/standalone')).default as Babel; + let maybeBabel = (await import('@babel/standalone')) as Babel; + // Handle difference between vite and webpack in consuming projects... + let babel = 'default' in maybeBabel ? maybeBabel.default : maybeBabel; return babel.transform(intermediate, { filename: `${name}.js`, From 18e9e3e0f86e7f53a4ae383f792cbf2bcea7d356 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:58:07 -0500 Subject: [PATCH 3/3] Make the transform function (which uses @babel/standalone) compatible with vite --- packages/ember-repl/addon/src/compile/formats/gjs/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts index 855ef2fc5..886126253 100644 --- a/packages/ember-repl/addon/src/compile/formats/gjs/index.ts +++ b/packages/ember-repl/addon/src/compile/formats/gjs/index.ts @@ -91,9 +91,9 @@ async function transform( ): Promise> { // @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 Babel; + let maybeBabel = (await import('@babel/standalone')) as any; // Handle difference between vite and webpack in consuming projects... - let babel = 'default' in maybeBabel ? maybeBabel.default : maybeBabel; + let babel: Babel = 'default' in maybeBabel ? maybeBabel.default : maybeBabel; return babel.transform(intermediate, { filename: `${name}.js`,