From a0674eaf4daae538528c435476454f722e4af485 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Fri, 21 Apr 2017 15:01:20 +0300 Subject: [PATCH] fix(template): ship bundle with empty `tns-java-classes.js` chunk This is required for compatibility reasons (NativeScript 2.5). When a non-webpacked NativeScript application is deployed to phone, the apk contains a `tns-java-classes.js` file. If that file is present, it is dynamically loaded by the Android runtime at startup. Webpacked NativeScript applications didn't contain that file as it is not needed. But when the application is deployed to phone, the previous `tns-java-classes.js` file is not removed from the app folder on the phone. That causes the Android runtime to try load the file and fail. Since this commit, all webpacked NativeScript apps will be shipped with an empty `tns-java-classes.js` file which is harmless and is used to override the existing file left from previous deployment. related to https://github.com/NativeScript/NativeScript/issues/3613, https://github.com/NativeScript/NativeScript/issues/3947 --- webpack.common.js.angular.template | 10 ++++++++-- webpack.common.js.javascript.template | 9 ++++++++- webpack.common.js.typescript.template | 9 ++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/webpack.common.js.angular.template b/webpack.common.js.angular.template index 0d017ebd..f52e56d6 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -21,9 +21,15 @@ module.exports = function (platform, destinationApp) { var plugins = [ new ExtractTextPlugin("app.css"), - // Vendor libs go to the vendor.js chunk new webpack.optimize.CommonsChunkPlugin({ - name: ["vendor"] + name: [ + // Vendor libs go to the vendor.js chunk + "vendor", + + // Compatibility workaround with NativeScript 2.5 Android runtime + // https://github.com/NativeScript/NativeScript/issues/3947 + "tns-java-classes", + ], }), // Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ diff --git a/webpack.common.js.javascript.template b/webpack.common.js.javascript.template index 7f44fda8..dde25431 100644 --- a/webpack.common.js.javascript.template +++ b/webpack.common.js.javascript.template @@ -22,7 +22,14 @@ module.exports = function (platform, destinationApp) { new ExtractTextPlugin("app.css"), // Vendor libs go to the vendor.js chunk new webpack.optimize.CommonsChunkPlugin({ - name: ["vendor"] + name: [ + // Vendor libs go to the vendor.js chunk + "vendor", + + // Compatibility workaround with NativeScript 2.5 Android runtime + // https://github.com/NativeScript/NativeScript/issues/3947 + "tns-java-classes", + ], }), // Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ diff --git a/webpack.common.js.typescript.template b/webpack.common.js.typescript.template index 8427c542..471ce9d4 100644 --- a/webpack.common.js.typescript.template +++ b/webpack.common.js.typescript.template @@ -22,7 +22,14 @@ module.exports = function (platform, destinationApp) { new ExtractTextPlugin("app.css"), // Vendor libs go to the vendor.js chunk new webpack.optimize.CommonsChunkPlugin({ - name: ["vendor"] + name: [ + // Vendor libs go to the vendor.js chunk + "vendor", + + // Compatibility workaround with NativeScript 2.5 Android runtime + // https://github.com/NativeScript/NativeScript/issues/3947 + "tns-java-classes", + ], }), // Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({