Skip to content

Commit 127ade1

Browse files
author
Robert Jackson
authored
Merge pull request #402 from babel/fix-compileModules-false-on-ember-3.27
2 parents 917f86b + e20c0e4 commit 127ade1

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

lib/babel-options-util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ function _getDebugMacroPlugins(config, project) {
8585
},
8686
};
8787

88-
if (_emberVersionRequiresModulesAPIPolyfill(project)) {
88+
// we have to use the global form when not compiling modules, because it is often used
89+
// in the context of an `app.import` where there is no wrapped in an AMD module
90+
if (addonOptions.compileModules === false || _emberVersionRequiresModulesAPIPolyfill(project)) {
8991
emberDebugOptions.externalizeHelpers = {
9092
global: "Ember",
9193
};
@@ -420,7 +422,7 @@ function _shouldIncludeDecoratorPlugins(config) {
420422
* be deduped as part of `ember-engines`. The reason this is important is because
421423
* `ember-engines` dedupe is _stateful_ so it's possible for `ember-cli-typescript`
422424
* to not be part of the addons array when `ember-cli-babel` is running.
423-
*
425+
*
424426
* For more info on `ember-engines` dedupe logic:
425427
* https://github.com/ember-engines/ember-engines/blob/master/packages/ember-engines/lib/utils/deeply-non-duplicated-addon.js#L35
426428
*

node-tests/addon-test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,65 @@ describe('ember-cli-babel', function() {
457457
"foo.js": `define("foo", ["@ember/debug"], function (_debug) {\n "use strict";\n\n (true && !(isNotBad()) && (0, _debug.assert)('stuff here', isNotBad()));\n});`,
458458
});
459459
}));
460+
461+
it("when transpiling with compileModules: false, it should use Ember global even on Ember 3.27+", co.wrap(function* () {
462+
process.env.EMBER_ENV = 'development';
463+
464+
dependencies[
465+
"ember-source"
466+
] = POST_EMBER_MODULE_IMPORTS_VERSION;
467+
input.write(
468+
buildEmberSourceFixture(POST_EMBER_MODULE_IMPORTS_VERSION)
469+
);
470+
471+
input.write({
472+
app: {
473+
"foo.js": stripIndent`
474+
import { assert } from '@ember/debug';
475+
assert('stuff here', isNotBad());
476+
`,
477+
"bar.js": stripIndent`
478+
import { deprecate } from '@ember/debug';
479+
deprecate(
480+
'foo bar baz',
481+
false,
482+
{
483+
id: 'some-id',
484+
until: '1.0.0',
485+
}
486+
);
487+
`,
488+
"baz.js": stripIndent`
489+
import { deprecate } from '@ember/application/deprecations';
490+
deprecate(
491+
'foo bar baz',
492+
false,
493+
{
494+
id: 'some-id',
495+
until: '1.0.0',
496+
}
497+
);
498+
`,
499+
},
500+
});
501+
502+
subject = this.addon.transpileTree(input.path('app'), {
503+
'ember-cli-babel': {
504+
compileModules: false,
505+
}
506+
});
507+
output = createBuilder(subject);
508+
509+
yield output.build();
510+
511+
expect(
512+
output.read()
513+
).to.deep.equal({
514+
"bar.js": `(true && !(false) && Ember.deprecate('foo bar baz', false, {\n id: 'some-id',\n until: '1.0.0'\n}));`,
515+
"baz.js": `(true && !(false) && Ember.deprecate('foo bar baz', false, {\n id: 'some-id',\n until: '1.0.0'\n}));`,
516+
"foo.js": `(true && !(isNotBad()) && Ember.assert('stuff here', isNotBad()));`,
517+
});
518+
}));
460519
});
461520

462521
describe('in production', function() {

0 commit comments

Comments
 (0)