-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
enhance: Transform ES standards in node_modules #159
base: master
Are you sure you want to change the base?
Conversation
Size Change: +328 B (0%) Total Size: 382 kB
ℹ️ View Unchanged
|
ftr, CRA only did this because users complained and it was easier than teaching them how to fix it properly; it's never safe to transpile code you didn't author. |
7c2aa68
to
7f26568
Compare
For my edification: what's unsafe about it? Not knowing that, it seems beneficial to be able select feature (ES version) targets independent of library authors. Authors can publish the latest version and export:browsers. Then consumers can optionally tranpsile back to whatever they need to support - be it node, IE11, or else. I do understand, doing non-standard ES features would be unsafe (how can you know what proper transpilation is). |
Transpilation is not 1:1. There's always caveats. For example, you can know that your own arrow functions are never All code should be published as ES5 CJS; a published module that requires transpilation simply shouldn't be used. |
Seems rather restrictive to not ever use libraries that cannot be transpiled. Why not simply only use them when you don't need to support particularly old versions? Over time there will be more and more things that benefit from new standards. |
Oh sure, that's fair :-) maybe a more reasonable policy is "don't use any dependency that isn't already transpiled such that it works on all your supported platforms"? |
For the things that cannot be transpiled, this limits a libraries' legacy support. This is independent of the actual process of transpilation itself. If attempted, it will fail, and it cannot be published as such anyway. The key in both cases is simply to know the level of support the library or at least expose it in the process. If the build tooling you have is good, then it should tell you if you try to use incorrect libraries. To make this possible we first have to rally behind standards for expressing such things. One of those is browserslist. IMO the other is export conditionals. |
7f26568
to
96a141e
Compare
6655a4d
to
c7823e2
Compare
cbd4851
to
4a4c881
Compare
50f1311
to
0891d43
Compare
e37a167
to
ef98256
Compare
ef98256
to
9b30a95
Compare
26667e0
to
18ed3db
Compare
cc46120
to
1019112
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
504d522
to
c10db2b
Compare
TODO: Figure out how to only run this on 'exports: browser'
Reference CRA method: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L467