node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



Teach webpack to use a file with the same name as the directory if that directory is required and it doesn't have an index.js file.

This allows you to write:


inorder to require:


This module is designed to be used as strategy for a webpack.ResolverPlugin like so:

var DirectoryNameAsMain = require('@elastic/webpack-directory-name-as-main');
var webpackConfig = {
  entry: ...,
  plugins: [
    new webpack.ResolverPlugin([
      new DirectoryNameAsMain()