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

[2.0.0] getLocalIdent validation #862

Closed
gpoitch opened this issue Dec 7, 2018 · 6 comments · Fixed by #865
Closed

[2.0.0] getLocalIdent validation #862

gpoitch opened this issue Dec 7, 2018 · 6 comments · Fixed by #865

Comments

@gpoitch
Copy link

gpoitch commented Dec 7, 2018

  • Operating System: macOS 10.14.1
  • Node Version: 11.2.0
  • NPM Version: 6.4.1
  • webpack Version: 4.27.1
  • css-loader Version: 2.0.0

Expected Behavior

Previously, if getLocalIdent returned a falsey value, css-loader would fallback to using localIdentName

Actual Behavior

css-loader throws an error:

ValidationError: CSS Loader Invalid Options
options.getLocalIdent should pass "instanceof" keyword validation

Code

const isProduction = false

const cssLoader = {
  loader: 'css-loader',
  options: {
    modules: true,
    localIdentName: '[local]__[hash:base64:3]',
    getLocalIdent: isProduction && function() {
       return 'foo' // other logic here, but just return a string for purpose of issue
    }
  }
}

How Do We Reproduce?

Run tests with those loader options

@alexander-akait
Copy link
Member

@gpoitch what you expected from getLocalIdent when you set it false?

@gpoitch
Copy link
Author

gpoitch commented Dec 7, 2018

I expect it to fallback to using localIdentName.
Worked around it by explicitly setting to undefined instead of a falsey value.

getLocalIdent: isProduction ? function(){ /*...*/ } : undefined

@gpoitch gpoitch closed this as completed Dec 7, 2018
@alexander-akait
Copy link
Member

@gpoitch maybe we can accept false value for easy configuration, what do you think?

@gpoitch
Copy link
Author

gpoitch commented Dec 7, 2018

@evilebottnawi yes, that'd be nice, as it worked in 1.x. Otherwise that is a tiny breaking change

@alexander-akait
Copy link
Member

@gpoitch let's mark it as bug and fix in 2.0.1

@alexander-akait
Copy link
Member

previous we don't have schema options and tests so i can lose something, sorry

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

Successfully merging a pull request may close this issue.

2 participants