rxdb: Unexpected token: keyword (function) UglifyJs
hi author, i trying to use rxdb with vuejs + cordova ( quasar framework ) but when build this bug happend.
ERROR in js/0.bcc8ac658f5ce5687243.js from UglifyJs
Unexpected token: keyword (function) [js/0.bcc8ac658f5ce5687243.js:590,6]
more detail i posted here: https://github.com/quasarframework/quasar/issues/573 this error make app can not run on mobile cordova, please help !
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 31 (21 by maintainers)
I released 4.0.2 a few seconds ago. One problem was the usage of
constructor.name=='WhatEver'which does not work after minification. Another thing was that we still had es7-things in the es6-build which of course broke UglifyJSHi @lyquocnam. This error is produced by UglifyJS whenever it tries to ‘uglify’ a function that has been designated as an asynchronous function.
Depending on how the webpack setup is defined for the
quasar-cli, you will need to run this bundle through a transpiler such asbabelfirst. It looks like that function is being required in wholesale from rxjs somewhere.NOTE: Offending function in your prod bundle;
@lyquocnam I could reproduce this on the angular2-example. I will investigate…
@varbrad Great. I will do a new release tomorrow evening. (now +20 hours)
@lyquocnam I created a branch where I commited a new build. Could you add rxdb to your package.json by the following commit-hash:
Then re-run
npm installand check if the build works now.A few notes;
cross-envshould be declared as a dev-dependency, I had to install it.npm run buildgives me an error, seems like anasyncfunction within thescripts/transpile.jsfile is tripping up NodeJS.npm run build:esworks, and seems to look better (no async stuff), but UglifyJS still blows up in my face with some errors.Not sure if this is an option, but could the ‘ES’ module version just not be uglified? Looking at most other modules such as
vue,reduxet al, they don’t uglify their ES module builds.Plus, can UglifyJS even handle the
exportES syntax?@varbrad Ah, you are right. Forgot to add the link itself 😃 Edited the post.
@varbrad Hi, Please read this post from Rich Harris explaining what “jsnext:main” is and how it should be used by package owners, and then the next comment. Seems like
rxdbhas chosen option 3, but this complicates things a lot for devs using Webpack which have to do extra configuration. You might want to chose another option so that this will work “out of the box” with Webpack too. Most users just drop a package and search for replacement when having such problems – not to mention not everyone is a Webpack wizard 😃 Just my opinion.EDIT: forgot to add link 😃 https://github.com/reactjs/redux/issues/1042#issuecomment-157129818
Ok I think I have figured it out. Webpack is using the
modulesource fromrxdbwhen being built. This results in webpack just using the source files rather than the dist files.This means the async/await stuff just gets put into the resulting bundle, and then uglify-js gets confused when it sees them when attempting to uglify the source.
Also, if babel (or similar) is running within the
quasar buildstep, then it will be ignoringnode_modules(presumably, I haven’t checked) and voila, there’s the issue.my project here https://github.com/lyquocnam/quasar-test