-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Minifying with uglify fails because build doesn't target ES5 #4
Comments
Yep, getting the same thing. Came here after reading facebook/create-react-app#1418 (comment) |
@sergeche Is there any way to solve this? Or maybe make it so It can be used on a CDN like https://unpkg.com/ |
Not familiar with Create React App build process, but working solution is to preprocess libs with ES6 code with Babel/Buble or use uglify-es |
@sergeche Create React App's build process uses uglify under the hood and I'm not sure if it was a decision of CRA to configure it this way, but they don't transpile dependencies and they don't support ES6+ dependencies stating that:
Create React App can only be customized after "ejecting" to gain access to babel and webpack configs - which I did and tried to customize to transpile emmet, but with emmet's dependencies also being es6, it turned into a bit of a mess. Any ideas? |
You just need to transpile packed bundle before passing it to uglify. If you use Rollup, simply add Babel or Buble into plugin list. This is how it works for bundling standalone minified CodeMirror plugin: https://github.com/emmetio/codemirror-plugin/blob/master/rollup.config.js#L22 It also can be done in Webpack but I’m not familiar with it. |
@bradwestfall I've come up with a workaround for now. I've forked the project and changed the build process to use Node Resolve and Buble and committed ./dist so I can add it straight to my project without distributing on npm. Using Node Resolve has increased the size of the dist file by quite a bit, but I don't think this matters because as far as I can tell the dependency tree consists entirely of other emmetio packages, so not anything that's likely to be used elsewhere in a project. Does that sound right to you, @sergeche? You should be able to get your project building by running
|
@tonyonodi I appreciate the work, but if I use your fork I won't get the same maintenance updates as I would from
Btw, |
I guess it’s not relevant anymore, closing |
I'm attempting to use this project in a project that uses Create React App, which uses Uglify when building. When I try to build I get the following error message
The link in the error message is very instructive and explains the issue well. Basically Uglify needs code that is compiled to ES5 to work and codemirror-plugin doesn't do this
I have already forked codemirror-plugin and its dependencies and have begun the process of modifying them to target ES5, but it's slow going because I'm not familiar with rollup or mocha and I'm unable to get any of the tests to pass and I don't know if what I have at the end of it will be good enough to merge into this project.
The text was updated successfully, but these errors were encountered: