Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit b65a80c

Browse files
authored
fix(template): ship bundle with empty tns-java-classes.js chunk (#128)
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 NativeScript/NativeScript#3613, NativeScript/NativeScript#3947
1 parent be0707d commit b65a80c

3 files changed

+24
-4
lines changed

Diff for: webpack.common.js.angular.template

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ module.exports = function (platform, destinationApp) {
2121

2222
var plugins = [
2323
new ExtractTextPlugin("app.css"),
24-
// Vendor libs go to the vendor.js chunk
2524
new webpack.optimize.CommonsChunkPlugin({
26-
name: ["vendor"]
25+
name: [
26+
// Vendor libs go to the vendor.js chunk
27+
"vendor",
28+
29+
// Compatibility workaround with NativeScript 2.5 Android runtime
30+
// https://github.com/NativeScript/NativeScript/issues/3947
31+
"tns-java-classes",
32+
],
2733
}),
2834
// Define useful constants like TNS_WEBPACK
2935
new webpack.DefinePlugin({

Diff for: webpack.common.js.javascript.template

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ module.exports = function (platform, destinationApp) {
2222
new ExtractTextPlugin("app.css"),
2323
// Vendor libs go to the vendor.js chunk
2424
new webpack.optimize.CommonsChunkPlugin({
25-
name: ["vendor"]
25+
name: [
26+
// Vendor libs go to the vendor.js chunk
27+
"vendor",
28+
29+
// Compatibility workaround with NativeScript 2.5 Android runtime
30+
// https://github.com/NativeScript/NativeScript/issues/3947
31+
"tns-java-classes",
32+
],
2633
}),
2734
// Define useful constants like TNS_WEBPACK
2835
new webpack.DefinePlugin({

Diff for: webpack.common.js.typescript.template

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ module.exports = function (platform, destinationApp) {
2222
new ExtractTextPlugin("app.css"),
2323
// Vendor libs go to the vendor.js chunk
2424
new webpack.optimize.CommonsChunkPlugin({
25-
name: ["vendor"]
25+
name: [
26+
// Vendor libs go to the vendor.js chunk
27+
"vendor",
28+
29+
// Compatibility workaround with NativeScript 2.5 Android runtime
30+
// https://github.com/NativeScript/NativeScript/issues/3947
31+
"tns-java-classes",
32+
],
2633
}),
2734
// Define useful constants like TNS_WEBPACK
2835
new webpack.DefinePlugin({

0 commit comments

Comments
 (0)