-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quality of life improvements for node usage #301
Quality of life improvements for node usage #301
Conversation
Allows node 6 to run natively as this operation is invalid (at least under v8).
- Removes uglify from node targets (uglify _still_ does not understand es2015+) - Use babel-env-preset to figure out what are the best options for target node (6.9 used as package.json engine specifies)
@brettz9 r? |
Hey, thanks for the changes! I was thinking we could probably dump those minified Node builds (I had been using Node 6 for a while before upgrading too, but maybe I didn't notice as "main" is pointing to the non-minified version, perhaps because of that!). A few questions/concerns:
And yes, good catch on |
I've added your commits, rebasing the last one to add Very helpful to have this, thanks! Btw, though it requires some work, if you can get the W3C tests set up, it would really help future testing. But regardless, it is good to have these changes! |
@brettz9 Thanks for getting this landed so fast! Let me address some of your questions:
babel-env will correctly figure out what is supported by node (in this case class is) but there seem to be some additional constraints when using class (I think those could have been easily fixed by using Object.setPrototypeOf but switching to class seemed easier).
Hah- This was my mistake... Originally contained: const glob = typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : self);
glob._babelPolyfill = false; // http://stackoverflow.com/questions/31282702/conflicting-use-of-babel-register This was in theory to prevent the exact error that prompted me to submit the patch... It may work in a different environment but IMO it's better to remove it (and polyfill in general if you can avoid it). |
Yeah, thanks. For strict compliance, I actually already added You encountered the duplicate babel-polyfill error even with the check we had in place? Also, do we need the import babel-polyfill command alone in its own file or can we move the command back inline (or is that what has seemingly avoided the duplicate calls to babel-polyfill?) |
@brettz9 I suspect the code I referenced above does not actually work... IMO it would be best to avoid using babel-polyfill in libs and let the individual consumers add in the polyfill (though I have seen all different kinds of combinations of this (i.e. using transform-runtime)). |
... and yes the new babel-polyfill-before.js could just be removed in favor of the direct babel-polyfill import |
The code referenced above had been working to avoid babel-polyfill throwing upon encountering another instance and didn't seem to cause any issues, but I do get the rationale for letting downstream users handle. Not sure babel-polyfill still does this, but as I ran all of the browser tests, it looks like we're good now atm, regardless... Since it is an extra step for people to do it themselves and we're doing the build anyways, since our project is of broad appeal and I'd like to reduce the complications toward entry and getting started, and since I think there are too many appealing cases to keep using the polyfilled prototypes for which browser support may vary for some time (thanks for the info on It is admittedly just one additional browser include (which we could instruct users on including), and it would be reassuring to use babel-polyfill in the recommended manner of not browserifying it as well as help anyone knowing the browser supports the features to be able to abandon the extra file size. But at this point, I think the costs of switching may outweigh the benefits. |
Ok, given another issue (#303) reporting on this (a problem with our removal of a polyfill check for code using babel-polyfill outside of IDB), I've decided users should be able to handle the newly-added README instructions requiring the |
This PR changes how node targets are built:
No more uglify (not compatible /w latest node 6 syntax ). Generally I think downstream consumers will only care about browser or will uglify their entire pipeline (which will effectively uglify this).
Node specific babel preset (targets node 6 per package.engine)
"This fixes the babel-polyfill included twice" bug I ran into and has a nice side effect of making the node builds much smaller.
I tested : grunt node-qunit, grunt mocha (has one existing failure on master), mocha in browser (for chrome)...