-
-
Notifications
You must be signed in to change notification settings - Fork 608
fix: the auto
option for inline module syntax
#1274
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
Changes from all commits
ba5b077
7f5d98c
583a9d1
fd41738
15ebb7a
62ef216
c44418f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -665,66 +665,66 @@ exports[`loader should work with inline module syntax: result 1`] = ` | |
Array [ | ||
Array [ | ||
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css", | ||
"._1ZJhuRHDA53bY_Z4Qfm2b4 { | ||
"._14oM7qkZ6dgC62uK5h4NI0 { | ||
color: red; | ||
} | ||
|
||
.j3CQSVq_DdDvo0Ew74yQi { | ||
._2NqyYysncZeLetATpl0xfW { | ||
color: white; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"plain.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.css", | ||
".baz { | ||
"button.modules.css!=!./index-loader-syntax-sass.css", | ||
"._8aapa4kQQdSsOoRODcrwe { | ||
width: 5px; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"other.modules.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.modules.css", | ||
"._1fGl5mRxLFCqIet0X3JYrB > ._2pVMnENaxk1YmKug-4EMYF { | ||
"._2yVYVQfmDwKLZn9Qj6k_Q5 > ._3rHlnRnPEotX4nTkd82-aE { | ||
color: red; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css", | ||
"._1ZJhuRHDA53bY_Z4Qfm2b4 { | ||
"._14oM7qkZ6dgC62uK5h4NI0 { | ||
color: red; | ||
} | ||
|
||
.j3CQSVq_DdDvo0Ew74yQi { | ||
._2NqyYysncZeLetATpl0xfW { | ||
color: white; | ||
} | ||
|
||
.B7fdaUjwJ3YVou1v7dYEE { | ||
._1-Aa1c8UQML46IWY0FjGXT { | ||
from: custom; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"other.modules.css!=!../../src/index.js?[ident]!./index-loader-syntax.modules.css", | ||
"._1ZJhuRHDA53bY_Z4Qfm2b4 { | ||
"._14oM7qkZ6dgC62uK5h4NI0 { | ||
color: red; | ||
} | ||
|
||
.j3CQSVq_DdDvo0Ew74yQi { | ||
._2NqyYysncZeLetATpl0xfW { | ||
color: white; | ||
} | ||
|
||
.B7fdaUjwJ3YVou1v7dYEE { | ||
._1-Aa1c8UQML46IWY0FjGXT { | ||
from: custom; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"other.modules.scss!=!../../src/index.js?[ident]!./index-loader-syntax-sass.modules.css", | ||
"._1fGl5mRxLFCqIet0X3JYrB > ._2pVMnENaxk1YmKug-4EMYF { | ||
"._2yVYVQfmDwKLZn9Qj6k_Q5 > ._3rHlnRnPEotX4nTkd82-aE { | ||
color: red; | ||
} | ||
|
||
._1kK_VYa-N303wnLgpvL-7d { | ||
._2kEhhupr-6tgHnCC_d4yO8 { | ||
from: custom; | ||
}", | ||
"", | ||
|
@@ -733,6 +733,27 @@ Array [ | |
"./index-loader-syntax.css", | ||
".a { | ||
color: red; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"button.modules.css!=!./index-loader-syntax-sass.css", | ||
"._8aapa4kQQdSsOoRODcrwe { | ||
width: 5px; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"button.module.scss!=!./base64-loader/index.js?[ident]!./simple.js?foo=bar", | ||
"._2hfVrRfux-FOrqimHr-fzt { | ||
color: red; | ||
}", | ||
"", | ||
], | ||
Array [ | ||
"other.module.scss!=!./base64-loader/index.js?[ident]!./simple.js?foo=baz", | ||
"._2jOyhMQwdpQ85V5dDLcfoG { | ||
color: red; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can see here: hash for classes are different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But note: you should use different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perfect! |
||
}", | ||
"", | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function loader(content) { | ||
return Buffer.from(this.query.slice(1), 'base64').toString('ascii'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import css from './index-loader-syntax.css'; | ||
import one from './index-loader-syntax.css'; | ||
import two from 'button.modules.css!=!./index-loader-syntax-sass.css'; | ||
// Hash should be different | ||
import three from './button.module.scss!=!./base64-loader?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./simple.js?foo=bar'; | ||
import four from './other.module.scss!=!./base64-loader?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./simple.js?foo=baz'; | ||
|
||
__export__ = css; | ||
__export__ = [...one, ...two, ...three, ...four]; | ||
|
||
export default css; | ||
export default [...one, ...two, ...three, ...four]; |
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.
woohoo! should this also be the logic for local ident generation?
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.
Yep, you are right, otherwise we will get the same class names.
After fix local ident generation should we merge it and release? All is fixed?
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.
i think so, seems like this covers it all. hard to know for sure until i try it out on a code base. Thanks again for helping me out here
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.
Yep, here interesting case, when we have:
We run the loader only once, why? Because ES modules executed only once. So I don't think here bug. But we can solve it using:
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.
ah interesting, so the query param acts like a cache buster. That solution seems fine to me
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.
yeah in my case it'd be easy to use a stable identifier here. This wouldn't solve the className hash generation issue tho right? I'm guessing you discovered this writing a test for that?
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.
Solved, please check code
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.
arg, i'm trying this out now and
_module.matchResource
is null locally. Going to debug a bit to see why will report backThere 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.
If you don't have
matchResource
in request, it will be nullishThere 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.
yeah this is for requests with it in it. For some reason i am seeing the module get created twice, one with the matchResource and one without, the one without is what makes it to the css-loader. It maybe has to do with ESM, still trying to figure it out