Skip to content

Commit d247d3e

Browse files
committed
Add an option to use a fork of ng-annotate
ng-annotate is no longer maintained[1], and hence fails when applied to source code containing modern JavaScript constructs, like import and export. In particular, this prevents usage with Webpack's ES6 modules support (issue andrey-skl#17). [1] olov/ng-annotate#245 To work around it, allow the user to specify a fork of ng-annotate, which adds support for new JS syntax.
1 parent 85f020e commit d247d3e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ module: {
5656
}
5757
```
5858

59+
#### Using a fork of ng-annotate:
60+
61+
```js
62+
{
63+
test: /src.*\.js$/,
64+
use: [
65+
{
66+
loader: 'ng-annotate-loader',
67+
options: {
68+
ngAnnotate: 'my-ng-annotate-fork'
69+
}
70+
}
71+
]
72+
}
73+
```
74+
5975
#### Works great with js compilers, `babel` for example:
6076

6177
```js

loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var ngAnnotate = require('ng-annotate');
21
var utils = require('loader-utils');
32
var SourceMapConsumer = require('source-map').SourceMapConsumer;
43
var SourceMapGenerator = require('source-map').SourceMapGenerator;
@@ -73,6 +72,7 @@ module.exports = function(source, inputSourceMap) {
7372
var filename = normalizePath(this.resourcePath);
7473
this.cacheable && this.cacheable();
7574

75+
var ngAnnotate = require((utils.getOptions(this) || {}).ngAnnotate || 'ng-annotate');
7676
var annotateResult = ngAnnotate(source, getOptions.call(this, sourceMapEnabled, filename));
7777

7878
if (annotateResult.errors) {

0 commit comments

Comments
 (0)