Skip to content

Commit 3e4f498

Browse files
committed
startup-test webpack build
1 parent c389ae6 commit 3e4f498

File tree

8 files changed

+105
-40
lines changed

8 files changed

+105
-40
lines changed

startup-test/app/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
var profiling = require('./profiling');
22
profiling.start('application-start');
33

4+
var reflectMetadata = require("reflect-metadata");
5+
var global = require("globals");
6+
var page = require("ui/page");
7+
console.log('page module: ' + page);
8+
49
var application = require("application");
510
application.on(application.launchEvent, function() {
611
//console.log('launched!');
712
//profiling.stop('application-start');
813
});
9-
application.mainModule = "main-page";
14+
15+
var moduleLoader = require("utils/module-loader");
16+
moduleLoader.registerModule("./main-page", function () { return require("./main-page"); });
17+
18+
application.mainModule = "./main-page";
1019
application.cssFile = "./app.css";
1120
application.start();

startup-test/app/main-page.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
var profiling = require('./profiling');
2-
var vmModule = require("./main-view-model");
3-
function pageLoaded(args) {
4-
profiling.stop('application-start');
5-
var page = args.object;
6-
page.bindingContext = vmModule.mainViewModel;
7-
}
8-
exports.pageLoaded = pageLoaded;
2+
console.log('import main-page');
3+
4+
exports.createPage = function() {
5+
console.dump(page);
6+
var pageModule = require('ui/page');
7+
var textView = require('ui/text-view');
8+
var page = new pageModule.Page();
9+
page.on('loaded', function() {
10+
profiling.stop('application-start');
11+
console.log('Page loaded');
12+
13+
var box = new textView.TextView();
14+
box.text = "Хуяк хуяк!";
15+
16+
page.content = box;
17+
});
18+
return page;
19+
};

startup-test/app/main-page.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

startup-test/app/main-view-model.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

startup-test/app/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "tns-template-hello-world",
3-
"main": "app.js",
43
"jsoptions": "--expose_gc",
54
"version": "1.4.0",
65
"author": "Telerik <support@telerik.com>",
@@ -23,4 +22,4 @@
2322
"url": "https://github.com/NativeScript/template-hello-world/issues"
2423
},
2524
"homepage": "https://github.com/NativeScript/template-hello-world"
26-
}
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var path = require("path");
2+
var shelljs = require("shelljs");
3+
4+
module.exports = function (logger, platformsData, projectData, hookArgs) {
5+
var platformData = platformsData.getPlatformData(hookArgs.platform.toLowerCase());
6+
var outDir = platformData.appDestinationDirectoryPath;
7+
console.log('outDir: ' + outDir);
8+
console.log('pwd: ' + shelljs.pwd());
9+
10+
return new Promise(function (resolve, reject) {
11+
return shelljs.exec("webpack", function(code, output) {
12+
if (code == 0) {
13+
//shelljs.rm("-rf", path.join(outDir, "app", "*"))
14+
shelljs.mv("bundle.js", path.join(outDir, "app", "index.js"))
15+
16+
resolve();
17+
} else {
18+
console.log('webpack failed.');
19+
reject();
20+
}
21+
});
22+
});
23+
}

startup-test/package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
"nativescript": {
33
"id": "org.nativescript.startuptest",
44
"tns-android": {
5-
"version": "1.4.0"
5+
"version": "1.5.0"
66
}
77
},
88
"dependencies": {
9-
"tns-core-modules": "1.4.0"
9+
"@reactivex/rxjs": "5.0.0-alpha.7",
10+
"parse5": "1.4.2",
11+
"punycode": "1.3.2",
12+
"querystring": "0.2.0",
13+
"url": "0.10.3",
14+
"reflect-metadata": "0.1.2",
15+
"zone.js": "0.5.8"
16+
},
17+
"devDependencies": {
18+
"shelljs": "^0.5.3"
1019
}
1120
}

startup-test/webpack.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var path = require("path");
2+
3+
module.exports = {
4+
context: "./platforms/android/src/main/assets/app",
5+
entry: {
6+
app: "./app",
7+
},
8+
output: {
9+
path: __dirname,
10+
pathinfo: true,
11+
libraryTarget: "commonjs2",
12+
filename: "bundle.js"
13+
},
14+
//externals: {
15+
//"crypto": "crypto",
16+
//"process/browser.js": "process",
17+
//"module.js": "module"
18+
//},
19+
externals: [
20+
function(context, request, callback) {
21+
//if (/\/module\.js$/.test(request))
22+
//return callback(null, "var module");
23+
//else if (/browserify|crypto/.test(request)) {
24+
if (/browserify|crypto/.test(request)) {
25+
return callback(null, "var {}");
26+
} else {
27+
callback();
28+
}
29+
}
30+
],
31+
resolve: {
32+
extensions: ["", ".js"],
33+
packageMains: ["main"],
34+
modulesDirectories: [
35+
"tns_modules",
36+
]
37+
},
38+
module: {
39+
loaders: [
40+
]
41+
}
42+
}

0 commit comments

Comments
 (0)