Complete Angular support for Parcel and TypeScript.
parcel-plugin-typescript
featuresangular/angular-cli
transformers) :
@angular/platform-browser-dynamic
module, see Entry file@angular/compiler
and @angular/compiler-cli
should be installedparcel-plugin-typescript
should not be installedyarn add parcel-plugin-angular --dev
or
npm install parcel-plugin-angular --save-dev
You can pass a parcelAngularOptions
object in your tsconfig.json
, here are the defaults :
{
"compilerOptions": { ... },
// the plugin options
"parcelAngularOptions": {
// What compiler should we use when watching or serving
"watch": "jit",
// What compiler should we use when building (parcel build)
"build": "aot"
}
}
To make it easy to switch between JIT and AOT mode we automatically translate your JIT bootstrap code to AOT if you are using the AOT compiler.
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'
import {enableProdMode} from '@angular/core'
import {AppModule} from './app/app.module'
if(process.env.NODE_ENV === 'production') {
enableProdMode()
}
platformBrowserDynamic().bootstrapModule(AppModule)
will be transformed to :
import {platformBrowser} from '@angular/platform-browser'
import {enableProdMode} from '@angular/core'
import {AppModuleNgFactory} from './app/app.module.ngfactory'
if(process.env.NODE_ENV === 'production') {
enableProdMode()
}
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory)