EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

Webpack using --uglify fails #13

Closed Svettis2k closed 6 years ago

Svettis2k commented 6 years ago

When attempting to use webpack with uglify the process fails giving this message:

ERROR in vendor.js from UglifyJs Unexpected token: operator (>) [vendor.js:82349,55]

This refers to the following line:

return string.replace(new RegExp(“(” + find.map(i => i.replace(/[.?*+^$[\]\\(){}|-]/g, “\\$&“)).join(“|”) + “)”, “g”), match => replace[find.indexOf(match)]);

The problem is that the default UglifyJsPlugin of nativescript-dev-webpack does not support the => notation, as it does not support ES6. This issue explains the problem. I was able to solve it simply by replacing the => with function() {} in resource.common.js.

return string.replace(new RegExp(“(” + find.map(function (i) { return i.replace(/[.?*+^$[\]\\(){}|-]/g, “\\$&“) }).join(“|”) + “)”, “g”), function (match) { return replace[find.indexOf(match)] });
lfabreges commented 6 years ago

Should be fixed in 2.0.3

lfabreges commented 6 years ago

Actually it will probably not work, I'm on it right now

lfabreges commented 6 years ago

Should be ok now