fathyb/parcel-plugin-angular


Complete Angular support for Parcel

License: MIT

Language: TypeScript

Keywords: angular, aot, jit, parcel


parcel-plugin-angular

Complete Angular support for Parcel and TypeScript.

screenshot

Features

  • parcel-plugin-typescript features
  • AOT compilation : using the official Angular compiler for smaller and faster applications.
  • Lazy Loading : the plugin automagically splits your Angular modules in multiple JavaScript files with Parcel when you use lazy routes.
  • Template and style parsing : your templates and style are processed by Parcel to find and replace resources.
  • Transformations (based on angular/angular-cli transformers) :
    • It removes all your Angular decorators in AOT mode for smaller bundles
    • It replaces JIT bootstrap code with AOT when it's used. You can keep one main file using the @angular/platform-browser-dynamic module, see Entry file

Prerequisites

  • @angular/compiler and @angular/compiler-cli should be installed
  • parcel-plugin-typescript should not be installed

Installation

yarn add parcel-plugin-angular --dev

or

npm install parcel-plugin-angular --save-dev

Configuration

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"
  }
}

Entry file

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)

Known issues

  • AOT mode is highly experimental
  • Lazy-loading does not work in JIT

Project Statistics

Sourcerank 3
Repository Size 612 KB
Stars 27
Forks 0
Watchers 2
Open issues 6
Dependencies 27
Contributors 1
Tags 8
Created
Last updated
Last pushed

Top Contributors See all

Fathy Boundjadj

Packages Referencing this Repo

parcel-plugin-angular
Angular support for Parcel bundler
Latest release 0.5.1-next.15 - Updated - 27 stars

Recent Tags See all

v0.5.0 January 06, 2018
v0.4.0 January 05, 2018
v0.2.4 December 19, 2017
v0.2.3 December 15, 2017
v0.2.2 December 15, 2017
v0.2.1 December 13, 2017
v0.2.0 December 12, 2017
v0.1.0 December 10, 2017

Something wrong with this page? Make a suggestion

Last synced: 2019-01-05 02:31:22 UTC

Login to resync this repository