-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use ember-cli-babel-plugin-helpers
Also update addon's ember-cli-babel version to latest
- Loading branch information
Showing
3 changed files
with
1,048 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
const { hasPlugin, addPlugin } = require('ember-cli-babel-plugin-helpers'); | ||
|
||
module.exports = { | ||
name: require('./package').name, | ||
|
||
included() { | ||
this._super.included.apply(this, arguments); | ||
|
||
this.patchEmberModulesAPIPolyfill(); | ||
this.addBabelPlugin(); | ||
}, | ||
|
||
patchEmberModulesAPIPolyfill() { | ||
const babel = this.parent.findOwnAddonByName | ||
? this.parent.findOwnAddonByName('ember-cli-babel') // parent is an addon | ||
: this.parent.findAddonByName('ember-cli-babel'); // parent is an app | ||
addBabelPlugin() { | ||
let app = this._findHost(); | ||
|
||
if (babel.__CachedDecoratorPolyfillApplied) return; | ||
babel.__CachedDecoratorPolyfillApplied = true; | ||
|
||
const { _getEmberModulesAPIPolyfill } = babel; | ||
|
||
babel._getEmberModulesAPIPolyfill = function (...args) { | ||
const plugins = _getEmberModulesAPIPolyfill.apply(this, args); | ||
if (!plugins) return; | ||
|
||
return [[resolve(__dirname, './lib/transpile-modules.js')], ...plugins]; | ||
}; | ||
if (!hasPlugin(app, 'ember-cache-decorator-polyfill')) { | ||
addPlugin(app, resolve(__dirname, './lib/transpile-modules.js')); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.