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

Commit 0fd9159

Browse files
authored
fix(template): create empty tns-java-classes.js internally (#148)
The tns-java-classes.js that is required for NativeScript 2.5 Android builds is now create internally (GenerateStarterPlugin) instead as part of CommonChunksPlugin.
1 parent 71422f5 commit 0fd9159

4 files changed

+13
-30
lines changed

Diff for: index.js

+9
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,19 @@ exports.GenerateBundleStarterPlugin.prototype = {
5252
compiler.plugin("emit", function (compilation, cb) {
5353
compilation.assets["package.json"] = plugin.generatePackageJson();
5454
compilation.assets["starter.js"] = plugin.generateStarterModule();
55+
plugin.generateTnsJavaClasses(compilation);
5556

5657
cb();
5758
});
5859
},
60+
generateTnsJavaClasses: function (compilation) {
61+
const path = compilation.compiler.outputPath;
62+
const isAndroid = path.indexOf("android") > -1;
63+
64+
if (isAndroid) {
65+
compilation.assets["tns-java-classes.js"] = new sources.RawSource("");
66+
}
67+
},
5968
generatePackageJson: function () {
6069
var packageJsonPath = path.join(this.webpackContext, "package.json");
6170
var packageData = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,11 @@ module.exports = function (platform, destinationApp) {
1919
// app.css bundle
2020
entry["app.css"] = "./app.css";
2121

22-
// Vendor libs go to the vendor.js chunk
23-
var commonsChunkNames = ["vendor"];
24-
25-
// Compatibility workaround with NativeScript 2.5 Android runtime
26-
// https://github.com/NativeScript/NativeScript/issues/3947
27-
if (platform === "android") {
28-
commonsChunkNames.push("tns-java-classes");
29-
}
30-
3122
var plugins = [
3223
new ExtractTextPlugin("app.css"),
3324
new webpack.optimize.CommonsChunkPlugin({
34-
name: commonsChunkNames
25+
// Vendor libs go to the vendor.js chunk
26+
name: ["vendor"]
3527
}),
3628
// Define useful constants like TNS_WEBPACK
3729
new webpack.DefinePlugin({

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,10 @@ module.exports = function (platform, destinationApp) {
1818
// app.css bundle
1919
entry["app.css"] = "./app.css";
2020

21-
// Vendor libs go to the vendor.js chunk
22-
var commonsChunkNames = ["vendor"];
23-
24-
// Compatibility workaround with NativeScript 2.5 Android runtime
25-
// https://github.com/NativeScript/NativeScript/issues/3947
26-
if (platform === "android") {
27-
commonsChunkNames.push("tns-java-classes");
28-
}
29-
3021
var plugins = [
3122
new ExtractTextPlugin("app.css"),
3223
new webpack.optimize.CommonsChunkPlugin({
33-
name: commonsChunkNames
24+
name: ["vendor"]
3425
}),
3526
// Define useful constants like TNS_WEBPACK
3627
new webpack.DefinePlugin({

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,10 @@ module.exports = function (platform, destinationApp) {
1818
// app.css bundle
1919
entry["app.css"] = "./app.css";
2020

21-
// Vendor libs go to the vendor.js chunk
22-
var commonsChunkNames = ["vendor"];
23-
24-
// Compatibility workaround with NativeScript 2.5 Android runtime
25-
// https://github.com/NativeScript/NativeScript/issues/3947
26-
if (platform === "android") {
27-
commonsChunkNames.push("tns-java-classes");
28-
}
29-
3021
var plugins = [
3122
new ExtractTextPlugin("app.css"),
3223
new webpack.optimize.CommonsChunkPlugin({
33-
name: commonsChunkNames
24+
name: ["vendor"]
3425
}),
3526
// Define useful constants like TNS_WEBPACK
3627
new webpack.DefinePlugin({

0 commit comments

Comments
 (0)