Skip to content

Commit 2f38efa

Browse files
committedApr 13, 2017
updated polyfills and prod env
1 parent 78c2159 commit 2f38efa

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed
 

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"start": "npm run watch",
88
"watch": "webpack --watch --progress --profile",
99
"build": "webpack --progress --profile",
10+
"build:prod": "NODE_ENV=\"production\" webpack --progress --profile",
1011
"test": "echo \"Error: no test specified\" && exit 1"
1112
},
1213
"repository": {
@@ -55,7 +56,7 @@
5556
"zone.js": "^0.8.5"
5657
},
5758
"devDependencies": {
58-
"@types/requirejs": "^2.1.29",
59+
"@types/node": "^7.0.12",
5960
"to-string-loader": "^1.1.5"
6061
}
6162
}

‎source/index.ts

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
/// <reference path="../node_modules/@types/requirejs/index.d.ts" />
1+
/// <reference path="../node_modules/@types/node/index.d.ts" />
22

3-
//import { enableProdMode } from '@angular/core';
3+
// polyfills
44
import 'ts-helpers';
55
import 'reflect-metadata';
66
import 'core-js/client/shim';
7-
import 'zone.js';
7+
import 'zone.js/dist/zone';
8+
9+
import { enableProdMode } from '@angular/core';
810
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
911
import AppModule from './app/app.module';
1012

11-
// depending on the env mode, enable prod mode or add debugging modules
12-
// if (ENV.production === 'production') {
13-
// enableProdMode();
14-
// }
13+
declare const ENV: {
14+
production: boolean;
15+
};
1516

16-
export function main() {
17-
return platformBrowserDynamic().bootstrapModule(AppModule);
17+
if (ENV.production) {
18+
enableProdMode();
19+
} else {
20+
Error['stackTraceLimit'] = Infinity;
21+
require('zone.js/dist/long-stack-trace-zone');
1822
}
1923

20-
main();
24+
function deployApp() {
25+
return platformBrowserDynamic().bootstrapModule(AppModule);
26+
}
2127

22-
// if (document.readyState === 'complete') {
23-
// main();
24-
// } else {
25-
// document.addEventListener('DOMContentLoaded', main);
26-
// }
28+
if (document.readyState !== 'loading') {
29+
deployApp();
30+
} else {
31+
document.addEventListener('DOMContentLoaded', deployApp);
32+
}

‎webpack.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const HtmlWebpackPlugin = require('html-webpack-plugin');
21
const CopyWebpackPlugin = require('copy-webpack-plugin');
32
const ExtractTextPlugin = require('extract-text-webpack-plugin');
43
const CleanWebpackPlugin = require('clean-webpack-plugin');

‎yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
version "4.0.1"
3535
resolved "https://registry.yarnpkg.com/@angular/router/-/router-4.0.1.tgz#2d73a4b6c40e18d5cd0bfd1f20222af64a11c11e"
3636

37-
"@types/requirejs@^2.1.29":
38-
version "2.1.29"
39-
resolved "https://registry.yarnpkg.com/@types/requirejs/-/requirejs-2.1.29.tgz#bc48bc833c079c2c24ba6afbca6d3a03b3f4e2f3"
37+
"@types/node@^7.0.12":
38+
version "7.0.12"
39+
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9"
4040

4141
abbrev@1:
4242
version "1.1.0"

0 commit comments

Comments
 (0)
Please sign in to comment.