Skip to content

Commit 1317065

Browse files
wagenetrunspired
andauthored
Fix build for 4.0 (#396)
* Fix build for 4.0 * compat for <= 3.20 ember-source Co-authored-by: Chris Thoburn <[email protected]>
1 parent f8ba113 commit 1317065

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

index.js

+32-36
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ module.exports = {
1919
return '';
2020
},
2121

22-
// Borrowed from ember-cli-babel
23-
_emberVersionRequiresModulesAPIPolyfill() {
24-
let checker = this.checker.for('ember-source', 'npm');
22+
// Borrowed from ember-cli-babel
23+
_emberVersionRequiresModulesAPIPolyfill() {
24+
let checker = this.checker.for('ember-source', 'npm');
2525

26-
if (!checker.exists()) {
27-
return true;
28-
}
26+
if (!checker.exists()) {
27+
return true;
28+
}
2929

30-
return checker.lt('3.27.0-alpha.1');
31-
},
30+
return checker.lt('3.27.0-alpha.1');
31+
},
3232

3333
treeForAddon(tree) {
3434
let babel = this.addons.find((addon) => addon.name === 'ember-cli-babel');
@@ -41,38 +41,34 @@ module.exports = {
4141
destDir: '@html-next/vertical-collection'
4242
});
4343

44-
// When compiling with `compileModules: false`, ember-cli-babel defaults to
45-
// using the modules polyfill, since it assumes we are concatenating the
46-
// output script using `app.import` without an AMD wrapper.
47-
//
48-
// This does not apply to us, since we are compiling the `-private` modules
49-
// into a single AMD module (via rollup below), which can in fact have
50-
// external dependencies.
51-
//
52-
// We can opt-out of this with `disableEmberModulesAPIPolyfill: true`. In
53-
// Ember versions with "real modules", that is what we want in order to
54-
// avoid the Ember global deprecation (or just completely not working in
55-
// 4.0+).
56-
//
57-
// It seems like the intent may have been that we should be able to set
58-
// this to `true` unconditionally, and `ember-cli-babel` will ignore this
59-
// setting if the Ember verion requires the modules API polyfill. However,
60-
// presumably due to a bug, ember-cli-babel actually checks for this value
61-
// first and return out of the function early if its value is truthy. This
62-
// means that if we set this to true unconditionally, then we would have
63-
// disabled the modules polyfill for Ember versions that needs it, which
64-
// would be incorrect. Therefore, we have to duplicate the detection logic
65-
// here in order to set this value appropriately.
66-
//
67-
// Ideally, we should just stop trying to rollup the -private modules and
68-
// let the modern build pipeline optimizes things for us, then none of this
69-
// would have been necessary.
7044
let privateTree = babel.transpileTree(withPrivate, {
7145
babel: this.options.babel,
7246
'ember-cli-babel': {
47+
// we leave our output as valid ES
48+
// for the consuming app's config to transpile as desired
49+
// so we don't want to compileModules to amd here
7350
compileModules: false,
74-
disableEmberModulesAPIPolyfill:
75-
!this._emberVersionRequiresModulesAPIPolyfill(),
51+
52+
disableEmberModulesAPIPolyfill: !this._emberVersionRequiresModulesAPIPolyfill(),
53+
54+
// TODO for the embroider world we want to leave our -private module
55+
// as an es module and only transpile the few things we genuinely care about.
56+
// ideally this would occur as a pre-publish step so that consuming apps would
57+
// just see a `-private.js` file and not pay any additional costs.
58+
// CURRENTLY we transpile the -private module fully acccording to the
59+
// consuming app's config, so we must leave these enabled.
60+
disablePresetEnv: false,
61+
disableDebugTooling: false,
62+
disableDecoratorTransforms: false,
63+
enableTypeScriptTransform: true,
64+
65+
throwUnlessParallelizable: true,
66+
67+
// consuming app will take care of this if needed,
68+
// we don't need to also include
69+
includePolyfill: false,
70+
71+
extensions: ['js', 'ts'],
7672
},
7773
});
7874

0 commit comments

Comments
 (0)