-
Notifications
You must be signed in to change notification settings - Fork 12k
build: use webpack for building apps. #1325
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
Changes from all commits
cf04a93
7786ed3
cf441a7
541d698
0d1c633
4189b9b
41653cf
f0e6e51
bdb8690
8ea2e72
8b6fdc9
87b4cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
import 'angular2-universal-polyfills'; | ||
import { provide } from '@angular/core'; | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { APP_SHELL_BUILD_PROVIDERS } from '@angular/app-shell'; | ||
import { AppComponent } from './app/'; | ||
import { | ||
REQUEST_URL, | ||
ORIGIN_URL | ||
import { | ||
REQUEST_URL, | ||
ORIGIN_URL, | ||
Bootloader, | ||
BootloaderConfig, | ||
AppConfig | ||
} from 'angular2-universal'; | ||
import { AppComponent } from './app/'; | ||
|
||
export const options = { | ||
directives: [ | ||
// The component that will become the main App Shell | ||
AppComponent | ||
], | ||
const bootloaderConfig: BootloaderConfig = { | ||
platformProviders: [ | ||
APP_SHELL_BUILD_PROVIDERS, | ||
provide(ORIGIN_URL, { | ||
useValue: '' | ||
}) | ||
useValue: 'http://localhost:4200' // full urls are needed for node xhr | ||
}), | ||
provide(APP_BASE_HREF, { useValue: '/' }), | ||
], | ||
async: true, | ||
preboot: false | ||
} | ||
|
||
const appConfig: AppConfig = { | ||
directives: [ | ||
// The component that will become the main App Shell | ||
AppComponent | ||
], | ||
providers: [ | ||
// What URL should Angular be treating the app as if navigating | ||
provide(APP_BASE_HREF, {useValue: '/'}), | ||
provide(REQUEST_URL, {useValue: '/'}) | ||
], | ||
async: false, | ||
preboot: false | ||
}; | ||
provide(REQUEST_URL, { useValue: '/' }) | ||
] | ||
} | ||
|
||
export function getBootloader() : Bootloader { | ||
return new Bootloader(bootloaderConfig); | ||
} | ||
|
||
export function serialize(bootloader: Bootloader, template: string) : string { | ||
appConfig.template = template; | ||
return bootloader.serializeApplication(appConfig); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Prefer CoreJS over the polyfills above | ||
import 'core-js/es6/symbol'; | ||
import 'core-js/es6/object'; | ||
import 'core-js/es6/function'; | ||
import 'core-js/es6/parse-int'; | ||
import 'core-js/es6/parse-float'; | ||
import 'core-js/es6/number'; | ||
import 'core-js/es6/math'; | ||
import 'core-js/es6/string'; | ||
import 'core-js/es6/date'; | ||
import 'core-js/es6/array'; | ||
import 'core-js/es6/regexp'; | ||
import 'core-js/es6/map'; | ||
import 'core-js/es6/set'; | ||
import 'core-js/es6/reflect'; | ||
|
||
import 'core-js/es7/reflect'; | ||
import 'zone.js/dist/zone'; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/*global jasmine, __karma__, window*/ | ||
import 'core-js/es6'; | ||
import 'core-js/es7/reflect'; | ||
|
||
// Typescript emit helpers polyfill | ||
import 'ts-helpers'; | ||
|
||
import 'zone.js/dist/zone'; | ||
import 'zone.js/dist/long-stack-trace-zone'; | ||
import 'zone.js/dist/jasmine-patch'; | ||
import 'zone.js/dist/async-test'; | ||
import 'zone.js/dist/fake-async-test'; | ||
import 'zone.js/dist/sync-test'; | ||
|
||
// RxJS | ||
import 'rxjs/Rx'; | ||
|
||
Promise.all([ | ||
System.import('@angular/core/testing'), | ||
System.import('@angular/platform-browser-dynamic/testing') | ||
]).then(function (providers) { | ||
let testing = providers[0]; | ||
let testingBrowser = providers[1]; | ||
|
||
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, | ||
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); | ||
}); | ||
|
||
let testContext = require.context('../src', true, /\.spec\.ts/); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here - this is common/webpack specific code... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if there is an alternative for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an alternative to bundling files in webpack for running in karma? |
||
|
||
/* | ||
* get all the files, for each file, call the context function | ||
* that will require the file and load it up here. Context will | ||
* loop and require those spec files here | ||
*/ | ||
function requireAll(requireContext) { | ||
return requireContext.keys().map(requireContext); | ||
} | ||
|
||
requireAll(testContext); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl":"./src", | ||
"declaration": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"mapRoot": "/", | ||
"module": "commonjs", | ||
"module": "es6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tree shake There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going on here? We don't care about TypeScript maps? Even so, we probably want to support running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nvm, misread. Not sure why this is being taken off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out it was further down, but misspelled. Fixed. |
||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noImplicitAny": false, | ||
"outDir": "../dist/", | ||
"outDir": "./dist/", | ||
"rootDir": ".", | ||
"sourceMap": true, | ||
"target": "es5", | ||
"inlineSources": true | ||
"mapRoot": "/", | ||
"inlinesource": true | ||
}, | ||
|
||
"files": [ | ||
"main.ts",<% if (isMobile) { %> | ||
"main-app-shell.ts",<% } %> | ||
"typings.d.ts" | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"exclude": [ | ||
"node_modules", | ||
"bower_components" | ||
], | ||
"includes": [ | ||
"**.d.ts" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
|
||
// Typings reference file, see links for more information | ||
// https://github.com/typings/typings | ||
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html | ||
|
||
/// <reference path="<%= refToTypings %>/typings/browser.d.ts" /> | ||
<% if(!isMobile) { %>declare var module: { id: string };<% } %> | ||
/// <reference path="<%= refToTypings %>/typings/index.d.ts" /> | ||
/// <reference path="../node_modules/typescript/lib/lib.es2015.core.d.ts" /> | ||
/// <reference path="../node_modules/typescript/lib/lib.es2015.collection.d.ts" /> | ||
/// <reference path="../node_modules/typescript/lib/lib.es2015.promise.d.ts" /> | ||
|
||
<% if(!isMobile) { %> | ||
declare var System: any; | ||
declare var module: { id: string }; | ||
declare var require: any; | ||
<% } %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Typescript emit helpers polyfill | ||
import 'ts-helpers'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous note about ts-helpers. |
||
|
||
import '@angular/core'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we using the side-effect-y version of there in a vendor.ts file? this forces inclusion of a bunch of code somebody may never use? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By putting this imports at vendor we are able to extract a cached vendor file with all vendor dependencies. That way you can update your app bundle without having to load the vendors again. |
||
import '@angular/common'; | ||
import '@angular/compiler'; | ||
import '@angular/http'; | ||
import '@angular/router'; | ||
import '@angular/platform-browser'; | ||
import '@angular/platform-browser-dynamic'; | ||
|
||
<% if(isMobile) { %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a weird thing to be doing dynamically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not dynamic, it's a template file. A project generated with |
||
import '@angular/app-shell'; | ||
<% } %> | ||
|
||
import 'rxjs/add/operator/map'; | ||
import 'rxjs/add/operator/mergeMap'; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,12 @@ | |
"declaration": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"mapRoot": "", | ||
"module": "commonjs", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment above. Any reason to remove those? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out this one needed to go away, because e2e is using tsconfig and it auto-sets the |
||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noImplicitAny": false, | ||
"rootDir": ".", | ||
"sourceMap": true, | ||
"sourceRoot": "/", | ||
"target": "es5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/// <reference path="../typings/main.d.ts" /> | ||
/// <reference path="../typings/index.d.ts" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
{ | ||
"ambientDevDependencies": { | ||
"globalDevDependencies": { | ||
"angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", | ||
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438", | ||
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" | ||
}, | ||
"ambientDependencies": { | ||
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>, | ||
"node": "registry:dt/node#4.0.0+20160509154515" <% } %> | ||
"globalDependencies": { | ||
<% if (isMobile) {%>"node": "registry:dt/node#6.0.0+20160621231320" <% } %> | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm still not comfortable with this being import/require'd yet, there's an increasing number of Zone issues we're seeing with people require'ing Zone.