Skip to content

Commit

Permalink
feat(platform/browser): use bundler for bootstrap
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

You have to bootstrap your app via root component like Angular 2 does.
This is because we use now tree resolving algorithm for building Angular.module

before:
```typescript
import {bootstrap} from 'ng-metadata/platform';
import {AppModule} from './index'; // string

bootstrap(AppModule);
```

after:
```typescript
import {bootstrap} from 'ng-metadata/platform';
import {LegacyModule} from './index'; // string
import {AppComponent} from './index'; // class with @component decorator

bootstrap(AppComponent, [LegacyModule]);
```
  • Loading branch information
Hotell committed Jun 11, 2016
1 parent ea6ce56 commit 88479a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/core/util.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './util/decorators';
export { bundle } from './util/bundler';
18 changes: 10 additions & 8 deletions src/platform/browser.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { assertionsEnabled } from '../facade/lang';
import { bundle } from '../core/util/bundler';

export * from './title';
export type AppRoot = string | Element | Document;

/**
* bootstrap angular app
* @param {string} ngModuleName
* @param {string | Element | Document} [element=document]
* @param {boolean} [strictDi=true]
* @param {Type} rootComponent
* @param {Array<any>} providers
*/
export function bootstrap(
ngModuleName: string,
{element=document,strictDi=true}: {
element?: AppRoot,
strictDi?: boolean
}={}
rootComponent: Type,
providers: any[]
) {

const ngModule = bundle( rootComponent, providers );
const ngModuleName = ngModule.name;
const strictDi = true;
const element = document;

if ( assertionsEnabled() ) {
console.info(
'Angular is running in the development mode. Call enableProdMode() to enable the production mode.'
Expand Down

0 comments on commit 88479a5

Please sign in to comment.