shaketbaby / directory-named-webpack-plugin

A Webpack plugin that treats a file with the name of directory as the index file
MIT License
182 stars 17 forks source link

directory-named-webpack-plugin doesn't work with typescript #38

Closed g8up closed 4 years ago

g8up commented 4 years ago

refer to https://webpack.js.org/configuration/configuration-languages/#typescript , I change my webpack.conf.js to typescript webpack.conf.ts.

An error come from tslint:

Only a void function can be called with the 'new' keyword.ts(2350)

as I config like below:

  var DirectoryNamedWebpackPlugin = require("directory-named-webpack-plugin");

  resolve: {
    plugins: [
      new DirectoryNamedWebpackPlugin()
    ]
  }
shaketbaby commented 4 years ago

Looks like tslint checks if the constructor returns a value and disallow that. You don't have to use new, it's not necessary. You can just do

  var directoryNamedWebpackPlugin = require("directory-named-webpack-plugin");

  resolve: {
    plugins: [
      directoryNamedWebpackPlugin()
    ]
  }