Skip to content

Commit

Permalink
Merge pull request #402 from babel/fix-compileModules-false-on-ember-…
Browse files Browse the repository at this point in the history
…3.27
  • Loading branch information
rwjblue committed May 6, 2021
2 parents 917f86b + e20c0e4 commit 127ade1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/babel-options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ function _getDebugMacroPlugins(config, project) {
},
};

if (_emberVersionRequiresModulesAPIPolyfill(project)) {
// we have to use the global form when not compiling modules, because it is often used
// in the context of an `app.import` where there is no wrapped in an AMD module
if (addonOptions.compileModules === false || _emberVersionRequiresModulesAPIPolyfill(project)) {
emberDebugOptions.externalizeHelpers = {
global: "Ember",
};
Expand Down Expand Up @@ -420,7 +422,7 @@ function _shouldIncludeDecoratorPlugins(config) {
* be deduped as part of `ember-engines`. The reason this is important is because
* `ember-engines` dedupe is _stateful_ so it's possible for `ember-cli-typescript`
* to not be part of the addons array when `ember-cli-babel` is running.
*
*
* For more info on `ember-engines` dedupe logic:
* https://github.com/ember-engines/ember-engines/blob/master/packages/ember-engines/lib/utils/deeply-non-duplicated-addon.js#L35
*
Expand Down
59 changes: 59 additions & 0 deletions node-tests/addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,65 @@ describe('ember-cli-babel', function() {
"foo.js": `define("foo", ["@ember/debug"], function (_debug) {\n "use strict";\n\n (true && !(isNotBad()) && (0, _debug.assert)('stuff here', isNotBad()));\n});`,
});
}));

it("when transpiling with compileModules: false, it should use Ember global even on Ember 3.27+", co.wrap(function* () {
process.env.EMBER_ENV = 'development';

dependencies[
"ember-source"
] = POST_EMBER_MODULE_IMPORTS_VERSION;
input.write(
buildEmberSourceFixture(POST_EMBER_MODULE_IMPORTS_VERSION)
);

input.write({
app: {
"foo.js": stripIndent`
import { assert } from '@ember/debug';
assert('stuff here', isNotBad());
`,
"bar.js": stripIndent`
import { deprecate } from '@ember/debug';
deprecate(
'foo bar baz',
false,
{
id: 'some-id',
until: '1.0.0',
}
);
`,
"baz.js": stripIndent`
import { deprecate } from '@ember/application/deprecations';
deprecate(
'foo bar baz',
false,
{
id: 'some-id',
until: '1.0.0',
}
);
`,
},
});

subject = this.addon.transpileTree(input.path('app'), {
'ember-cli-babel': {
compileModules: false,
}
});
output = createBuilder(subject);

yield output.build();

expect(
output.read()
).to.deep.equal({
"bar.js": `(true && !(false) && Ember.deprecate('foo bar baz', false, {\n id: 'some-id',\n until: '1.0.0'\n}));`,
"baz.js": `(true && !(false) && Ember.deprecate('foo bar baz', false, {\n id: 'some-id',\n until: '1.0.0'\n}));`,
"foo.js": `(true && !(isNotBad()) && Ember.assert('stuff here', isNotBad()));`,
});
}));
});

describe('in production', function() {
Expand Down

0 comments on commit 127ade1

Please sign in to comment.