Skip to content

Webpack plugin for ng-sample #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nativescript-angular*.tgz
bin/dist
node_modules
tags
Expand Down
2 changes: 2 additions & 0 deletions ng-sample/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "tns-template-hello-world",
"main": "starter.js",
"bundleMain": "app.js",
"bundleOutput": "bundle.js",
"version": "1.2.0",
"author": "Telerik <[email protected]>",
"description": "Nativescript hello-world project template",
Expand Down
1 change: 1 addition & 0 deletions ng-sample/hooks/after-prepare/nativescript-dev-webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("nativescript-dev-webpack/after-prepare-hook.js");
43 changes: 0 additions & 43 deletions ng-sample/hooks/after-prepare/webpack.js

This file was deleted.

7 changes: 3 additions & 4 deletions ng-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@
"grunt-shell": "1.1.2",
"grunt-ts": "5.0.0-beta.5",
"nativescript-dev-typescript": "^0.3.1",
"shelljs": "^0.5.3",
"typescript": "1.8.2",
"webpack": "^1.12.9"
"nativescript-dev-webpack": "0.0.7",
"typescript": "1.8.2"
},
"nativescript": {
"id": "org.nativescript.ngsample",
"tns-android": {
"version": "1.7.1"
}
}
}
}
1 change: 1 addition & 0 deletions ng-sample/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"experimentalDecorators": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"noImplicitUseStrict": true,
"noEmitOnError": true
},
"exclude": [
Expand Down
53 changes: 4 additions & 49 deletions ng-sample/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,5 @@
var path = require("path");
var webpack = require("webpack");
var bundler = require("nativescript-dev-webpack");


console.log('PROJECT_DIR: ' + process.env.PROJECT_DIR);

module.exports = {
//context: "./platforms/android/src/main/assets/app",
context: process.env.PROJECT_DIR,
entry: {
app: "./app",
},
output: {
path: __dirname,
pathinfo: true,
libraryTarget: "commonjs2",
filename: "bundle.js"
},
externals: [
function(context, request, callback) {
if (/browserify|crypto/.test(request)) {
return callback(null, "var {}");
} else {
callback();
}
}
],
resolve: {
extensions: ["", ".js"],
packageMains: ["main"],
modulesDirectories: [
"tns_modules",
]
},
module: {
loaders: [
]
},
plugins: [
new webpack.DefinePlugin({
global: 'global',
__dirname: '__dirname'
}),
//new webpack.optimize.UglifyJsPlugin({
//compress: {
//warnings: true
//}
//})
]
};
module.exports = bundler.getConfig({
// TODO: add project-specific webpack settings here...
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-angular",
"version": "0.0.39",
"version": "0.0.40",
"description": "",
"homepage": "http://www.telerik.com",
"bugs": "http://www.telerik.com",
Expand Down Expand Up @@ -37,7 +37,7 @@
"typescript": "1.8.2"
},
"peerDependencies": {
"tns-core-modules": ">=2.0.0 || >=2.0.0-2016 || >=2.0.0-angular-2"
"tns-core-modules": ">=2.0.0 || >=2.0.0-2016 || >=2.0.0-angular-3"
},
"nativescript": {}
}
7 changes: 4 additions & 3 deletions src/nativescript-angular/application.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//Import globals before the zone, so the latter can patch the global functions
import 'globals';

//prevent a crash in zone patches. pretend we're node.js
global.process = {};
const oldToString = Object.prototype.toString;
Expand All @@ -10,6 +7,10 @@ Object.prototype.toString = function() {
import "zone.js/dist/zone.js"
Object.prototype.toString = oldToString;
delete global.process;
//
//Import globals after the zone, so the latter can't patch everything there.
//The patchables should already be zone-aware already.
import 'globals';

import 'reflect-metadata';
import './polyfills/array';
Expand Down