Skip to content

Commit cf04a93

Browse files
TheLarkInnfilipesilva
authored andcommitted
build: use webpack for building apps.
This pull request replaces the underlying broccoli build system and then replaces it with webpack as the build and bundler. This will affect the following commands (however the user-level) functionality should go unchanged (besides unimplemented flags which will come after this PR.): ng build (with --env flag and --watch flag supported) ng serve (with --port flag supported) ng test / ng e2e The webpack configuration is blackboxed, and therefore users will not see a webpack.config.js file in their repository. Also this PR will bump the typescript version to 2.0 (beta). Fixes #909 #1155 #882
1 parent 8126785 commit cf04a93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2240
-6221
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
1+
import 'angular2-universal-polyfills';
12
import { provide } from '@angular/core';
23
import { APP_BASE_HREF } from '@angular/common';
34
import { APP_SHELL_BUILD_PROVIDERS } from '@angular/app-shell';
4-
import { AppComponent } from './app/';
5-
import {
6-
REQUEST_URL,
7-
ORIGIN_URL
5+
import {
6+
REQUEST_URL,
7+
ORIGIN_URL,
8+
Bootloader,
9+
BootloaderConfig,
10+
AppConfig
811
} from 'angular2-universal';
12+
import { AppComponent } from './app/';
913

10-
export const options = {
11-
directives: [
12-
// The component that will become the main App Shell
13-
AppComponent
14-
],
14+
const bootloaderConfig: BootloaderConfig = {
1515
platformProviders: [
1616
APP_SHELL_BUILD_PROVIDERS,
1717
provide(ORIGIN_URL, {
18-
useValue: ''
19-
})
18+
useValue: 'http://localhost:4200' // full urls are needed for node xhr
19+
}),
20+
provide(APP_BASE_HREF, { useValue: '/' }),
21+
],
22+
async: true,
23+
preboot: false
24+
}
25+
26+
const appConfig: AppConfig = {
27+
directives: [
28+
// The component that will become the main App Shell
29+
AppComponent
2030
],
2131
providers: [
2232
// What URL should Angular be treating the app as if navigating
23-
provide(APP_BASE_HREF, {useValue: '/'}),
24-
provide(REQUEST_URL, {useValue: '/'})
25-
],
26-
async: false,
27-
preboot: false
28-
};
33+
provide(REQUEST_URL, { useValue: '/' })
34+
]
35+
}
36+
37+
export function getBootloader() : Bootloader {
38+
return new Bootloader(bootloaderConfig);
39+
}
2940

41+
export function serialize(bootloader: Bootloader, template: string) : string {
42+
appConfig.template = template;
43+
return bootloader.serializeApplication(appConfig);
44+
}

addon/ng2/blueprints/mobile/files/__path__/system-import.js

-2
This file was deleted.

addon/ng2/blueprints/ng2/files/__path__/index.html

+12-39
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,26 @@
55
<title><%= jsComponentName %></title>
66
<base href="/">
77

