const, let and spread (not IE11 compatible)
See original GitHub issueThis library is expected to be consumed as is, however, without implicit include
for babel-loader
it will emit the original ES6 code to the final bundle, breaking old browsers.
Proposal:
- use ES5 inside, so it would be safe to use it
- or ship as a multi-bundle (see https://github.com/theKashey/multiple-entry-points-example)
PS: And is there any reason so spread result like return { ...memoryStatus };
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
IE 11 "Expected Identifier" error on spread operator found in ...
No issues with evergreen browsers. The error occurs at the first "." in the spread operator function, identified in the bundled js file...
Read more >"Object spread" | Can I use... Support tables for HTML5, CSS3 ...
1 Notable partial support in IE11 includes (at least some) support for const , let , block-level function declaration, typed arrays, Map ,...
Read more >let, var, and const - Go Make Things
Browser Compatibility # let and const work in all modern browsers, and IE11 and up. They cannot be polyfilled. To push support back...
Read more >A Simple Formula For When To Use Let, Const, and Var
By now, all major browsers and even IE11 support let and const . The var keyword declares a mutable reference to a value,...
Read more >let - JavaScript - MDN Web Docs
Just like const the let does not create properties of the window object when declared globally (in the top-most scope).
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 FreeTop 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
Top GitHub Comments
In general, the compromise the community has arrived at is to publish both ES2017 and ES5 builds. Within the next few months, bundlers like Rollup and Webpack will begin to support for Node’s new “package exports” package.json annotations, which brings a community-standardized mechanism for shipping not just CJS and ESM, but ES-current and ES5:
In the meantime, if the source here is strictly ES2017 (no JSX, Babel extensions, class properties, etc), a small number of bundlers are configured to look for a
"jsnext:main"
package.json property, and will interpret this as a signal that the package contains ES2017 code, triggering transpilation when bundling for older browsers (and using the source as-is for modern browsers).For now, I’d recommend shipping ESM and CJS using the
"module"
and"main"
fields, unless the package is dramatically smaller when left as ES2017. Generally I’d recommend trying a solution like microbundle, which will generate these outputs automatically, and also now includes support for compiling to modern JS.I had wanted to circle back on whether we needed to go for multi-build depending on community feedback. I would be happy to review a PR introducing two builds if someone would like to try out an approach.