Angular Support for Parcel 1
raw JSON →parcel-plugin-angular is an abandoned Parcel plugin, currently at version 0.5.0, designed to provide comprehensive Angular support for the Parcel 1 bundler. It enables features like AOT (Ahead-of-Time) compilation using the official Angular compiler, lazy loading of Angular modules, and automatic processing of templates and styles. The plugin also performs transformations, such as decorator removal in AOT mode for smaller bundles and replacing JIT bootstrap code with AOT. It explicitly requires Parcel 1.x and Angular versions around 5.1.0, along with their associated compiler tools. Due to the release of Parcel 2 with a completely redesigned plugin system in September 2021, this plugin is no longer maintained or compatible with modern Parcel versions or recent Angular releases. Its release cadence was irregular and it has not seen updates since 2018.
Common errors
error Error: Plugin "parcel-plugin-angular" is not compatible with Parcel 2.x.x. Requires "1.x" but the current version is "2.x.x". ↓
npm install parcel-bundler@^1.0.0 --save-dev) or migrate your project's build system to Parcel 2 or Angular CLI. error Error: Cannot find module '@angular/compiler' ↓
npm install @angular/compiler@^5.1.0 @angular/compiler-cli@^5.1.0 --save-dev). Ensure all peer dependencies listed in package.json are met. error TypeError: Class constructor 'X' cannot be invoked without 'new' ↓
tsconfig.json matches the plugin's recommended configuration, especially for target, module, emitDecoratorMetadata, and experimentalDecorators. Ensure Angular dependencies are within the ^5.1.0 range. Warnings
breaking This plugin is only compatible with Parcel 1.x. It will not work with Parcel 2.x or newer versions due to a complete overhaul of Parcel's plugin system. ↓
breaking The plugin's peer dependencies require Angular versions around 5.1.0. It is not compatible with modern Angular versions (e.g., Angular 6 and above) due to breaking changes in Angular's core and compiler. ↓
gotcha The `parcel-plugin-angular` package is abandoned and has not received updates since 2018. This means there will be no new features, bug fixes, or security patches, leaving projects using it vulnerable to known and unknown issues. ↓
gotcha The plugin's README explicitly states that `parcel-plugin-typescript` should *not* be installed alongside `parcel-plugin-angular` as it can lead to conflicts and unexpected build behavior. ↓
Install
npm install parcel-plugin-angular yarn add parcel-plugin-angular pnpm add parcel-plugin-angular Imports
- platformBrowserDynamic wrong
const platformBrowserDynamic = require('@angular/platform-browser-dynamic');correctimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - enableProdMode
import { enableProdMode } from '@angular/core'; - AppModule
import { AppModule } from './app/app.module';
Quickstart
{
"name": "my-angular-parcel-app",
"version": "1.0.0",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html"
},
"devDependencies": {
"parcel-bundler": "^1.1.0",
"parcel-plugin-angular": "^0.5.0",
"@angular/common": "^5.1.0",
"@angular/compiler": "^5.1.0",
"@angular/compiler-cli": "^5.1.0",
"@angular/core": "^5.1.0",
"@angular/platform-browser": "^5.1.0",
"@angular/platform-browser-dynamic": "^5.1.0",
"rxjs": "^5.5.0",
"typescript": ">=2.4.2 <2.6",
"zone.js": "^0.8.0"
}
}
// tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"typeRoots": [
"node_modules/@types"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictMetadataEmit": true
},
"parcelAngularOptions": {
"watch": "jit",
"build": "aot"
}
}
// index.html
<!DOCTYPE html>
<html>
<head>
<title>Parcel Angular App</title>
</head>
<body>
<app-root></app-root>
<script src="main.ts"></script>
</body>
</html>
// main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
if (process.env.NODE_ENV === 'production') {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
// app/app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
// app/app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: '<h1>Hello from Angular with Parcel!</h1>'
})
export class AppComponent { }