-
-
Notifications
You must be signed in to change notification settings - Fork 28
wont work with webpack2 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@digitalkaoz So I investigated the issue and found that not a webpack 2 itself but es2015-webpack preset. It doesn't convert imports and exports from ES6 to commonJS so ng-annotate couldn't understand this. So you could still be possible to use standart es2015 preset instead and get CommonJS as output of babel loader. I believe this is not a big deal to miss webpack's ES6 processing feature, isn't it? |
mh, webpack2 has a native maybe it must be a |
@digitalkaoz I would like it to support this native So the only way is to convert js to valid es5 before passing to ng-annotate. |
some news about |
Unfortunately no because |
I didn't get it to work with Webpack 2 so I tried ng-annotate-webpack-plugin and it worked. |
I switched to "babel-plugin-angularjs-annotate" and I now have annotation working in webpack 2 with tree shaking. This means using babel to do the annotation transform, not using any webpack loaders or plugins. |
|
Been using ng-annotate-loader with Webpack 2.2.1 successfully with this as an element in my array for config.module.rules:
Also tried ng-annotate-webpack-plugin which works but is much slower (could be my configuration though). |
You have to suffix by
|
@huston007 What do you think about adding an option to specify how diff --git a/ng-annotate-main.js b/ng-annotate-main.js
index 78ca8df..41a701d 100644
--- a/ng-annotate-main.js
+++ b/ng-annotate-main.js
@@ -1075,8 +1075,9 @@ module.exports = function ngAnnotate(src, options) {
stats.parser_parse_t0 = Date.now();
// acorn
ast = parser(src, {
- ecmaVersion: 6,
- allowReserved: true,
+ ecmaVersion: 8,
+ allowImportExportEverywhere: true,
+ allowReturnOutsideFunction: true,
locations: true,
ranges: true,
onComment: comments,
diff --git a/package.json b/package.json
index f0b1673..0852387 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"url": "https://github.com/olov/ng-annotate.git"
},
"dependencies": {
- "acorn": "~2.6.4",
+ "acorn": "~5.0.3",
"alter": "~0.2.0",
"convert-source-map": "~1.1.2",
"optimist": "~0.6.1", [for some reason ng-annotate has a test which rejects caret ( It should not be a problem to publish that to a new package, ng-annotate-next or something like that. |
@bluetech hm, actually this could work. Something like: {
test: /src.*\.js$/,
use: [
{
loader: 'ng-annotate-loader',
options: {
add: false,
map: false,
ngAnnotatePath: path.resolve(__dirname, '..path/to')
}
}
]
} |
I think one of these two methods will be better than having to pass a full path:
I personally prefer 2, if it's possible with webpack, but 1 is also fine. I think the option should be called just |
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.
OK, since version 0.6.0 of the loader it is now possible to specify a fork of ng-annotate. I had made such a fork which fixes the issues I had encountered around If you want to use that, install the fork:
And tell the loader to use it: {
loader: 'ng-annotate-loader',
options: {
ngAnnotate: 'ng-annotate-patched',
},
} That should be it. |
So I assume this issue is closed that way. Thanks everybody for help. |
babel-plugin-angularjs-annotate is the updated version of ng-annotate. it works by adding the plugin to babelrc file. |
it seems this loader wont work with webpack2:
using https://github.com/gajus/babel-preset-es2015-webpack (to enable tree-shaking)
none of my angular files gets injections anymore...any hint?
btw im using the
"ngInject"
syntaxThe text was updated successfully, but these errors were encountered: