Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Can't work with old webpack uglify plugin? #65

Closed
xwillmadeit opened this issue Feb 12, 2019 · 4 comments
Closed

Can't work with old webpack uglify plugin? #65

xwillmadeit opened this issue Feb 12, 2019 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@xwillmadeit
Copy link

xwillmadeit commented Feb 12, 2019

ERROR in Encountered an error while minifying js/vendor.891a096d.js:
SyntaxError: Unexpected token: keyword (const)
  27927 |
  27928 | function useObservable(initialValue) {
> 27929 |     const observableRef = Object(__WEBPACK_IMPORTED_MODULE_1_react__["useRef"])(null);
        |    ^
  27930 |     if (!observableRef.current) {
  27931 |         observableRef.current = Object(__WEBPACK_IMPORTED_MODULE_0_mobx__["observable"])(initialValue);
  27932 |     }

The build version of this package has es6 syntax,but i use webpack-parallel-uglify-plugin,so it breaks my app. Do I have to upgrade my uglify plugin or config my babel-loader to transpile it first?

@danielkcz danielkcz added bug Something isn't working help wanted Extra attention is needed duplicate This issue or pull request already exists and removed bug Something isn't working help wanted Extra attention is needed labels Feb 12, 2019
@danielkcz
Copy link
Collaborator

Is probably related to #63, but yea, would be better if you can update your stack to support ES6. It's kinda strange that you would go with a bleeding edge like React Hooks, but would be still requiring ES5 😕 Alternatively you can try a new and maintained minifier Terser. I am not sure if it has parallel webpack plugin though.

@xwillmadeit
Copy link
Author

Is probably related to #63, but yea, would be better if you can update your stack to support ES6. It's kinda strange that you would go with a bleeding edge like React Hooks, but would be still requiring ES5 😕 Alternatively you can try a new and maintained minifier Terser. I am not sure if it has parallel webpack plugin though.

I didn't think too much because react hook is fully backwards-compatible. I use webpack 3+ and can't use terser-webpack-plugin,so its kinda embarrassed... I guess it's time to upgrade webpack to 4+

@danielkcz
Copy link
Collaborator

Yea, this package is meant for like a future proof stacks. Please do try an update and if it turns out impossible, you would need to wait (or contribute) for #63 to get fixed. I will close this now and subscribe there, please.

@alsotang
Copy link
Contributor

uglify can not work with es6. It only support es5. First you should compile the module to es5, then uglify it.

mweststrate added a commit that referenced this issue Feb 14, 2019
danielkcz pushed a commit that referenced this issue Feb 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants