From 21731b238006bdfe63221dad328aa01c8f16dbdc Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Mon, 22 Feb 2021 16:22:04 -0500 Subject: [PATCH] implement ember module plugin deprecation for new 3.26-beta --- lib/ember-plugins.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/ember-plugins.js b/lib/ember-plugins.js index 275cfb83..c2b30b1b 100644 --- a/lib/ember-plugins.js +++ b/lib/ember-plugins.js @@ -60,9 +60,13 @@ function _getEmberModulesAPIPolyfill(appRoot, config) { if (_emberVersionRequiresModulesAPIPolyfill()) { const ignore = _getEmberModulesAPIIgnore(appRoot, config); + const useEmberModule = _shouldDeprecateGlobalEmber(appRoot); return [ - [require.resolve("babel-plugin-ember-modules-api-polyfill"), { ignore }], + [ + require.resolve("babel-plugin-ember-modules-api-polyfill"), + { ignore, useEmberModule }, + ], ]; } } @@ -80,6 +84,16 @@ function _shouldIgnoreJQuery(appRoot) { return pkg && semver.gt(pkg.version, "0.6.0"); } +function _shouldDeprecateGlobalEmber(appRoot) { + let packagePath = resolvePackagePath("ember-source", appRoot); + if (packagePath === null) { + return false; + } + + let pkg = require(packagePath); + return pkg && semver.get(pkg.version, "3.26.0-beta.1"); +} + function _emberDataVersionRequiresPackagesPolyfill(appRoot) { let packagePath = resolvePackagePath("ember-data", appRoot); if (packagePath === null) { @@ -128,7 +142,7 @@ function _getEmberDataPackagesPolyfill(appRoot, config) { function _getModuleResolutionPlugins(config) { if (!config.disableModuleResolution) { const resolvePath = require("../lib/relative-module-paths") - .resolveRelativeModulePath; + .resolveRelativeModulePath; return [ [require.resolve("babel-plugin-module-resolver"), { resolvePath }], [