Skip to content

Commit

Permalink
feat: EmberData Packages Polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jan 29, 2020
1 parent 442ec64 commit 15574e4
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 411 deletions.
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ module.exports = {
userPlugins,
this._getDebugMacroPlugins(config),
this._getEmberModulesAPIPolyfill(config),
this._getEmberDataPackagesPolyfill(config),
shouldCompileModules && this._getModulesPlugin(),
userPostTransformPlugins
).filter(Boolean);
Expand Down Expand Up @@ -444,6 +445,16 @@ module.exports = {
}
},

_getEmberDataPackagesPolyfill(config) {
let addonOptions = config['ember-cli-babel'] || {};

if (addonOptions.disableEmberDataPackagesPolyfill) { return; }

if (this._emberDataVersionRequiresPackagesPolyfill()) {
return [[require.resolve('babel-plugin-ember-data-packages-polyfill')]];
}
},

_getPresetEnv(config) {
let options = config.options;

Expand Down Expand Up @@ -511,6 +522,20 @@ module.exports = {
return true;
},

_emberDataVersionRequiresPackagesPolyfill() {
let checker = new VersionChecker(this.project);
let dep = checker.for('ember-data');
let hasEmberData = dep.exists();

if (hasEmberData) {
if (!dep.version) {
throw new Error('EmberData missing version');
}
return semver.lt(dep.version, '3.12.0-alpha.0');
}
return false;
},

_getEmberModulesAPIBlacklist() {
const blacklist = {
'@ember/debug': ['assert', 'deprecate', 'warn'],
Expand Down
Loading

0 comments on commit 15574e4

Please sign in to comment.