Skip to content

Commit 6183c16

Browse files
author
Robert Jackson
committed
[BUGFIX release] Ensure loader.js is transpiled via targets.
Prior to this change, the `packages/loader/lib/index.js` file was not transpiled (at all). However, until 4a5b372 landed the file was still authored (manually) in IE11 compliant ES5 JavaScript. Once 4a5b372 landed however (first released in 3.14.0-beta.1) it is impossible to use the built assets in a browser that does not support `let` variable declaration (e.g. Safari 9). This ensures that `packages/loader/lib/index.js` passes through the same transpilation process as the rest of the application, and (confirmed manually) fixes the issue reported. Ironically, our CI did not catch this issue (even though we are properly testing in IE11) because IE11 actually supports `let` usage (with minor caveats). Also, since `loader.js` is the "one thing" that does not need modules transpilation, this also adds a new argument to `transpileTree`. Most of the time that option is `undefined` (and therefore not used at all), but for header files we need to avoid the module wrapping. (cherry picked from commit 60b8dee)
1 parent 1edabe4 commit 6183c16

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module.exports = {
127127
}
128128
},
129129

130-
transpileTree(tree, isProduction) {
130+
transpileTree(tree, isProduction, shouldCompileModules) {
131131
let emberCliBabel = this.addons.find(a => a.name === 'ember-cli-babel');
132132

133133
let parentOptions = this.parent && this.parent.options;
@@ -157,6 +157,13 @@ module.exports = {
157157
}),
158158
};
159159

160+
if (shouldCompileModules !== undefined) {
161+
// ember-cli-babel internally uses **any** value that was provided IIF
162+
// the option is set so this option must only be set when we have a
163+
// useful value for it
164+
options['ember-cli-babel'].compileModules = shouldCompileModules;
165+
}
166+
160167
if (isProduction) {
161168
options.babel.plugins.push(buildStripClassCallcheckPlugin());
162169
}
@@ -172,7 +179,11 @@ module.exports = {
172179
isProduction
173180
);
174181

175-
let headerFiles = new Funnel(tree, { srcDir: 'header' });
182+
let headerFiles = this.transpileTree(
183+
new Funnel(tree, { srcDir: 'header' }),
184+
isProduction,
185+
false
186+
);
176187

177188
let exclude = isProduction ? ['ember-testing/**'] : [];
178189

0 commit comments

Comments
 (0)