webpack: Can't find options with ident 'ref--*-*' when Rule.use is a function

Bug report

What is the current behavior?

When Rule.use is a function that return UseEntry With Options, the compilation failed with error “Can’t find options with ident ‘ref–4-1’”

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

webpack.config.js

const path = require('path')
module.exports = {
  mode: 'production',
  entry: './index.js',
  output: {
    path: path.resolve(__dirname, './dist')
  },
  module: {
    rules: [
      {
        test: /\.css/,
        use (info) {
          return [
            'style-loader',
            {
              loader: 'css-loader',
              options: {
                url: true
              }
            }
          ]
        }
      }
    ]
  }
}

What is the expected behavior?

behavior like it is a UseEntry Array

Other relevant information: webpack version: 4.29.6 Node.js version: 10.15.3 Operating System: Windows 10

Check out the source and pretty sure it’s a bug in RuleSet.js , the options references as RuleSet.references is assigned only when rule.use is an array. Should I make an PR?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 21 (11 by maintainers)

Most upvoted comments

/cc @sokra it is solved for webpack@5?