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

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

Closed
melan0802 opened this issue Mar 24, 2019 · 21 comments
Closed

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

melan0802 opened this issue Mar 24, 2019 · 21 comments

Comments

@melan0802
Copy link

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?

@alexander-akait
Copy link
Member

Why do you use function? Feel free to send a PR

@melan0802
Copy link
Author

@evilebottnawi Above webpack.config.js is just as an example. In my project I want to add a loader when issuer match a specific file, maybe function isn't designed for this? But bug is still there as long as using function.

@7iomka
Copy link

7iomka commented Jul 12, 2019

it is not fixed in latest ver (4.x)?! how to use that in v4?

@BlueSky1997AL
Copy link

Is there any progress about this issue? Still not functional in latest version (4.39.2).

@aKzenT
Copy link

aKzenT commented Sep 2, 2019

If I understand the PR correctly, it was merged to the next (v5) branch. Any chance to get this backported for the next minor 4.x release? I also need to define Rule.use as a function and getting this problem.

@alexander-akait
Copy link
Member

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

@jedmonsanto
Copy link

No need for it to be function. Please see below:
image

@steventhan
Copy link

@jedmonsanto not relevant to the question I'm afraid

@ja0n
Copy link

ja0n commented Dec 3, 2019

Still not functional in the latest version (4.41.2)

@alexander-akait
Copy link
Member

alexander-akait commented Dec 3, 2019

You can use ident: 'name-of-ident' to avoid that problem

@underflow00
Copy link

You can use ident: 'name-of-ident' to avoid that problem

Tried this. Issue still persists. Is there a workaround to this?

@alexander-akait
Copy link
Member

alexander-akait commented Jan 9, 2020

@underflow00 can you create reproducible test repo?

@underflow00
Copy link

@underflow00 can you create reproducible test repo?

Isn't the first post already it? I just added ident: '...' into the options and that didn't do anything.

@CressZZ
Copy link

CressZZ commented Mar 20, 2020

...cant't we Rule.use function with options until releasing 5.x version ?

@alexander-akait
Copy link
Member

@underflow00 @CressZZ please create reproducible test repo

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

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

@alexander-akait
Copy link
Member

bump

@sokra
Copy link
Member

sokra commented Jun 29, 2020

Webpack 5 has a better error message for this case. It also fixes some problems here. Anyway you need an ident When using a function. ident should be next to options not inside of the options. { loader, options, ident }

@alexander-akait
Copy link
Member

@sokra so we throw an error when ident doesn't exists?

@sokra
Copy link
Member

sokra commented Aug 9, 2020

Yes. We also have better names for the automatic indents in webpack 5.

@sokra sokra closed this as completed Aug 9, 2020
@alexander-akait
Copy link
Member

If somebody faced with the issue again, please open a new issue with reproducible test repo, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests