andrey-skl / ng-annotate-loader

Webpack loader to annotate angular applications
MIT License
120 stars 28 forks source link

Sourcemaps not working with babel + ng-annotate #23

Open killersite opened 8 years ago

killersite commented 8 years ago
module.exports = {
    devtool: 'sourcemap',
    context: __dirname + '/app',
    entry: './index.js',
    output: {
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            // run babel first then ng-annotate
            { test: /\.js$/, loaders: ['ng-annotate','babel'] }
        ]
    }
};

When I use the above webpack config the source-map file is messed up with duplicate entries like the following.

"webpack:///./index.js",
"webpack:///./index.js?2645",
"webpack:///../~/angular/index.js",
"webpack:///../~/angular/index.js?08f2",
"webpack:///../~/angular/angular.js",
"webpack:///../~/angular/angular.js?58d0",

This is causing Chrome to not find the correct lines...

It seems that ng-annotate is inserting lines in the code without the source-map getting corrected info.

So where before ng-annotate (when the source-map was created) the code looked like

        /* @ngInject */
        function HeroController(users) {

now after ng-annotate there are new lines that the source-map doesnt know about

        /* @ngInject */
        HeroController.$inject = ["users"];
        function HeroController(users) {
e-cloud commented 8 years ago

which version?

killersite commented 8 years ago
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babel-core": "^6",
"babel-loader": "^6",
"ng-annotate-loader": "^0.1.1",
"webpack": "^1.12.13",

Thanks