Skip to content

Commit 0a4ca66

Browse files
fix: classes generation for client and server bundling
1 parent a56bd94 commit 0a4ca66

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

src/utils.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,15 @@ function defaultGetLocalIdent(
317317
localName,
318318
options
319319
) {
320-
let relativeMatchResource = "";
321-
322320
const { context } = options;
323321
const { resourcePath } = loaderContext;
324322

325-
// eslint-disable-next-line no-underscore-dangle
326-
if (loaderContext._module && loaderContext._module.matchResource) {
327-
relativeMatchResource = `${normalizePath(
328-
// eslint-disable-next-line no-underscore-dangle
329-
path.relative(context, loaderContext._module.matchResource)
330-
)}\x00`;
331-
}
332-
333323
const relativeResourcePath = normalizePath(
334324
path.relative(context, resourcePath)
335325
);
336326

337327
// eslint-disable-next-line no-param-reassign
338-
options.content = `${relativeMatchResource}${relativeResourcePath}\x00${localName}`;
328+
options.content = `${relativeResourcePath}\x00${localName}`;
339329

340330
let { hashFunction, hashDigest, hashDigestLength } = options;
341331
const matches = localIdentName.match(

test/__snapshots__/loader.test.js.snap

+15-15
Original file line numberDiff line numberDiff line change
@@ -849,66 +849,66 @@ exports[`loader should work with inline module syntax: result 1`] = `
849849
Array [
850850
Array [
851851
"other.modules.css!=!../../src/index.js??ruleSet[1].rules[0].rules[0]!../../node_modules/sass-loader/dist/cjs.js!./index-loader-syntax.modules.css",
852-
".ABsTUeF6gmFCjdFT2gFj {
852+
".xCJYD030P78MBXmutRe1 {
853853
color: red;
854854
}
855855
856-
._hMCVXaTnfM6PXNxIi9q {
856+
.Ei0SB4gC2Hc256_lNm0O {
857857
color: white;
858858
}",
859859
"",
860860
],
861861
Array [
862862
"button.modules.css!=!./index-loader-syntax-sass.css",
863-
".Drgxp1xjMmc3NE0RSqYo {
863+
".sApvvu2Ofv8P96bvkTV6 {
864864
width: 5px;
865865
}",
866866
"",
867867
],
868868
Array [
869869
"other.modules.scss!=!../../src/index.js??ruleSet[1].rules[0].rules[0]!../../node_modules/sass-loader/dist/cjs.js!./index-loader-syntax-sass.modules.css",
870-
".Bf1TxkQnV__64Gk9dM7n > .qOILSEPdF7F3GDpf9VWt {
870+
"._ca3ww50DquZ6RvWVlGp > .KQ_jhA95rsUHVKjE6AXn {
871871
color: red;
872872
}",
873873
"",
874874
],
875875
Array [
876876
"other.modules.css!=!../../src/index.js??ruleSet[1].rules[0].rules[0]!../../node_modules/sass-loader/dist/cjs.js!./my-inline-loader/index.js!./index-loader-syntax.modules.css",
877-
".ABsTUeF6gmFCjdFT2gFj {
877+
".xCJYD030P78MBXmutRe1 {
878878
color: red;
879879
}
880880
881-
._hMCVXaTnfM6PXNxIi9q {
881+
.Ei0SB4gC2Hc256_lNm0O {
882882
color: white;
883883
}
884884
885-
._65OKcDrrEG8MI0jTKCQ {
885+
.KMo3xxd4WM4PLTjhSvMc {
886886
from: custom;
887887
}",
888888
"",
889889
],
890890
Array [
891891
"other.modules.css!=!../../src/index.js??ruleSet[1].rules[0].rules[0]!../../node_modules/sass-loader/dist/cjs.js!./my-inline-loader/index.js!./index-loader-syntax.modules.css",
892-
".ABsTUeF6gmFCjdFT2gFj {
892+
".xCJYD030P78MBXmutRe1 {
893893
color: red;
894894
}
895895
896-
._hMCVXaTnfM6PXNxIi9q {
896+
.Ei0SB4gC2Hc256_lNm0O {
897897
color: white;
898898
}
899899
900-
._65OKcDrrEG8MI0jTKCQ {
900+
.KMo3xxd4WM4PLTjhSvMc {
901901
from: custom;
902902
}",
903903
"",
904904
],
905905
Array [
906906
"other.modules.scss!=!../../src/index.js??ruleSet[1].rules[0].rules[0]!../../node_modules/sass-loader/dist/cjs.js!./my-inline-loader/index.js!./index-loader-syntax-sass.modules.css",
907-
".Bf1TxkQnV__64Gk9dM7n > .qOILSEPdF7F3GDpf9VWt {
907+
"._ca3ww50DquZ6RvWVlGp > .KQ_jhA95rsUHVKjE6AXn {
908908
color: red;
909909
}
910910
911-
.iCwSzW_a1wp1hr9lXhSh {
911+
.zeG_Xwa9FzgAQ_wrfP67 {
912912
from: custom;
913913
}",
914914
"",
@@ -922,21 +922,21 @@ Array [
922922
],
923923
Array [
924924
"button.modules.css!=!./index-loader-syntax-sass.css",
925-
".Drgxp1xjMmc3NE0RSqYo {
925+
".sApvvu2Ofv8P96bvkTV6 {
926926
width: 5px;
927927
}",
928928
"",
929929
],
930930
Array [
931931
"button.module.scss!=!./base64-loader/index.js?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./simple.js?foo=bar",
932-
"._fj422pJ2ianfug99ZY_ {
932+
".RK1MI2vvw75Y7ERMcD0r {
933933
color: red;
934934
}",
935935
"",
936936
],
937937
Array [
938938
"other.module.scss!=!./base64-loader/index.js?LmZvbyB7IGNvbG9yOiByZWQ7IH0=!./simple.js?foo=baz",
939-
".KvYw79kUeYHQWQPScCTK {
939+
".RK1MI2vvw75Y7ERMcD0r {
940940
color: red;
941941
}",
942942
"",

test/__snapshots__/modules-option.test.js.snap

+7-7
Original file line numberDiff line numberDiff line change
@@ -5079,11 +5079,11 @@ import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../src/runtime/noSour
50795079
import ___CSS_LOADER_API_IMPORT___ from \\"../../src/runtime/api.js\\";
50805080
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
50815081
// Module
5082-
___CSS_LOADER_EXPORT___.push([module.id, \\".tAbfDoQYh1hH8fgy5jt_ {\\\\n color: red;\\\\n}\\\\n\\\\n._h7REYQFFxfq7wKBe15e { from: custom; }\\", \\"\\"]);
5082+
___CSS_LOADER_EXPORT___.push([module.id, \\"._LAQzblHTRmSe8Mk9eNB {\\\\n color: red;\\\\n}\\\\n\\\\n.Lc8lLgBO3fED_ZtsON9I { from: custom; }\\", \\"\\"]);
50835083
// Exports
50845084
___CSS_LOADER_EXPORT___.locals = {
5085-
\\"some-class\\": \\"tAbfDoQYh1hH8fgy5jt_\\",
5086-
\\"class\\": \\"_h7REYQFFxfq7wKBe15e\\"
5085+
\\"some-class\\": \\"_LAQzblHTRmSe8Mk9eNB\\",
5086+
\\"class\\": \\"Lc8lLgBO3fED_ZtsON9I\\"
50875087
};
50885088
export default ___CSS_LOADER_EXPORT___;
50895089
"
@@ -5118,11 +5118,11 @@ Array [
51185118
],
51195119
Array [
51205120
"other.modules.css!=!./my-inline-loader/index.js!./simple.css",
5121-
".tAbfDoQYh1hH8fgy5jt_ {
5121+
"._LAQzblHTRmSe8Mk9eNB {
51225122
color: red;
51235123
}
51245124

5125-
._h7REYQFFxfq7wKBe15e { from: custom; }",
5125+
.Lc8lLgBO3fED_ZtsON9I { from: custom; }",
51265126
"",
51275127
],
51285128
Array [
@@ -15191,7 +15191,7 @@ exports[`"modules" option should work with the 'auto' and exctract CSS using min
1519115191
"/*!*****************************************************************!*\\\\
1519215192
!*** css ../../src/index.js!./modules/mode/relative.module.css ***!
1519315193
\\\\*****************************************************************/
15194-
.IU1H9vP4cpzQT_RvUQ84 {
15194+
._wr0eVpMbaGr94MKhByE {
1519515195
color: red;
1519615196
}
1519715197

@@ -15202,7 +15202,7 @@ exports[`"modules" option should work with the 'auto' and exctract CSS using min
1520215202

1520315203
exports[`"modules" option should work with the 'auto' and exctract CSS using mini-css-extract-plugin: module 1`] = `
1520415204
"// extracted by mini-css-extract-plugin
15205-
export default {\\"relative\\":\\"IU1H9vP4cpzQT_RvUQ84\\"};"
15205+
export default {\\"relative\\":\\"_wr0eVpMbaGr94MKhByE\\"};"
1520615206
`;
1520715207

1520815208
exports[`"modules" option should work with the 'auto' and exctract CSS using mini-css-extract-plugin: warnings 1`] = `Array []`;

0 commit comments

Comments
 (0)