Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misleading error message: configuration.module.rules[].exclude #66

Open
taewdy opened this issue Apr 6, 2019 · 5 comments
Open

misleading error message: configuration.module.rules[].exclude #66

taewdy opened this issue Apr 6, 2019 · 5 comments

Comments

@taewdy
Copy link

taewdy commented Apr 6, 2019

Bug report

What is the current behavior?
misleading error message: configuration.module.rules[].exclude
All other config property is removed here for clarity.

When I use string for exclude

  • config
// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: 'node_modules',
        use: [
          {
            loader: 'babel-loader'
          }
        ]
      }
    ]
  }
};
  • error message
## error
✖ 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[0].exclude should be one of these:
   RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
   -> One or multiple rule conditions
   Details:
    * configuration.module.rules[0].exclude should be an instance of RegExp
    * configuration.module.rules[0].exclude: The provided value "node_modules" is not an absolute path!
    * configuration.module.rules[0].exclude should be an instance of function
    * configuration.module.rules[0].exclude should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration.module.rules[0].exclude should be an object.
    * configuration.module.rules[0].exclude should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]

If I use array of string for exclude

  • config
module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: ['node_modules'],
        use: [
          {
            loader: 'babel-loader'
          }
        ]
      }
    ]
  }
};
  • error message
✖ 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[0].exclude should be one of these:
   RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
   -> One or multiple rule conditions
   Details:
    * configuration.module.rules[0].exclude should be an instance of RegExp
    * configuration.module.rules[0].exclude should be a string.
    * configuration.module.rules[0].exclude should be an instance of function
    * configuration.module.rules[0].exclude[0] should be an instance of RegExp
    * configuration.module.rules[0].exclude[0]: The provided value "node_modules" is not an absolute path!
    * configuration.module.rules[0].exclude[0] should be an instance of function
    * configuration.module.rules[0].exclude[0] should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration.module.rules[0].exclude[0] should be an object.
    * configuration.module.rules[0].exclude should be an object.
    * configuration.module.rules[0].exclude[0] should be an instance of RegExp
    * configuration.module.rules[0].exclude[0]: The provided value "node_modules" is not an absolute path!
    * configuration.module.rules[0].exclude[0] should be an instance of function
    * configuration.module.rules[0].exclude[0] should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration.module.rules[0].exclude[0] should be an object.

If the current behavior is a bug, please provide the steps to reproduce.

  1. use below config and run webpack-dev-server --config webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: ['node_modules'],
        use: [
          {
            loader: 'babel-loader'
          }
        ]
      }
    ]
  }
};

What is the expected behavior?

string should be removed from allowed object in error message.

Other relevant information:
webpack version: ^4.29.6
Node.js version: 8.11.1
Operating System: ubuntu 18.04
webpack-dev-server: ^3.2.1

@alexander-akait
Copy link
Member

@taewdy Why? We support String, look on message:

configuration.module.rules[0].exclude: The provided value "node_modules" is not an absolute path!

@taewdy
Copy link
Author

taewdy commented Apr 9, 2019

'node_modules' and '/node_modules' are both string.
One produce error the other doesn't. String is supported only when in absolute path format as the error message suggest. That's all

@webpack-bot
Copy link

This issue had no activity for at least half a year.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@alexander-akait alexander-akait transferred this issue from webpack/webpack Oct 9, 2019
@alexander-akait
Copy link
Member

need add test case to avoid problem in future

@vankop
Copy link
Member

vankop commented Oct 13, 2019

I can suggest to add extra info, e.g.

{
    "format": "absolutePath",
    "type": "string"
}

will produce string (absolute path) or absolute path string. Same for

{
    "format": "phone",
    "type": "string"
}

will produce phone string

UPD: we need to use https://github.com/epoberezkin/ajv#api-addformat instead of addKeyword

@vankop vankop mentioned this issue Oct 13, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants