-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Most developer workflows are based around CJS (Browserify or WebPack) and not System.js. Since System.js can consume cjs bundles, I suggest we replace our System.register bundle with a CJS bundle. In this case, developers that use Browserify or WebPack will be able to use it, and it should still work with System.
Notes:
- System.register has a lot of overhead comparing to CJS. My naive measurements showed the difference is about 18%.
- When using a CJS bundle, you cannot important submodudles, only "angular2/angular2". I think this is an advantage cause it prevents users from depending on private API.
Finally, once we produce a CJS bundle, I think we should change our Getting Started guide to use WebPack instead of System.js. The reason is WebPack provides a lot better experience out of the box (including TypeScript and Babel).
The WebPack config for an Angular 2 project written with TypeScript is about 10 lines long:
module.exports = {
resolve: {
root: __dirname,
extensions: ['.ts', '.js']
},
entry: ["webpackapp"],
output: {filename: "webappapp_bundle.js"},
externals: {'angular2/angular2': "angular2"},
devtool: 'source-map',
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
}
You get source maps, dev server with live reload, production/dev modes -- a very good first impression and a clear path to production setting.