Cannot declare a let variable twice


Did anyone manage a successful build with webpack before? When I enable --env.uglify my app basically stalls at the splash screen and the console shows
Cannot declare a let variable twice <LETTER-HERE>
( changes; sometimes an ‘e’, sometimes it’s a ‘t’, etc)

I’ve seen a lot of issues reported on this across the web that uglifying can cause issues with mangling. But there are also reports that boil down to a safari10 bug of some sort.

UglifyJS has a flag to enable/disable the ‘safari10’ bug, but it doesn’t solve the issue. Then again, I don’t even know what does this has to do with safari 10 (if at all), since I’m not using a webview, not running in safari, and don’t even know which version I have (running iOS 9.3.5).

Point in case, the project doesn’t run. Period. It has been nothing but frustration ever since I decided to give nativescript-dev-webpack a try. Of course I can’t really ship a project without uglifying the code, so now I feel stuck.

nativescript:  3.4.3
tns-core-modules: 3.4.1
tns-ios: 3.4.1
"dependencies": {
    "nativescript-theme-core": "~1.0.2",
    "tinycolor2": "^1.4.1",
    "tns-core-modules": "^3.4.1"
  "devDependencies": {
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-webpack": "^0.9.2",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.9.1",
    "webpack-sources": "~1.1.0"

Webpack uglify crash

Have you tried following this webpack upgrade guide?


Yes, I have read that multiple times, unfortunately it didn’t help.


Are you using NativeScript Core?


Yes. And just vanilla JS.


If you ask me, I’d not worry much about webpacking a NativeScript Core app. It already works pretty great. I’m in the same boat as you though. I couldn’t webpack my NativeScript Core app either. The webpack would finish, but the styles don’t work when webpacked for me.


I would not worry about it, except I do not wish to upload it to the store with the code open.


I solved this by using webpack-obfuscator ( instead of --env.uglify. Seems to work so far.