Nullish coalescing / optional chaining support without IE11 in targets
See original GitHub issueCurrently production builds wihout IE11 in targets will fail if Nullish coalescing / optional chaining used in project codebase.
Issue from: https://github.com/terser/terser/issues/567 Related issue: https://github.com/ember-cli/ember-cli-uglify/issues/49
Error will looks like:
ERROR Summary:
- broccoliBuilderErrorStack: SyntaxError: Unexpected token: punc (.)
at ee (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:19541)
at c (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:28244)
at l (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:28335)
at f (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:28388)
at G (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:42202)
at ge (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:48272)
at C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:49152
at be (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:49167)
at ze (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:50421)
at qe (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\terser\dist\bundle.min.js:1:50653)
- code: [undefined]
- codeFrame: Unexpected token: punc (.)
- errorMessage: Unexpected token: punc (.)
at UglifyWriter
-~- created here: -~-
at UglifyWriter.Plugin (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\broccoli-plugin\index.js:7:31)
at new UglifyWriter (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\broccoli-uglify-sourcemap\index.js:38:10)
at UglifyWriter (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\broccoli-uglify-sourcemap\index.js:33:12)
at Class.postprocessTree (C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\ember-cli-uglify\index.js:54:50)
at C:\Users\lifeart\Documents\repos\brn\frontend\node_modules\ember-cli\lib\utilities\addon-process-tree.js:6:25
at Array.reduce (<anonymous>:null:null)
Discord thread: https://discord.com/channels/480462759797063690/486548111221719040/737966824775221258
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Does the nullish coalescing operator (??) in TypeScript have ...
As for now, yes, nullish coalescing will be transpiled, along with all the other syntax that isn't yet supported by your target ES...
Read more >Nullish coalescing operator (??) - JavaScript - MDN Web Docs
The nullish coalescing operator treats undefined and null as specific values. So does the optional chaining operator ( ?. ), which is useful...
Read more >Optional chaining and nullish coalescing in TypeScript
Use two features of TypeScript 3.7: optional chaining and nullish coalescing, to write simple code without never-ending conditionals.
Read more >soda on Twitter: "Reminder to all developers that still need to ...
The default queries no longer target IE11 anymore. Quote Tweet ... which depends on acorn 6, which never supports optional chaining and nullish...
Read more >vue/cli - Awesome JS
The default browserslist query no longer includes IE 11 as a target. ... so that optional chaining and nullish coalescing syntaxes won't cause...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another potential fix: Explicitly include the babel plugins for those two features into your
ember-cli-build.js
like this:As a workaround, one could use
targets
that are for browsers without native support for those two features (so they are transpiled by babel and terser won’t blow up). I, personally, use these:And that works fine.