Registry / web-framework / babel-plugin-angular2-annotations

babel-plugin-angular2-annotations

JSON →
library5.1.0jsnpmunverified

An experimental Babel transformer plugin for Angular 2 decorators and type annotations. Version 5.1.0 (last released in 2016) is the latest stable version, but the project is effectively abandoned with no updates since. It requires babel-plugin-transform-decorators-legacy for decorator support and transforms Flow-style type annotations into Angular's design:paramtypes metadata for dependency injection. Unlike the official Angular compiler, this plugin allowed using Angular 2 with Babel/Flow instead of TypeScript. However, it only supports Angular 2.x and has known issues with newer Angular versions and strict mode.

npm install babel-plugin-angular2-annotations
INSTALL
IMPORT
SIG · BABEL-PLUGIN-ANGUL
B
babel-plugin-angular2-annotations
web-frameworkjavascriptv5.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babel-plugin-angular2-annotations
install and configure in .babelrc
This is a Babel plugin, not an imported module. Configure it in .babelrc or babel.config.js as 'angular2-annotations'.

Installs the plugin and other required Babel plugins, then configures them in .babelrc to transpile Angular 2 decorators and type annotations.

npm install --save-dev babel-plugin-angular2-annotations babel-plugin-transform-decorators-legacy babel-plugin-transform-class-properties babel-plugin-transform-flow-strip-types babel-preset-es2015 // .babelrc { "plugins": [ "angular2-annotations", "transform-decorators-legacy", "transform-class-properties", "transform-flow-strip-types" ], "presets": [ "es2015" ] }
Debug
Known issues
breakingPlugin does not compile with strict mode
affects: >=5.0.0
gotchaRequires reflect-metadata polyfill
fix
npm install reflect-metadata and import it in your app
affects: >=5.0.0
deprecatedProject is abandoned and unmaintained; may not work with Babel 7+ or Angular 4+
fix
Migrate to Angular's official compiler or ngc
affects: >=5.0.0
gotchaDecorator ordering matters: angular2-annotations must come before transform-decorators-legacy in plugins list
fix
List 'angular2-annotations' before 'transform-decorators-legacy' in .babelrc
affects: >=5.0.0
gotchaClass property decorators without initializer are handled but produce degraded output on class prototype
fix
Provide an initializer (even undefined) for class properties
affects: >=5.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-angular2-annotations'
Plugin not installed or not listed in node_modules
fix
Run npm install --save-dev babel-plugin-angular2-annotations
SyntaxError: Unexpected token @
Decorator syntax not supported by Babel without transform-decorators-legacy plugin
fix
Add 'transform-decorators-legacy' to plugins list in .babelrc
Error: Reflect is not defined
reflect-metadata polyfill missing
fix
Install reflect-metadata (npm install reflect-metadata) and import it at the entry point
TypeError: Cannot read property 'annotations' of undefined
angular2-annotations plugin may be configured incorrectly or missing in .babelrc
fix
Ensure 'angular2-annotations' is in plugins list and appears before transform-decorators-legacy
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies
babel-plugin-transform-decorators-legacyrequiredRequired for decorator support
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
babel-plugin-angular2-annotations — npm install babel-plugin-angular2-annotations · libregistry