├── .gitignore
├── README.md
├── app
├── app.component.ts
├── app.module.ts
└── main.ts
├── index.html
├── package.json
├── rollup.config.js
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | npm-debug.log
4 | typings
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # How to use?
2 |
3 | **Updated to Angular final!**
4 |
5 | ```bash
6 | npm i
7 | npm run build_prod
8 | npm run http-server
9 | ```
10 |
11 | For further information take a look at [this blog post](http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/).
12 |
13 | # License
14 |
15 | MIT
16 |
17 |
--------------------------------------------------------------------------------
/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'my-app',
5 | template: 'Hello world!'
6 | })
7 | export class AppComponent {}
8 |
9 |
--------------------------------------------------------------------------------
/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { BrowserModule } from '@angular/platform-browser';
3 |
4 | import { AppComponent } from './app.component';
5 |
6 | @NgModule({
7 | imports: [BrowserModule],
8 | bootstrap: [AppComponent],
9 | declarations: [AppComponent],
10 | })
11 | export class AppModule {}
12 |
13 |
--------------------------------------------------------------------------------
/app/main.ts:
--------------------------------------------------------------------------------
1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2 | import { AppModule } from './app.module';
3 |
4 | platformBrowserDynamic().bootstrapModule(AppModule);
5 |
6 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular2-min",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "clean": "rm -rf dist",
9 | "clean": "rm -rf dist",
10 | "serve": "http-server . -p 5557",
11 | "build": "tsc -p tsconfig.json",
12 | "rollup": "rollup -f iife -c rollup.config.js -o dist/bundle.es2015.js",
13 | "es5": "tsc --target es5 --allowJs dist/bundle.es2015.js --out dist/bundle.js",
14 | "minify": "uglifyjs dist/bundle.js --screw-ie8 --compress --mangle --output dist/bundle.min.js",
15 | "build_prod": "npm run clean && npm run build && npm run rollup && npm run es5 && npm run minify"
16 | },
17 | "author": "Minko Gechev ",
18 | "license": "MIT",
19 | "devDependencies": {
20 | "@angular/compiler-cli": "^2.1.0",
21 | "@angular/platform-server": "^2.1.0",
22 | "@types/core-js": "^0.9.34",
23 | "browserify": "^13.0.1",
24 | "http-server": "^0.9.0",
25 | "rollup": "^0.36.3",
26 | "rollup-plugin-node-resolve": "^2.0.0",
27 | "typescript": "^2.0.3",
28 | "uglifyjs": "^2.4.10"
29 | },
30 | "dependencies": {
31 | "@angular/common": "^2.1.0",
32 | "@angular/compiler": "^2.1.0",
33 | "@angular/core": "^2.1.0",
34 | "@angular/platform-browser": "^2.1.0",
35 | "@angular/platform-browser-dynamic": "^2.1.0",
36 | "es6-shim": "^0.35.1",
37 | "reflect-metadata": "^0.1.3",
38 | "rxjs": "^5.0.0-beta.12",
39 | "rxjs-es": "^5.0.0-beta.12",
40 | "systemjs": "^0.19.31",
41 | "zone.js": "^0.6.25"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import nodeResolve from 'rollup-plugin-node-resolve';
2 |
3 | class RollupNG2 {
4 | resolveId(id, from) {
5 | if (id.startsWith('rxjs/')) {
6 | return `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`;
7 | }
8 | return undefined;
9 | }
10 | }
11 |
12 | const rollupNG2 = () => new RollupNG2();
13 |
14 | export default {
15 | entry: 'dist/main.js',
16 | sourceMap: true,
17 | treeshake: true,
18 | moduleName: 'main',
19 | plugins: [
20 | rollupNG2(),
21 | nodeResolve({
22 | jsnext: true, main: true, module: true
23 | })
24 | ]
25 | };
26 |
27 |
28 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "module": "es2015",
5 | "moduleResolution": "node",
6 | "declaration": false,
7 | "removeComments": true,
8 | "noLib": false,
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "lib": ["es6", "es2015", "dom"],
12 | "sourceMap": true,
13 | "pretty": true,
14 | "allowUnreachableCode": false,
15 | "allowUnusedLabels": false,
16 | "noImplicitAny": true,
17 | "noImplicitReturns": true,
18 | "noImplicitUseStrict": false,
19 | "noFallthroughCasesInSwitch": true,
20 | "outDir": "./dist",
21 | "typeRoots": [
22 | "./node_modules/@types",
23 | "./node_modules"
24 | ],
25 | "types": [
26 | ]
27 | },
28 | "files": [
29 | "app/main.ts"
30 | ],
31 | "exclude": [
32 | "node_modules",
33 | "dist",
34 | "src"
35 | ],
36 | "compileOnSave": false
37 | }
38 |
--------------------------------------------------------------------------------