8-
{{#unless environment.production}}
9-
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
10-
{{/unless}}
118
<meta name="viewport" content="width=device-width, initial-scale=1">
129
<link rel="icon" type="image/x-icon" href="favicon.ico"><% if (isMobile) { %>
1310
<meta name="apple-mobile-web-app-capable" content="yes">
1411
<meta name="theme-color" content="#000000">
1512
<link rel="manifest" href="/manifest.webapp">
16-
{{#each mobile.icons}}
17-
<link rel="{{rel}}" {{#if sizes}}sizes="{{sizes}}" {{/if}}href="{{href}}">
18-
{{/each}}
19-
20-
{{#if environment.production}}
21-
<script type="text/javascript">
22-
if ('serviceWorker' in navigator) {
23-
navigator.serviceWorker.register('/worker.js').catch(function(err) {
24-
console.log('Error installing service worker: ', err);
25-
});
26-
}
27-
</script>
28-
{{/if}}
13+
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
14+
<link rel="apple-touch-icon" sizes="57x57" href="/icons/apple-touch-icon-57x57.png">
15+
<link rel="apple-touch-icon" sizes="60x60" href="/icons/apple-touch-icon-60x60.png">
16+
<link rel="apple-touch-icon" sizes="72x72" href="/icons/apple-touch-icon-72x72.png">
17+
<link rel="apple-touch-icon" sizes="76x76" href="/icons/apple-touch-icon-76x76.png">
18+
<link rel="apple-touch-icon" sizes="114x114" href="/icons/apple-touch-icon-114x114.png">
19+
<link rel="apple-touch-icon" sizes="120x120" href="/icons/apple-touch-icon-120x120.png">
20+
<link rel="apple-touch-icon" sizes="144x144" href="/icons/apple-touch-icon-144x144.png">
21+
<link rel="apple-touch-icon" sizes="152x152" href="/icons/apple-touch-icon-152x152.png">
22+
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon-180x180.png">
23+
<link rel="apple-touch-startup-image" href="/icons/apple-touch-icon-180x180.png">
2924
<% } %>
25+
3026
</head>
3127
<body>
3228
<<%= prefix %>-root>Loading...</<%= prefix %>-root>
33-
<% if (isMobile) { %>
34-
{{#if environment.production}}
35-
<script src="/app-concat.js" async></script>
36-
{{else}}
37-
{{#each scripts.polyfills}}
38-
<script src="{{.}}"></script>
39-
{{/each}}
40-
<script>
41-
System.import('system-config.js').then(function () {
42-
System.import('main');
43-
}).catch(console.error.bind(console));
44-
</script>
45-
{{/if}}
46-
<% } else { %>
47-
{{#each scripts.polyfills}}
48-
<script src="{{.}}"></script>
49-
{{/each}}
50-
<script>
51-
System.import('system-config.js').then(function () {
52-
System.import('main');
53-
}).catch(console.error.bind(console));
54-
</script>
55-
<% } %>
5629
</body>
5730
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Prefer CoreJS over the polyfills above
2+
import 'core-js/es6';
3+
import 'core-js/es7/reflect';
4+
import 'zone.js/dist/zone';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
/*global jasmine, __karma__, window*/
3+
require('core-js/es6');
4+
require('core-js/es7/reflect');
5+
6+
// Typescript emit helpers polyfill
7+
require('ts-helpers');
8+
9+
require('zone.js/dist/zone');
10+
require('zone.js/dist/long-stack-trace-zone');
11+
require('zone.js/dist/jasmine-patch');
12+
require('zone.js/dist/async-test');
13+
require('zone.js/dist/fake-async-test');
14+
require('zone.js/dist/sync-test');
15+
16+
// RxJS
17+
require('rxjs/Rx');
18+
19+
Promise.all([
20+
System.import('@angular/core/testing'),
21+
System.import('@angular/platform-browser-dynamic/testing')
22+
]).then(function (providers) {
23+
let testing = providers[0];
24+
let testingBrowser = providers[1];
25+
26+
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
27+
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
28+
});
29+
30+
let testContext = require.context('../src', true, /\.spec\.ts/);
31+
32+
/*
33+
* get all the files, for each file, call the context function
34+
* that will require the file and load it up here. Context will
35+
* loop and require those spec files here
36+
*/
37+
function requireAll(requireContext) {
38+
return requireContext.keys().map(requireContext);
39+
}
40+
41+
requireAll(testContext);
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
{
2-
"compileOnSave": false,
32
"compilerOptions": {
3+
"baseUrl":"./src",
44
"declaration": false,
55
"emitDecoratorMetadata": true,
66
"experimentalDecorators": true,
7-
"mapRoot": "/",
8-
"module": "commonjs",
7+
"module": "es6",
8+
"target": "es5",
99
"moduleResolution": "node",
10-
"noEmitOnError": true,
11-
"noImplicitAny": false,
12-
"outDir": "../dist/",
10+
"outDir": "./dist/",
1311
"rootDir": ".",
14-
"sourceMap": true,
15-
"target": "es5",
16-
"inlineSources": true
12+
"sourceMap": true
1713
},
18-
19-
"files": [
20-
"main.ts",<% if (isMobile) { %>
21-
"main-app-shell.ts",<% } %>
22-
"typings.d.ts"
14+
"compileOnSave": false,
15+
"buildOnSave": false,
16+
"exclude": [
17+
"node_modules",
18+
"bower_components"
19+
],
20+
"includes": [
21+
"**.d.ts"
2322
]
2423
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
12
// Typings reference file, see links for more information
23
// https://github.com/typings/typings
34
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
45

5-
/// <reference path="<%= refToTypings %>/typings/browser.d.ts" />
6-
<% if(!isMobile) { %>declare var module: { id: string };<% } %>
6+
/// <reference path="<%= refToTypings %>/typings/index.d.ts" />
7+
/// <reference path="../node_modules/typescript/lib/lib.es2015.core.d.ts" />
8+
/// <reference path="../node_modules/typescript/lib/lib.es2015.collection.d.ts" />
9+
/// <reference path="../node_modules/typescript/lib/lib.es2015.promise.d.ts" />
10+
11+
<% if(!isMobile) { %>
12+
declare var System: any;
13+
declare var module: { id: string };
14+
declare var require: any;
15+
<% } %>
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Typescript emit helpers polyfill
2+
import 'ts-helpers';
3+
4+
import '@angular/core';
5+
import '@angular/common';
6+
import '@angular/compiler';
7+
import '@angular/http';
8+
import '@angular/router';
9+
import '@angular/platform-browser';
10+
import '@angular/platform-browser-dynamic';
11+
12+
<% if(isMobile) { %>
13+
import '@angular/app-shell';
14+
<% } %>
15+
16+
import 'rxjs/add/operator/map';
17+
import 'rxjs/add/operator/mergeMap';

addon/ng2/blueprints/ng2/files/angular-cli-build.js

-21
This file was deleted.

addon/ng2/blueprints/ng2/files/config/karma.conf.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Karma configuration file, see link for more information
2-
// https://karma-runner.github.io/0.13/config/configuration-file.html
3-
41
module.exports = function (config) {
52
config.set({
63
basePath: '..',
@@ -16,20 +13,7 @@ module.exports = function (config) {
1613
flags: ['--no-sandbox']
1714
}
1815
},
19-
files: [
20-
{ pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
21-
{ pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
22-
{ pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
23-
{ pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
24-
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
25-
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
26-
{ pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false },
27-
28-
{ pattern: 'config/karma-test-shim.js', included: true, watched: true },
29-
30-
// Distribution folder.
31-
{ pattern: 'dist/**/*', included: false, watched: true }
32-
],
16+
files: [],
3317
exclude: [
3418
// Vendor packages might include spec files. We don't want to use those.
3519
'dist/vendor/**/*.spec.js'

addon/ng2/blueprints/ng2/files/e2e/tsconfig.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
"declaration": false,
55
"emitDecoratorMetadata": true,
66
"experimentalDecorators": true,
7-
"mapRoot": "",
87
"module": "commonjs",
98
"moduleResolution": "node",
109
"noEmitOnError": true,
1110
"noImplicitAny": false,
1211
"rootDir": ".",
1312
"sourceMap": true,
14-
"sourceRoot": "/",
1513
"target": "es5"
1614
}
1715
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="../typings/main.d.ts" />
1+
/// <reference path="../typings/index.d.ts" />

addon/ng2/blueprints/ng2/files/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
"@angular/platform-browser": "2.0.0-rc.4",
2222
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
2323
"@angular/router": "3.0.0-beta.2",
24-
"es6-shim": "0.35.1",
25-
"reflect-metadata": "0.1.3",
24+
"ts-helpers": "^1.1.1",
2625
"rxjs": "5.0.0-beta.6",
2726
"systemjs": "0.19.26",
28-
"zone.js": "0.6.12"
27+
"zone.js": "0.6.12",
28+
"core-js": "^2.4.0"
2929
},
3030
"devDependencies": {<% if(isMobile) { %>
3131
"@angular/platform-server": "2.0.0-rc.4",
3232
"@angular/service-worker": "0.2.0",
3333
"@angular/app-shell": "0.0.0",
34-
"angular2-broccoli-prerender": "0.11.5",
3534
"angular2-universal":"0.104.5",
3635
"angular2-universal-polyfills": "0.4.1",
37-
"preboot": "2.0.10",<% } %>
38-
"angular-cli": "<%= version %>",
36+
"preboot": "2.1.2",
37+
"parse5": "1.5.1",<% } %>
38+
"angular-cli": "^<%= version %>",
3939
"codelyzer": "0.0.20",
4040
"ember-cli-inject-live-reload": "1.4.0",
4141
"jasmine-core": "2.4.1",
@@ -44,9 +44,9 @@
4444
"karma-chrome-launcher": "0.2.3",
4545
"karma-jasmine": "0.3.8",
4646
"protractor": "3.3.0",
47-
"ts-node": "0.5.5",
47+
"ts-node": "0.9.1",
4848
"tslint": "3.11.0",
49-
"typescript": "1.8.10",
50-
"typings": "0.8.1"<%= stylePackage %>
49+
"typescript": "^1.9.0-dev.20160627-1.0",
50+
"typings": "^1.3.1"<%= stylePackage %>
5151
}
5252
}
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"ambientDevDependencies": {
2+
"globalDevDependencies": {
33
"angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
44
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
55
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
66
},
7-
"ambientDependencies": {
8-
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>,
9-
"node": "registry:dt/node#4.0.0+20160509154515" <% } %>
7+
"globalDependencies": {
8+
<% if (isMobile) {%>"node": "registry:dt/node#6.0.0+20160621231320" <% } %>
109
}
1110
}

0 commit comments

Comments
 (0)