-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Unexpected token: keyword (function) UglifyJs #172
Comments
Hi @lyquocnam |
Hi @lyquocnam. Depending on how the webpack setup is defined for the NOTE: Offending function in your prod bundle; async function assertThrowsAsync(test, error = Error, contains = '') { ... } |
my project here https://github.com/lyquocnam/quasar-test |
Hi all, Didn't quite look, but is there a transpiled version of Rxdb in the npm package? This would solve the problem for all projects using Webpack by default, without the need to add Webpack exceptions, which is what most devs expect. |
Just a note that the naughty async function that is getting put into the pre-uglify file is being pulled in from Looks like somewhere (rxdb?, webpack?) is pulling in the util async functions from the 'src' directory as opposed to the 'dist' transpiled asyncToGenerators? |
Ok I think I have figured it out. Webpack is using the 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 |
@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 EDIT: forgot to add link :) reduxjs/redux#1042 (comment) |
Hi @rstoenescu, I am not the author of |
@varbrad Ah, you are right. Forgot to add the link itself :) Edited the post. |
Thank you @varbrad and @rstoenescu for the investigation. It looks like RxDB is doing something wrong here. Would this fix the issue or do you see any further problems with this? |
I think that is the way to go, by exporting a CommonJS/UMD format for the |
The commit d3a14cc417b04e32e2c534908dc62b0bcd654a5f handles this. |
A few notes;
Not sure if this is an option, but could the 'ES' module version just not be uglified? Looking at most other modules such as Plus, can UglifyJS even handle the |
@varbrad Thank you for testing. The es-version is not uglified. RxDB does not use UglifyJS in any build-context. Everything is just transpiled. I don't know if UglifyJS can handle |
@lyquocnam I created a branch where I commited a new build. rxdb: "git+https://github.com/pubkey/rxdb/commit/d3d70e919f10d7f5178f6febeb6707ed089c8100" Then re-run |
Ah that's why I get an error, I was running under my default node version (6.10), it work's fine on 7.10. And yes sorry about the Uglify confusion, I was being stupid and just directly cloning the newer commit into my testing project's |
I can confirm the latest commit d3d70e9 does indeed fix this issue. Awesome 👍. Just make sure to use the correct babel preset @lyquocnam, ES2015 won't work (you will also need stage-0 or just use env) |
@varbrad Great. I will do a new release tomorrow evening. (now +20 hours) |
@pubkey i tried but error:
may wait for next release :) |
You can also just install up to the latest master commit via |
@varbrad yeah, it work, the error not happen again ! 🥇 ...
var sub = db.khu.find().$
.filter(x=>x != null)
.subscribe(results => {
self.results = results;
}); demo app: |
@lyquocnam The tests and our examples work. |
@pubkey you mean is this : https://github.com/pubkey/rxdb/blob/master/docs/QueryChangeDetection.md ? i tried to do the tutorial, but still not reactive like before |
I just wanted to know if you enabled it. Do not enable it. Which adapter do you use with cordova? |
@pubkey i use |
I released v4.0.1 which solves this issue by shipping es6-code instead of es7-stage-0. @lyquocnam For the other problem (reactive-not-working), please create a new issue with steps to reproduce. |
Something still error @pubkey . The error before has resolved, but this new error showing. My app still run ok, but when build it show this error: code at line 5326: /**
* async version of assert.throws
* @param {function} test
* @param {Error|TypeError|string} [error=Error] error
* @param {?string} [contains=''] contains
* @return {Promise} [description]
*/
let assertThrowsAsync = (() => {
var _ref = _asyncToGenerator(function* (test, error = Error, contains = '') {
const shouldErrorName = typeof error === 'string' ? error : error.name;
try {
yield test();
} catch (e) {
// wrong type
if (e.constructor.name != shouldErrorName) {
throw new Error(`
util.assertThrowsAsync(): Wrong Error-type
- is : ${e.constructor.name}
- should: ${shouldErrorName}
- error: ${e.toString()}
`);
}
// check if contains
if (contains != '' && !e.toString().includes(contains)) {
throw new Error(`
util.assertThrowsAsync(): Error does not contain
- should contain: ${contains}
- is string: ${e.toString()}
`);
}
// all is ok
return 'util.assertThrowsAsync(): everything is fine';
}
throw new Error('util.assertThrowsAsync(): Missing rejection' + (error ? ' with ' + error.name : ''));
});
return function assertThrowsAsync(_x) {
return _ref.apply(this, arguments);
};
})(); |
@lyquocnam I could reproduce this on the angular2-example. |
I also could reproduce the non-reactive-bug. UPDATE: It looks like UglifyJS destroys the reactive behavior, especially when |
I released 4.0.2 a few seconds ago. |
@pubkey thanks so much, all work perfectly ! reactive still work correct 👍 |
hi author, i trying to use rxdb with vuejs + cordova ( quasar framework )
but when build this bug happend.
more detail i posted here: quasarframework/quasar#573
this error make app can not run on mobile cordova, please help !
The text was updated successfully, but these errors were encountered: