andrey-skl / ng-annotate-loader

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

Webpack 4 #46

Open benneq opened 6 years ago

benneq commented 6 years ago

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

andrey-skl commented 6 years ago

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

benneq commented 6 years ago

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';
}
urish commented 6 years ago

Seems to work for me on a mid-sized project

gsikorski commented 6 years ago

Works for me too.