From d1544eec92a5ad489972f5b633163de4e7ef032c Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:46:57 -0400 Subject: [PATCH] Try to get ember booting --- lib/ember-plugins.js | 38 +++++++++++++++++++++++--------------- lib/get-babel-options.js | 3 ++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/ember-plugins.js b/lib/ember-plugins.js index 71cd019..625a1ba 100644 --- a/lib/ember-plugins.js +++ b/lib/ember-plugins.js @@ -147,8 +147,8 @@ function _getEmberDataPackagesPolyfill(appRoot, config) { function _getModuleResolutionPlugins(config) { if (!config.disableModuleResolution) { - const resolvePath = require("../lib/relative-module-paths") - .resolveRelativeModulePath; + const resolvePath = + require("../lib/relative-module-paths").resolveRelativeModulePath; return [ [require.resolve("babel-plugin-module-resolver"), { resolvePath }], [ @@ -162,16 +162,16 @@ function _getModuleResolutionPlugins(config) { function _getProposalDecoratorsAndClassPlugins(config) { if (!config.shouldIgnoreDecoratorAndClassPlugins) { return [ - /** - * Required for apps to use `@ember/template-compliation` - * for transforming templates from babel-plugin-ember-template-compilation - * which shipped in ember-cli-htmlbars 6.2 - * - * Normally this plugin wouldn't be required because the feature has shipped - * in all browsers, but because we have legacy decorators, and - * legacy decorators do not support parsing the static block syntax, - * we need to compile it away. - */ + /** + * Required for apps to use `@ember/template-compliation` + * for transforming templates from babel-plugin-ember-template-compilation + * which shipped in ember-cli-htmlbars 6.2 + * + * Normally this plugin wouldn't be required because the feature has shipped + * in all browsers, but because we have legacy decorators, and + * legacy decorators do not support parsing the static block syntax, + * we need to compile it away. + */ ["@babel/plugin-transform-class-static-block"], ["@babel/plugin-proposal-decorators", { legacy: true }], ["@babel/plugin-proposal-class-properties"], @@ -180,9 +180,15 @@ function _getProposalDecoratorsAndClassPlugins(config) { } function _getImportMetaEnv(config) { + const isProduction = process.env.EMBER_ENV === "production"; + const isDebug = !isProduction; + return [ - ["module:@import-meta-env/babel", { env: { DEV: isDebug, PROD: !isDebug }}], - ] + [ + "module:@import-meta-env/babel", + { env: { DEV: isDebug, PROD: isProduction } }, + ], + ]; } /** @@ -204,6 +210,7 @@ function _getImportMetaEnv(config) { module.exports = function (appRoot, config = {}) { return [] .concat( + _getImportMetaEnv(config), _getProposalDecoratorsAndClassPlugins(config), _getDebugMacroPlugins(appRoot), _getEmberModulesAPIPolyfill(appRoot, config), @@ -217,4 +224,5 @@ module.exports.getDebugMacroPlugins = _getDebugMacroPlugins; module.exports.getEmberModulesAPIPolyfill = _getEmberModulesAPIPolyfill; module.exports.getEmberDataPackagesPolyfill = _getEmberDataPackagesPolyfill; module.exports.getModuleResolutionPlugins = _getModuleResolutionPlugins; -module.exports.getProposalDecoratorsAndClassPlugins = _getProposalDecoratorsAndClassPlugins; +module.exports.getProposalDecoratorsAndClassPlugins = + _getProposalDecoratorsAndClassPlugins; diff --git a/lib/get-babel-options.js b/lib/get-babel-options.js index 35398a4..ecd862a 100644 --- a/lib/get-babel-options.js +++ b/lib/get-babel-options.js @@ -48,11 +48,12 @@ module.exports = function getBabelOptions(config, appInstance) { ); } + userPlugins = _addImportMetaEnv(userPlugins.slice(), parent, project), + options.plugins = [] .concat( shouldIncludeHelpers && _getHelpersPlugin(project), userPlugins, - _addImportMetaEnv(userPlugins.slice(), parent, project), _getDebugMacroPlugins(config, project), _getEmberModulesAPIPolyfill(config, parent, project), _getEmberDataPackagesPolyfill(config, parent),