ember.js: Version 3.10.1 regression: use of const in strict mode, causing critical errors in e.g. Safari 9
In ember.min.js version 3.10.1 there are various usages of the const keyword in use strict mode:
@ember/-internals/glimmer, example:const e=L(["template-compiler:main"]@ember/application/lib/application, example:const e=function(e,t){t...@ember/engine/index, example:const e=v(["-bucket-cache:main"])@ember/engine/instance, example:const e=u(["template-compiler:main"])
These cause syntax errors in Safari 9 (e.g. on iPhone 6S) and the Ember app fails to start. The error is:
SyntaxError: Use of const in strict mode
Ember 3.9.1 (the previous version) didn’t have this problem.
Repro:
npm install -g ember-cli@3.10.1
ember new test-app
yarn install
(edit config/targets.js to include Safari >= 9)
ember build -prod
(inspect dist/vendor.js and see the above-mentioned const occurrences)
Is this a bug, or am I missing something with respect to the build process?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (10 by maintainers)
I’m currently working on the fix for this. It is not easy, it means some pretty major changes to Ember’s build and testing setup, so that it dynamically compiles based on the consuming application’s Babel settings and targets.
@austinezell this is because we actually do not compile any of Ember’s code using your targets. At the moment Ember ships with two builds, the legacy build with everything transpiled, and the modern build targeted at the most recent browsers. We use feature detection based on your presets to pick which one to use, but this is the second time that something has broken because of it.
I think at this point we really need to work toward compiling Ember just-in-time using the host application’s build targets. It may end up being a bit of a hacky solution, but it’ll prevent these kinds of issues from cropping up.
Is there anything new about this problem?
One thing I have noticed in the build process is the message:
I’m guessing that this is a dependency of one of the ember-related packages and it’s something that we’re not responsible for updating ourselves. I wanted to mention it regardless though.
one more related issue: https://github.com/emberjs/ember.js/issues/17809#issuecomment-509599388
I just tried to
npm linkthis package and force my app to pull in the “legacy” version of ember. I ended up just verifying that my application is in fact already pulling in the legacy version.The issue is that the legacy currently has 15 instances of
const. Cloning this repo and runningnpm buildthen checking thedist/legacy/folder verifies this. It does seem that @rwjblue’s assumption is correct and that this was caused by #17859 . Re-adding the line['@babel/transform-template-literals', { loose: true }],into theto-es5.jsmodule and re-runningnpm buildsuccessfully removed all instances ofconstfrom the legacy build.