MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
191 stars 62 forks source link

Failed to minify constants/index.js when build with CRA #16

Closed ydatech closed 5 years ago

ydatech commented 6 years ago

I'm trying to build my electron app bootstraped by create-react-app (cra). and get this error:

react-scripts build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

    ./node_modules/electron-push-receiver/src/constants/index.js:13 

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! melisa@1.0.0-beta.13 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the melisa@1.0.0-beta.13 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/yudasukmana/.npm/_logs/2018-03-16T04_23_46_972Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
MatthieuLemoine commented 6 years ago

@ydatech CRA uses Webpack@^3 which is bundled with a version of UglifyJS that does not support ES6. Webpack@^4 is bundled with a new version of UglifyJS that can parse ES6.

Four solutions here :

ydatech commented 6 years ago

@MatthieuLemoine I have fixed the issue by moving constants from src/constants/index.js file to local variable in entrypoint src/index.js.. and also I changed the dependency of push-receiver to dev-master because it also causes build error if we use latest stable version..

Note: Create React App can consume both CommonJS and ES modules. For Node.js compatibility, it is recommended that the main entry point is CommonJS. However, they can optionally provide an ES module entry point with the module field in package.json. Note that even if a library provides an ES Modules version, it should still precompile other ES6 features to ES5 if it intends to support older browsers.

this is my fork: https://github.com/ydatech/electron-push-receiver

MatthieuLemoine commented 5 years ago

Fixed in v2.1.2 thanks to @NBoychev #36