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

Commit

Permalink
fix(template): create empty tns-java-classes.js internally (#148)
Browse files Browse the repository at this point in the history
The tns-java-classes.js that is required for NativeScript 2.5 Android
builds is now create internally (GenerateStarterPlugin) instead as part
of CommonChunksPlugin.
  • Loading branch information
sis0k0 authored May 9, 2017
1 parent 71422f5 commit 0fd9159
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,19 @@ exports.GenerateBundleStarterPlugin.prototype = {
compiler.plugin("emit", function (compilation, cb) {
compilation.assets["package.json"] = plugin.generatePackageJson();
compilation.assets["starter.js"] = plugin.generateStarterModule();
plugin.generateTnsJavaClasses(compilation);

cb();
});
},
generateTnsJavaClasses: function (compilation) {
const path = compilation.compiler.outputPath;
const isAndroid = path.indexOf("android") > -1;

if (isAndroid) {
compilation.assets["tns-java-classes.js"] = new sources.RawSource("");
}
},
generatePackageJson: function () {
var packageJsonPath = path.join(this.webpackContext, "package.json");
var packageData = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
Expand Down
12 changes: 2 additions & 10 deletions webpack.common.js.angular.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,11 @@ module.exports = function (platform, destinationApp) {
// app.css bundle
entry["app.css"] = "./app.css";

// Vendor libs go to the vendor.js chunk
var commonsChunkNames = ["vendor"];

// Compatibility workaround with NativeScript 2.5 Android runtime
// https://github.com/NativeScript/NativeScript/issues/3947
if (platform === "android") {
commonsChunkNames.push("tns-java-classes");
}

var plugins = [
new ExtractTextPlugin("app.css"),
new webpack.optimize.CommonsChunkPlugin({
name: commonsChunkNames
// Vendor libs go to the vendor.js chunk
name: ["vendor"]
}),
// Define useful constants like TNS_WEBPACK
new webpack.DefinePlugin({
Expand Down
11 changes: 1 addition & 10 deletions webpack.common.js.javascript.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@ module.exports = function (platform, destinationApp) {
// app.css bundle
entry["app.css"] = "./app.css";

// Vendor libs go to the vendor.js chunk
var commonsChunkNames = ["vendor"];

// Compatibility workaround with NativeScript 2.5 Android runtime
// https://github.com/NativeScript/NativeScript/issues/3947
if (platform === "android") {
commonsChunkNames.push("tns-java-classes");
}

var plugins = [
new ExtractTextPlugin("app.css"),
new webpack.optimize.CommonsChunkPlugin({
name: commonsChunkNames
name: ["vendor"]
}),
// Define useful constants like TNS_WEBPACK
new webpack.DefinePlugin({
Expand Down
11 changes: 1 addition & 10 deletions webpack.common.js.typescript.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@ module.exports = function (platform, destinationApp) {
// app.css bundle
entry["app.css"] = "./app.css";

// Vendor libs go to the vendor.js chunk
var commonsChunkNames = ["vendor"];

// Compatibility workaround with NativeScript 2.5 Android runtime
// https://github.com/NativeScript/NativeScript/issues/3947
if (platform === "android") {
commonsChunkNames.push("tns-java-classes");
}

var plugins = [
new ExtractTextPlugin("app.css"),
new webpack.optimize.CommonsChunkPlugin({
name: commonsChunkNames
name: ["vendor"]
}),
// Define useful constants like TNS_WEBPACK
new webpack.DefinePlugin({
Expand Down

0 comments on commit 0fd9159

Please sign in to comment.