Skip to content

Commit

Permalink
feat(new babel config): in app-template, move the default ember-cli-b…
Browse files Browse the repository at this point in the history
…abel config from generated config to the app config
  • Loading branch information
BlueCutOfficial committed Jul 4, 2024
1 parent ca08aaf commit 9ad7cc8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
17 changes: 2 additions & 15 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 59 additions & 2 deletions tests/app-template/babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 9ad7cc8

Please sign in to comment.