ng-annotate-loader icon indicating copy to clipboard operation
ng-annotate-loader copied to clipboard

Webpack 4

Open benneq opened this issue 6 years ago • 4 comments

Is there any chance that ng-annotate-loader will support webpack 4?

benneq avatar Feb 25 '18 09:02 benneq

@benneq Hello! Eventually it will. Any help with that is appreciated.

andrey-skl avatar Feb 25 '18 10:02 andrey-skl

I could only provide help with testing. Push some beta to npm and I'll see if it works :)

EDIT: I set up a mini sample project, and it seems to work with webpack 4 already. In a few days I can maybe test it with our real project.

package.json:

{
  "name": "wp4test",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "build": "webpack --mode production",
    "watch": "webpack --mode development --watch"
  },
  "devDependencies": {
    "ng-annotate-loader": "0.6.1",
    "ng-annotate-patched": "1.7.0",
    "ts-loader": "4.0.0",
    "typescript": "2.7.2",
    "webpack": "4.0.0",
    "webpack-cli": "2.0.8"
  }
}

webpack.config.js:

'use strict';
module.exports = {
    devtool: 'inline-source-map',
    entry: {
        main: './src/index.ts'
    },
    output: {
        filename: '[name].js',
        path: __dirname + '/dist'
    },
    module: {
        rules: [
            {
                test: /\.ts?$/,
                loader: 'ng-annotate-loader?ngAnnotate=ng-annotate-patched!ts-loader'
            }
        ]
    },
    resolve: {
        extensions: [ '.ts', '.js' ]
    }
};

index.ts:

function bar(HelloService) {'ngInject';
}

resulting main.js contains:

bar.$inject = ["HelloService"];function bar(HelloService) {
    'ngInject';
}

benneq avatar Feb 25 '18 10:02 benneq

Seems to work for me on a mid-sized project

urish avatar Mar 06 '18 22:03 urish

Works for me too.

gsikorski avatar Mar 29 '18 12:03 gsikorski