Skip to content

Commit 1aeba9e

Browse files
authored
chore: update ns-webpack to next (#255)
1 parent d6ba1b9 commit 1aeba9e

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

app/vendor-platform.android.ts

+9-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
// Resolve JavaScript classes that extend a Java class, and need to resolve
2-
// their JavaScript module from a bundled script. For example:
3-
// NativeScriptApplication, NativeScriptActivity, etc.
4-
//
5-
// This module gets bundled together with the rest of the app code and the
6-
// `require` calls get resolved to the correct bundling import call.
7-
//
8-
// At runtime the module gets loaded *before* the rest of the app code, so code
9-
// placed here needs to be careful about its dependencies.
10-
111
require("application");
12-
require("ui/frame");
13-
require("ui/frame/activity");
142

15-
if (global.TNS_WEBPACK) {
16-
global.__requireOverride = function (name, dir) {
17-
if (name === "./tns_modules/application/application.js") {
18-
return require("application");
19-
} else if (name === "./tns_modules/ui/frame/frame.js") {
20-
return require("ui/frame");
21-
} else if (name === "./tns_modules/ui/frame/activity.js") {
22-
return require("ui/frame/activity");
23-
}
24-
};
3+
if (!global["__snapshot"]) {
4+
// In case snapshot generation is enabled these modules will get into the bundle
5+
// but will not be required/evaluated.
6+
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
7+
// This way, they will be evaluated on app start as early as possible.
8+
9+
require("ui/frame");
10+
require("ui/frame/activity");
2511
}
12+

package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
"scripts": {
2828
"tslint": "tslint -p tsconfig.json",
2929
"ns-bundle": "ns-bundle",
30-
"start-android-bundle": "npm run ns-bundle --android --start-app",
31-
"start-ios-bundle": "npm run ns-bundle --ios --start-app",
30+
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
31+
"start-android-bundle": "npm run ns-bundle --android --run-app",
32+
"start-ios-bundle": "npm run ns-bundle --ios --run-app",
3233
"build-android-bundle": "npm run ns-bundle --android --build-app",
3334
"build-ios-bundle": "npm run ns-bundle --ios --build-app",
34-
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app"
35+
"generate-android-snapshot": "generate-android-snapshot --projectRoot . --targetArchs arm,arm64 --install"
3536
},
3637
"dependencies": {
3738
"@angular/common": "~4.1.3",
@@ -68,12 +69,12 @@
6869
"lazy": "1.0.11",
6970
"nativescript-css-loader": "~0.26.0",
7071
"nativescript-dev-typescript": "^0.4.5",
71-
"nativescript-dev-webpack": "^0.6.1",
72+
"nativescript-dev-webpack": "next",
7273
"raw-loader": "~0.5.1",
7374
"resolve-url-loader": "~2.0.2",
7475
"tslint": "^5.4.2",
75-
"typescript": "^2.3.4",
76-
"webpack": "^2.6.1",
77-
"webpack-sources": "^1.0.1"
76+
"typescript": "~2.3.4",
77+
"webpack": "~2.6.1",
78+
"webpack-sources": "~1.0.1"
7879
}
79-
}
80+
}

webpack.config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = env => {
3131
const plugins = getPlugins(platform, env);
3232
const extensions = getExtensions(platform);
3333

34-
return {
34+
const config = {
3535
context: resolve("./app"),
3636
target: nativescriptTarget,
3737
entry,
@@ -60,6 +60,19 @@ module.exports = env => {
6060
module: { rules },
6161
plugins,
6262
};
63+
64+
if (env.snapshot) {
65+
plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
66+
chunk: "vendor",
67+
projectRoot: __dirname,
68+
webpackConfig: config,
69+
targetArchs: ["arm", "arm64"],
70+
tnsJavaClassesOptions: { packages: ["tns-core-modules" ] },
71+
useLibs: false
72+
}));
73+
}
74+
75+
return config;
6376
};
6477

6578

0 commit comments

Comments
 (0)