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 f305de0 commit ead9fd6
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 335 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface EmberCLIBabelConfig {
disableDebugTooling?: boolean;
disablePresetEnv?: boolean;
disableEmberModulesAPIPolyfill?: boolean;
disableEmberDataPackagesPolyfill?: boolean;
disableDecoratorTransforms?: boolean;
extensions?: string[];
};
Expand Down
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 ead9fd6

Please sign in to comment.