Skip to content

Commit

Permalink
Avoid conflicting transforms for @ember/debug.
Browse files Browse the repository at this point in the history
When both babel-plugin-debug-macros and babel-plugin-ember-modules-api-polyfill
attempt to replace `import { assert } from '@ember/assert';` the interaction
between the two also removes any helpers that are injected by other parts of
the transpilation (e.g. `_classCallCheck` or `_asyncToGenerator`) therefore
making the transpiled output fail at runtime.

This updates babel-plugin-ember-modules-api-polyfill to a version that allows
specifying a blacklist so that we can avoid this conflict.
  • Loading branch information
rwjblue committed Jul 3, 2017
1 parent 403b4bf commit 3550cb9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -260,7 +260,7 @@ module.exports = {
if (this._emberVersionRequiresModulesAPIPolyfill()) {
const ModulesAPIPolyfill = require('babel-plugin-ember-modules-api-polyfill');

return [[ModulesAPIPolyfill]];
return [[ModulesAPIPolyfill, { blacklist: ['@ember/debug'] }]];
}
},

Expand Down
18 changes: 18 additions & 0 deletions node-tests/addon-test.js
Expand Up @@ -110,6 +110,24 @@ describe('ember-cli-babel', function() {
"foo.js": `define('foo', [], function () {\n 'use strict';\n\n var Component = Ember.Component;\n});`
});
}));

it("does not remove _asyncToGenerator helper function when used together with debug-macros", co.wrap(function* () {
input.write({
"foo.js": stripIndent`
import { assert } from '@ember/debug';
export default { async foo() { await this.baz; }}
`
});

subject = this.addon.transpileTree(input.path());
output = createBuilder(subject);

yield output.build();

let contents = output.read()['foo.js'];

expect(contents).to.include('function _asyncToGenerator');
}));
});

describe('debug macros', function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"amd-name-resolver": "0.0.6",
"babel-plugin-debug-macros": "^0.1.10",
"babel-plugin-ember-modules-api-polyfill": "^1.2.0",
"babel-plugin-ember-modules-api-polyfill": "^1.3.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.0",
"babel-polyfill": "^6.16.0",
"babel-preset-env": "^1.5.1",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -438,9 +438,9 @@ babel-plugin-debug-macros@^0.1.1, babel-plugin-debug-macros@^0.1.10, babel-plugi
dependencies:
semver "^5.3.0"

babel-plugin-ember-modules-api-polyfill@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-1.2.0.tgz#f99f26040d4d29ae42fdc333553198940d59cf46"
babel-plugin-ember-modules-api-polyfill@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-1.3.0.tgz#0b32e3dfdee47f26942968f49d2d67ba85346ae3"
dependencies:
ember-rfc176-data "^0.1.0"

Expand Down

0 comments on commit 3550cb9

Please sign in to comment.