Skip to content

Commit b078954

Browse files
committed
Merge pull request #160 from NativeScript/hdeshev/webpack-plugin
Webpack plugin for ng-sample
2 parents 7cf3327 + c8e7325 commit b078954

File tree

9 files changed

+18
-101
lines changed

9 files changed

+18
-101
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
nativescript-angular*.tgz
12
bin/dist
23
node_modules
34
tags

Diff for: ng-sample/app/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "tns-template-hello-world",
33
"main": "starter.js",
4+
"bundleMain": "app.js",
5+
"bundleOutput": "bundle.js",
46
"version": "1.2.0",
57
"author": "Telerik <[email protected]>",
68
"description": "Nativescript hello-world project template",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("nativescript-dev-webpack/after-prepare-hook.js");

Diff for: ng-sample/hooks/after-prepare/webpack.js

-43
This file was deleted.

Diff for: ng-sample/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@
4141
"grunt-shell": "1.1.2",
4242
"grunt-ts": "5.0.0-beta.5",
4343
"nativescript-dev-typescript": "^0.3.1",
44-
"shelljs": "^0.5.3",
45-
"typescript": "1.8.2",
46-
"webpack": "^1.12.9"
44+
"nativescript-dev-webpack": "0.0.7",
45+
"typescript": "1.8.2"
4746
},
4847
"nativescript": {
4948
"id": "org.nativescript.ngsample",
5049
"tns-android": {
5150
"version": "1.7.1"
5251
}
5352
}
54-
}
53+
}

Diff for: ng-sample/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"experimentalDecorators": true,
99
"removeComments": false,
1010
"emitDecoratorMetadata": true,
11+
"noImplicitUseStrict": true,
1112
"noEmitOnError": true
1213
},
1314
"exclude": [

Diff for: ng-sample/webpack.config.js

+4-49
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,5 @@
1-
var path = require("path");
2-
var webpack = require("webpack");
1+
var bundler = require("nativescript-dev-webpack");
32

4-
5-
console.log('PROJECT_DIR: ' + process.env.PROJECT_DIR);
6-
7-
module.exports = {
8-
//context: "./platforms/android/src/main/assets/app",
9-
context: process.env.PROJECT_DIR,
10-
entry: {
11-
app: "./app",
12-
},
13-
output: {
14-
path: __dirname,
15-
pathinfo: true,
16-
libraryTarget: "commonjs2",
17-
filename: "bundle.js"
18-
},
19-
externals: [
20-
function(context, request, callback) {
21-
if (/browserify|crypto/.test(request)) {
22-
return callback(null, "var {}");
23-
} else {
24-
callback();
25-
}
26-
}
27-
],
28-
resolve: {
29-
extensions: ["", ".js"],
30-
packageMains: ["main"],
31-
modulesDirectories: [
32-
"tns_modules",
33-
]
34-
},
35-
module: {
36-
loaders: [
37-
]
38-
},
39-
plugins: [
40-
new webpack.DefinePlugin({
41-
global: 'global',
42-
__dirname: '__dirname'
43-
}),
44-
//new webpack.optimize.UglifyJsPlugin({
45-
//compress: {
46-
//warnings: true
47-
//}
48-
//})
49-
]
50-
};
3+
module.exports = bundler.getConfig({
4+
// TODO: add project-specific webpack settings here...
5+
});

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-angular",
3-
"version": "0.0.39",
3+
"version": "0.0.40",
44
"description": "",
55
"homepage": "http://www.telerik.com",
66
"bugs": "http://www.telerik.com",
@@ -37,7 +37,7 @@
3737
"typescript": "1.8.2"
3838
},
3939
"peerDependencies": {
40-
"tns-core-modules": ">=2.0.0 || >=2.0.0-2016 || >=2.0.0-angular-2"
40+
"tns-core-modules": ">=2.0.0 || >=2.0.0-2016 || >=2.0.0-angular-3"
4141
},
4242
"nativescript": {}
4343
}

Diff for: src/nativescript-angular/application.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//Import globals before the zone, so the latter can patch the global functions
2-
import 'globals';
3-
41
//prevent a crash in zone patches. pretend we're node.js
52
global.process = {};
63
const oldToString = Object.prototype.toString;
@@ -10,6 +7,10 @@ Object.prototype.toString = function() {
107
import "zone.js/dist/zone.js"
118
Object.prototype.toString = oldToString;
129
delete global.process;
10+
//
11+
//Import globals after the zone, so the latter can't patch everything there.
12+
//The patchables should already be zone-aware already.
13+
import 'globals';
1314

1415
import 'reflect-metadata';
1516
import './polyfills/array';

0 commit comments

Comments
 (0)