Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never emit Ember global on ember versions that don't support it #515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/babel-options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ function _getDebugMacroPlugins(config, project) {

if (_emberVersionRequiresModulesAPIPolyfill(project)) {
useModulesVersion = false;
} else if (addonOptions.compileModules === false) {
} else if (addonOptions.compileModules === false && _emberVersionSupportsEmberGlobal(project)) {
// we have to use the global form when not compiling modules, because it is often used
// in the context of an `app.import` where there is no wrapped in an AMD module
//
// However, you can opt out of this behavior by explicitly specifying `disableDebugTooling`
useModulesVersion = disableDebugTooling === false;
} else {
useModulesVersion = true;
Expand Down Expand Up @@ -141,6 +139,16 @@ function _emberVersionRequiresModulesAPIPolyfill(project) {
return result;
}

function _emberVersionSupportsEmberGlobal(project) {
let checker = new VersionChecker(project).for("ember-source", "npm");
if (!checker.exists()) {
return true;
}
let result = checker.lt("4.0.0-alpha.1");

return result;
}

function _emberDataVersionRequiresPackagesPolyfill(project) {
let checker = new VersionChecker(project);
let dep = checker.for("ember-data");
Expand All @@ -165,7 +173,7 @@ function _getEmberModulesAPIPolyfill(config, parent, project) {

if (_emberVersionRequiresModulesAPIPolyfill(project)) {
useModulesVersion = false;
} else if (addonOptions.compileModules === false) {
} else if (addonOptions.compileModules === false && _emberVersionSupportsEmberGlobal(project)) {
// we have to use the global form when not compiling modules, because it is often used
// in the context of an `app.import` where there is no wrapped in an AMD module
//
Expand Down
Loading