Skip to content

Commit

Permalink
Merge pull request #161 from rwjblue/avoid-issues-with-ember-debug
Browse files Browse the repository at this point in the history
Avoid conflicting transforms for @ember/debug.
  • Loading branch information
rwjblue committed Jul 6, 2017
2 parents 403b4bf + d632119 commit 6ac2390
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 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': ['assert', 'deprecate', 'warn']} }]];
}
},

Expand Down
45 changes: 43 additions & 2 deletions node-tests/addon-test.js
Expand Up @@ -96,7 +96,8 @@ describe('ember-cli-babel', function() {

it("should replace imports by default", co.wrap(function* () {
input.write({
"foo.js": `import Component from '@ember/component';`
"foo.js": `import Component from '@ember/component';`,
"app.js": `import Application from '@ember/application';`
});

subject = this.addon.transpileTree(input.path());
Expand All @@ -107,8 +108,48 @@ describe('ember-cli-babel', function() {
expect(
output.read()
).to.deep.equal({
"foo.js": `define('foo', [], function () {\n 'use strict';\n\n var Component = Ember.Component;\n});`
"foo.js": `define('foo', [], function () {\n 'use strict';\n\n var Component = Ember.Component;\n});`,
"app.js": `define('app', [], function () {\n 'use strict';\n\n var Application = Ember.Application;\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');
}));

it("allows @ember/debug to be consumed via both debug-macros and ember-modules-api-polyfill", co.wrap(function* () {
input.write({
"foo.js": stripIndent`
import { assert, inspect } 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.not.include('@ember/debug');
expect(contents).to.include('function _asyncToGenerator');
expect(contents).to.include('var inspect = Ember.inspect;');
expect(contents).to.not.include('assert');
}));
});

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -36,8 +36,8 @@
},
"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-debug-macros": "^0.1.11",
"babel-plugin-ember-modules-api-polyfill": "^1.4.1",
"babel-plugin-transform-es2015-modules-amd": "^6.24.0",
"babel-polyfill": "^6.16.0",
"babel-preset-env": "^1.5.1",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Expand Up @@ -432,15 +432,15 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"

babel-plugin-debug-macros@^0.1.1, babel-plugin-debug-macros@^0.1.10, babel-plugin-debug-macros@^0.1.6:
version "0.1.10"
resolved "https://registry.yarnpkg.com/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.1.10.tgz#dd077ad6e1cc0a8f9bbc6405c561392ebfc9a01c"
babel-plugin-debug-macros@^0.1.1, babel-plugin-debug-macros@^0.1.11, babel-plugin-debug-macros@^0.1.6:
version "0.1.11"
resolved "https://registry.yarnpkg.com/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.1.11.tgz#6c562bf561fccd406ce14ab04f42c218cf956605"
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.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-1.4.1.tgz#2b05e1b37e492449319a9cc2bdca460cda70b5b1"
dependencies:
ember-rfc176-data "^0.1.0"

Expand Down

0 comments on commit 6ac2390

Please sign in to comment.