From 5450922a79364c4ac7f092d9c5ceae717de8dde9 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Wed, 11 Sep 2024 14:04:52 +0100 Subject: [PATCH] update to user-controlled babel file --- files/babel.config.cjs | 53 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/files/babel.config.cjs b/files/babel.config.cjs index 22317a3..3b195ef 100644 --- a/files/babel.config.cjs +++ b/files/babel.config.cjs @@ -1,17 +1,40 @@ -let config; +const { + babelCompatSupport, + templateCompatSupport, +} = require('@embroider/compat/babel'); -// TODO - remove this once we have the better solution for injecting stage1 babel config into a real config file -// this is needed because there are things (like ember-composible-helpers) that are now finding our babel config during -// their stage1 build and historically they will never (99% of the time) have found any babel config. -// we might need to keep something like this so that prebuild will never apply babel configs during stage1 i.e. a util -// function that wraps your whole babel config -if ( - process.env.EMBROIDER_PREBUILD || - process.env.EMBROIDER_TEST_SETUP_FORCE === 'classic' -) { - config = {}; -} else { - config = require('./node_modules/.embroider/_babel_config_'); -} +module.exports = { + plugins: [ + [ + 'babel-plugin-ember-template-compilation', + { + compilerPath: 'ember-source/dist/ember-template-compiler.js', + enableLegacyModules: [ + 'ember-cli-htmlbars', + 'ember-cli-htmlbars-inline-precompile', + 'htmlbars-inline-precompile', + ], + transforms: [...templateCompatSupport()], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { import: require.resolve('decorator-transforms/runtime') }, + }, + ], + [ + '@babel/plugin-transform-runtime', + { + absoluteRuntime: __dirname, + useESModules: true, + regenerator: false, + }, + ], + ...babelCompatSupport(), + ], -module.exports = config; + generatorOpts: { + compact: false, + }, +};