-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
fix: default context should be undefined instead of null #965
fix: default context should be undefined instead of null #965
Conversation
loaderUtils.interpolateName breaks if it passes null to path.relative
strange, we use |
Yes, you do, but only in your internal getLocalIdent() function in utils.js. If a custom getLocalIdent function is passed as option: modules: {
getLocalIdent: (loaderContext, localIdentName, localName, options) => {
// this should be undefined:
options.context === null
}
} … it's |
… you can check it by adding a
in 3.0.0 and
in 2.1.1.
|
hm, looks regression, let's add test for this case |
Just added a test. Please have a look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, thanks!
loaderUtils.interpolateName
breaks if it passesnull
to path.relativeThis PR contains a:
Motivation / Use-Case
When css-loader 3.0.0 is used with
react-dev-utils/getCSSModuleLocalIdent
the build fails because getLocalIdent passescontext
toloaderUtils.interpolateName
. interpolateName then uses thiscontext
to get a relative path usingpath.relative()
. Whileundefined
(the value in ^2.1.1) is ... undefined and thus simply ignored bypath.relative()
,null
is an object and causes the error below (shortened):This PR removes the
context
default option completely, implicitly setting its value back toundefined
.Breaking Changes
Existing tests are still passing so I assume there should be no breaking changes. I didn't add any additional tests though.
Additional Info
You should be able to reproduce this behavior by cloning my demo repo and run
npm run build
.