Skip to content

Commit 5b71022

Browse files
committed
upgrade webpack 1 to 2
1 parent baf91b5 commit 5b71022

18 files changed

+398
-262
lines changed

README.md

+49-15
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,82 @@
11
# ng-annotate-loader [![Build Status](https://img.shields.io/travis/huston007/ng-annotate-loader.svg?style=flat-square)](https://travis-ci.org/huston007/ng-annotate-loader)
2+
23
Webpack loader to annotate angular applications. Generates a sourcemaps as well.
34

45
## Installation
56

67
```
7-
npm install --save-dev ng-annotate-loader
8+
npm install --save-dev ng-annotate-loader
89
```
910

1011
## Usage:
1112

12-
```
13+
```js
1314
module: {
14-
loaders: [
15-
{test: /src.*\.js$/, loaders: ['ng-annotate']},
16-
]
17-
}
15+
loaders: [
16+
{
17+
test: /src.*\.js$/,
18+
use: [{ loader: 'ng-annotate-loader' }],
19+
}
20+
]
21+
}
1822
```
1923

20-
#### Passing parameters:
24+
#### Passing parameters:
2125

22-
```
23-
{test: /src.*\.js$/, loaders: ['ng-annotate?add=false&map=false']}
26+
```js
27+
{
28+
test: /src.*\.js$/,
29+
use: [
30+
{
31+
loader: 'ng-annotate-loader',
32+
options: {
33+
add: false,
34+
map: false,
35+
}
36+
}
37+
]
38+
}
2439
```
2540

2641
[More about `ng-annotate` parameters](https://github.com/olov/ng-annotate#library-api)
2742

28-
#### Using ng-annotate plugins:
43+
#### Using ng-annotate plugins:
2944

30-
```
31-
{test: /src.*\.js$/, loaders: ['ng-annotate?plugin[]=ng-annotate-adf-plugin']}
45+
```js
46+
{
47+
test: /src.*\.js$/,
48+
use: [
49+
{
50+
loader: 'ng-annotate-loader',
51+
options: {
52+
plugin: ['ng-annotate-adf-plugin']
53+
}
54+
}
55+
]
56+
}
3257
```
3358

3459
#### Works great with js compilers, `babel` for example:
3560

36-
```
37-
{test: /src.*\.js$/, loaders: ['ng-annotate', 'babel-loader']},
61+
```js
62+
{
63+
test: /src.*\.js$/,
64+
use: [
65+
{ loader: 'ng-annotate-loader' },
66+
{ loader: 'babel-loader' },
67+
]
68+
},
3869
```
3970

4071
## Contributing
72+
4173
#### Compiling examples and run acceptance test
74+
4275
Run on the root folder:
76+
4377
```
4478
npm install
4579
npm test
4680
```
4781

48-
[Using loaders](http://webpack.github.io/docs/using-loaders.html)
82+
[Using loaders](https://webpack.js.org/concepts/loaders/)

cases/babel/file-to-annotate.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
import babelTestMsg from './to-import';
44
console.log(babelTestMsg);
55

6+
class someCtrl {
7+
constructor($scope) {
8+
this.doSomething();
9+
}
10+
doSomething() {
11+
}
12+
}
13+
614
angular.module('test', [])
715
.controller('testCtrl', function($scope) {
816
})
@@ -26,12 +34,4 @@ function toAnnotate($scope) {
2634
console.log('hi'); // should be function body, otherwise babel remove directive prologue
2735
}
2836

29-
class someCtrl {
30-
constructor($scope) {
31-
this.doSomething();
32-
}
33-
doSomething() {
34-
}
35-
}
36-
3737
console.log('after annotated function');

cases/babel/reference/build.js

+94-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = [
22
{
33
original: { source: 'webpack:///file-to-annotate.js', line: 33, column: 2 },
4-
generated: { line: 84, column: 3 },
4+
generated: { line: 129, column: 2 },
55
},
66
{
77
original: { source: 'webpack:///file-to-annotate.js', line: 41, column: 0 },
8-
generated: { line: 95, column: 0 },
8+
generated: { line: 134, column: 12 },
99
},
1010
];

cases/babel/webpack.config.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ module.exports = {
88
filename: 'build.js',
99
},
1010
resolveLoader: {
11-
fallback: path.resolve(__dirname, '../../'),
11+
modules: [
12+
'node_modules',
13+
path.resolve(__dirname, '../../'),
14+
],
1215
},
1316
module: {
14-
loaders: [
17+
rules: [
1518
{
1619
test: /\.js$/,
17-
loaders: ['loader', 'babel?presets[]=es2015'],
20+
use: [
21+
{ loader: 'loader' },
22+
{ loader: 'babel-loader', options: { presets: ['es2015'] } },
23+
],
1824
},
1925
],
2026
},

cases/simple/file-to-annotate.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
function namedFunction($dep) {
4+
$dep.do();
5+
}
6+
37
angular.module('test', [])
48
.controller('testCtrl', function($scope) {
59
})
@@ -17,7 +21,3 @@ angular.module('test', [])
1721
};
1822
})
1923
.service('namedFunction', namedFunction);
20-
21-
function namedFunction($dep) {
22-
$dep.do();
23-
}

0 commit comments

Comments
 (0)