Skip to content

Commit 60b8dee

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.
1 parent 4bfb4cb commit 60b8dee

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
@@ -128,7 +128,7 @@ module.exports = {
128128
}
129129
},
130130

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

134134
let parentOptions = this.parent && this.parent.options;
@@ -158,6 +158,13 @@ module.exports = {
158158
}),
159159
};
160160

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

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

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

0 commit comments

Comments
 (0)