Closed cmargulhano closed 6 years ago
Have you tried without --snapshot ?
Recently I was blaming the Uglification but in fact was the snapshot or both.
Yes, same error.
I was with a similar error but the variable is "position":
ERROR in bundle.js from UglifyJs
Unexpected token: name (position) [bundle.js:13540,8]
And the problem was in the plugin nativescript-toasts. I changed the variable let position
to var position
and works for while.
Try look in your project for variable let window
in any plugin and change to var window
@cmargulhano can you provide the content of your package.json
file
Thank you for help me! Here my package.json:
{ "description": "XX", "license": "XX", "readme": "XX", "repository": "XX", "profiling" : "timeline", "nativescript": { "id": "XX", "tns-ios": { "version": "3.2.0" }, "tns-android": { "version": "3.2.0" } }, "scripts": { "lint": "tslint \"app/*/.ts\"", "ns-bundle": "ns-bundle", "publish-ios-bundle": "npm run ns-bundle --ios --publish-app", "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install", "start-android-bundle": "npm run ns-bundle --android --run-app", "start-ios-bundle": "npm run ns-bundle --ios --run-app", "build-android-bundle": "npm run ns-bundle --android --build-app", "build-ios-bundle": "npm run ns-bundle --ios --build-app" }, "dependencies": { "@angular/animations": "4.4.3", "@angular/common": "4.4.3", "@angular/compiler": "4.4.3", "@angular/core": "4.4.3", "@angular/forms": "4.4.3", "@angular/http": "4.4.3", "@angular/platform-browser": "4.4.3", "@angular/router": "4.4.3", "base-64": "0.1.0", "moment": "2.18.1", "nativescript-android-utils": "1.0.2", "nativescript-angular": "4.2.0", "nativescript-checkbox": "2.1.14", "nativescript-dom": "2.0.0", "nativescript-local-notifications": "1.2.2", "nativescript-pro-ui": "3.1.3", "nativescript-pulltorefresh": "2.0.2", "nativescript-theme-core": "1.0.4", "nativescript-toast": "1.4.6", "nativescript-websockets": "1.3.3", "nativescript-worker-loader": "0.8.1", "ng2-translate": "5.0.0", "reflect-metadata": "0.1.10", "rxjs": "5.4.3", "tns-core-modules": "3.2.0", "utf8": "2.1.2", "zone.js": "0.8.17" }, "devDependencies": { "@angular/compiler-cli": "4.4.3", "@ngtools/webpack": "1.7.1", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "codelyzer": "3.2.0", "copy-webpack-plugin": "4.0.1", "extract-text-webpack-plugin": "3.0.0", "lazy": "1.0.11", "nativescript-css-loader": "0.26.1", "nativescript-dev-sass": "1.3.2", "nativescript-dev-typescript": "0.5.0", "nativescript-dev-webpack": "0.8.0", "node-sass": "4.5.3", "raw-loader": "0.5.1", "resolve-url-loader": "2.1.0", "tslint": "5.7.0", "typescript": "2.5.2", "webpack": "3.6.0", "webpack-bundle-analyzer": "2.9.0", "webpack-sources": "1.0.1", "nativescript-worker-loader": "0.8.1" } }
@cmargulhano @ferpaganucci ,
UglifyJS 2 doesn't support ES6 code. In @ferpaganucci's case, the nativescript-toast
plugin is not transpiled to es5 and uglify is failing to parse it.
@cmargulhano, you must have plugin or plugins that are distributed in es6, too.
You can either find the es6 plugins and transpile them to es5 or use UglifyJS 3, which supports es6+. Here's how:
Install the latest beta version of the corresponding webpack plugin:
npm i -D uglifyjs-webpack-plugin@1.0.0-beta.2
Modify your webpack configuration to use the above plugin instead of the one, distributed with webpack:
// webpack.config.js
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// ...
function getPlugins() {
// line 209
if (env.uglify) {
plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));
plugins.push(new UglifyJsPlugin({
uglifyOptions: {
mangle: { reserved: [ nsWebpack.uglifyMangleExcludes ]},
compress: true
}
}));
}
}
That's works! Thanks @sis0k0! By the way, congratulations for yours videos in Youtube :)
After Uglify now I'm getting this error:
10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) 10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodNative(Native method) 10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1084) 10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodImpl(Runtime.java:966) 10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:953) 10-05 16:48:53.260 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:937) 10-05 16:48:53.261 16384 16384 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:929) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethodNative(Native method) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1084) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethodImpl(Runtime.java:966) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:953) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:937) 10-05 16:48:53.361 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:929) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethodNative(Native method) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1084) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethodImpl(Runtime.java:966) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:953) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:937) 10-05 16:48:53.362 16384 16384 F art : art/runtime/runtime.cc:441] at com.tns.Runtime.callJSMethod(Runtime.java:929)
@sis0k0 I tried the latest UglifyJsPlugin but it gives me the error below. Any thoughts on this,
throw new _ValidationError2.default(ajv.errors, name);
^
false
child process exited with code 1
Sorry, my bad. I missed to update the UglifyJsPlugin constructor options.
Did we ever find a proper fix for this? It's a nativescript core issue, that seems obvious since I've got the same problem on NS-VUE. Went through NS plugins and manually changed _let_s to _var_s. Not looking forward to doing this with each rebuild.
@spirit-of-satoshi It's not an issue with NativeScript, you may call it a issue with the plugin you use or UglifyJS. Either the plugin must be updated to use ES5 or your UglifyJS version should support ES6. As I mentioned above, the easiest fix is to update your UglifyJS version to latest and point it in webpack config.
After run this: tns build android --clean && npm run start-android-bundle --uglify --snapshot
I got this error after running uglification:
ERROR in bundle.js from UglifyJs Unexpected token: name (window) [bundle.js:29157,4]