https://github.com/xierenyuan/rollup-plugin-ng-annotate
ng1 自动引入依赖
https://github.com/xierenyuan/rollup-plugin-ng-annotate
angular1 ng-annitate rollup rollup-plugin rollup-plugin-ng-annotate
Last synced: 3 months ago
JSON representation
ng1 自动引入依赖
- Host: GitHub
- URL: https://github.com/xierenyuan/rollup-plugin-ng-annotate
- Owner: xierenyuan
- Created: 2017-05-25T13:41:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T09:47:48.000Z (about 9 years ago)
- Last Synced: 2025-10-08T15:45:49.813Z (8 months ago)
- Topics: angular1, ng-annitate, rollup, rollup-plugin, rollup-plugin-ng-annotate
- Language: JavaScript
- Size: 28.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rollup-pulgin-ng1-annotate
> 解决 angularjs 1 的依赖注入 在 es6 和 普通的代码的可以使用 Add angularjs dependency injection annotations with ng-annotate
## Install
```js
$ npm i rollup-pulgin-ng1-annotate -D
of
$ yarn add rollup-pulgin-ng1-annotate -D
```
## Usage
> 如果是es6 必须写在babel 插件之后【__If it is es6 must after Babel__】
> see demo [examples/test.es6.js or examples/test.js]
``` js
import babel from 'rollup-plugin-babel'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import {resolve} from 'path'
export default {
format: 'cjs',
entry: resolve(__dirname, './test.es6.js'),
dest: resolve(__dirname, './dist/index.js'),
plugins: [
babel({
exclude: 'node_modules/**'
}),
nodeResolve(),
commonjs(),
ng()
]
}
```
### 来自 ng-annotate docs
> ng-annotate supports ES5 as input so run it with the output from Babel, Traceur, TypeScript (tsc) and the likes. Use __"ngInject"__ on functions you want annotated. Your transpiler should preserve directive prologues, if not please file a bug on it.
```js
'use strict'
import A from './1.es6.js'
class HelloCtrl {
constructor($scope, HelloAccount, $rcTableDelegate, $rcModal) {
'ngInject';
$scope.hello = ''
this.b = ''
}
init() {
}
}
```
## Options
You can pass any of the [ng-annotate](https://github.com/olov/ng-annotate/blob/master/OPTIONS.md) options as an object:
```js
{
include: '**/*.js',
exclude: '',
// see [ng-annotate] options https://github.com/olov/ng-annotate/blob/master/OPTIONS.md
ngConfig: {
add: true
}
}
```
## 最后ng1 已经是过去式了, 如果可以升级 到ng2 或者换到 vue2