From 9ad7cc8ea6f2f41d964618e1006d8bab5968dde1 Mon Sep 17 00:00:00 2001 From: Marine Dunstetter Date: Thu, 4 Jul 2024 14:42:41 +0200 Subject: [PATCH] feat(new babel config): in app-template, move the default ember-cli-babel config from generated config to the app config --- packages/compat/src/compat-app.ts | 17 +------- tests/app-template/babel.config.cjs | 61 ++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/packages/compat/src/compat-app.ts b/packages/compat/src/compat-app.ts index 963df0d97..1f2a87833 100644 --- a/packages/compat/src/compat-app.ts +++ b/packages/compat/src/compat-app.ts @@ -225,21 +225,8 @@ export default class CompatApp { @Memoize() babelConfig(): TransformOptions { - // this finds all the built-in babel configuration that comes with ember-cli-babel - const babelAddon = (this.legacyEmberAppInstance.project as any).findAddonByName('ember-cli-babel'); - const babelConfig = babelAddon.buildBabelOptions({ - 'ember-cli-babel': { - ...this.legacyEmberAppInstance.options['ember-cli-babel'], - includeExternalHelpers: true, - compileModules: false, - disableDebugTooling: false, - disablePresetEnv: false, - disableEmberModulesAPIPolyfill: false, - }, - }); - - let plugins = babelConfig.plugins as any[]; - let presets = babelConfig.presets; + let plugins: any[] = []; + let presets: any[] = []; // this finds any custom babel configuration that's on the app (either // because the app author explicitly added some, or because addons have diff --git a/tests/app-template/babel.config.cjs b/tests/app-template/babel.config.cjs index b3db8c1c0..6c14ca103 100644 --- a/tests/app-template/babel.config.cjs +++ b/tests/app-template/babel.config.cjs @@ -4,8 +4,65 @@ const { addLegacyConfig } = require("@embroider/compat"); let config = { babelrc: false, highlightCode: false, - plugins: [], -} + plugins: [ + ["@babel/plugin-proposal-decorators", { legacy: true }], + ["@babel/plugin-proposal-private-property-in-object", { loose: false }], + ["@babel/plugin-proposal-private-methods", { loose: false }], + ["@babel/plugin-proposal-class-properties", { loose: false }], + [ + require.resolve("babel-plugin-debug-macros"), + { + flags: [ + { + source: "@glimmer/env", + flags: { + DEBUG: true, + CI: false, + }, + }, + ], + debugTools: { + isDebug: true, + source: "@ember/debug", + assertPredicateIndex: 1, + }, + externalizeHelpers: { + module: "@ember/debug", + }, + }, + "@ember/debug stripping", + ], + [ + require.resolve("babel-plugin-debug-macros"), + { + externalizeHelpers: { + module: "@ember/application/deprecations", + }, + debugTools: { + isDebug: true, + source: "@ember/application/deprecations", + assertPredicateIndex: 1, + }, + }, + "@ember/application/deprecations stripping", + ], + ], + presets: [ + [ + "@babel/preset-env", + { + modules: false, + targets: { + browsers: [ + "last 1 Chrome versions", + "last 1 Firefox versions", + "last 1 Safari versions", + ], + }, + }, + ], + ], +}; // addLegacyConfig assign your config to the legacy config from classic (v1) addons module.exports = addLegacyConfig(config);