-
Notifications
You must be signed in to change notification settings - Fork 490
Changing target to ES6 causes build script to fail #21
Comments
Uglify can't parse the generated ES6 code. Create-react-app would have the same issue if you could emit ES6 code. There's some talk about moving to babili for minification to alleviate this. |
Thanks @heyimalex! Should this just be closed then? |
Hm, it's not really solvable without a ton of work, and I think we should wait for compiling-to-es6 support to land upstream before tackling it. We could make the error more obvious by reading the tsconfig first and checking for unsupported targets. That opens up a can of worms (what other tsconfig options aren't supported?), but is in line with create-react-app's maintainer-masochism-in-the-name-of-end-user-experience development strategy. Maybe a better long-term solution is to lock down the typescript version and tsconfig.json completely? Definitely makes tailoring the experience easier, and cra does basically the same thing with eslint and babel transforms. Some options would be very contentious (like |
Ah, I wasn't aware uglify doesn't have es6 support. It's not a huge issue for me; I was just testing and noticed it crashed.
That seems reasonable, but it does imply bringing babel back into this project! (Assuming CRA moves to babili.) |
@magicmaaaaan @heyimalex going to close this issue until upstream is updated! Thanks |
I just bumped into this issue trying to build a project that uses redux-saga, which in turn uses generator functions, which forced me to change the target to ES6 and caused the build to fail. So assuming
as @heyimalex wrote - what are my options here? |
Nothing I can think of without ejecting. The quickest fix is to replace uglify with another minifier (or none at all if you're ok with that). I remember hearing that closure compiler can handle es6 code, but I'm really not familiar with it. What does the angular world use for minification? They deal with a lot of typescript and I imagine have the same problem with uglify. Maybe that replacement could happen within this project. I really wish I had the time to look into this myself. Sorry I can't be more helpful! Also I'm not by my computer but are you sure that tsc can't compile generators to es5? I know that babel can and thought that typescript could also. Good luck! |
I'm targeting es5 in tsconfig.... I'm intersted in taking a look at this, I've done the uglify to babili switch for other webpack projects, but I don't understand the react-scripts-ts internals.... |
I am also experiencing some issues with various module dependencies and targeting es6. Is there any workaround for these UglifyJS issues? |
@tatemz Use a different target? Just as an update:
|
I did what @heyimalex suggested.
const UglifyJsPlugin = require('uglifyjs-webpack-plugin') change to -> new UglifyJsPlugin
as suggested here: webpack-contrib/uglifyjs-webpack-plugin#140 (comment) Works fine now, but it required ejecting, which I think should be fixed in the repo here :) |
Can you reproduce the problem with latest npm?
Yes
Description
After changing the tsc target to
es6
,react-scripts-ts build
fails during minification (I think). Running the development server (react-scripts-ts start
) works fine on thees6
target.Expected behavior
The build script should not fail.
Actual behavior
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected): [email protected]node -v
: v7.4.0npm -v
: 4.1.2Then, specify:
Reproducible Demo
The text was updated successfully, but these errors were encountered: