Skip to content

Commit 7ec6bb9

Browse files
chore: update other packages
1 parent d182d67 commit 7ec6bb9

File tree

4 files changed

+67
-135
lines changed

4 files changed

+67
-135
lines changed

package-lock.json

Lines changed: 26 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"icss-utils": "^5.0.0-rc.0",
4949
"loader-utils": "^2.0.0",
5050
"postcss": "^8.1.1",
51-
"postcss-modules-extract-imports": "^2.0.0",
52-
"postcss-modules-local-by-default": "^3.0.3",
53-
"postcss-modules-scope": "^2.2.0",
54-
"postcss-modules-values": "^3.0.0",
51+
"postcss-modules-extract-imports": "^3.0.0-rc.1",
52+
"postcss-modules-local-by-default": "^4.0.0-rc.1",
53+
"postcss-modules-scope": "^3.0.0-rc.1",
54+
"postcss-modules-values": "^4.0.0-rc.2",
5555
"postcss-value-parser": "^4.1.0",
5656
"schema-utils": "^3.0.0",
5757
"semver": "^7.3.2"

src/index.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ export default async function loader(content, map, meta) {
5656
plugins.push(...getModulesPlugins(options, this));
5757
}
5858

59+
const icssPluginImports = [];
60+
const icssPluginApi = [];
61+
62+
if (shouldUseIcssPlugin(options)) {
63+
const icssResolver = this.getResolve({
64+
conditionNames: ['style'],
65+
extensions: [],
66+
mainFields: ['css', 'style', 'main', '...'],
67+
mainFiles: ['index', '...'],
68+
});
69+
70+
plugins.push(
71+
icssParser({
72+
imports: icssPluginImports,
73+
api: icssPluginApi,
74+
replacements,
75+
exports,
76+
context: this.context,
77+
rootContext: this.rootContext,
78+
resolver: icssResolver,
79+
urlHandler: (url) =>
80+
stringifyRequest(
81+
this,
82+
getPreRequester(this)(options.importLoaders) + url
83+
),
84+
})
85+
);
86+
}
87+
5988
const importPluginImports = [];
6089
const importPluginApi = [];
6190

@@ -108,35 +137,6 @@ export default async function loader(content, map, meta) {
108137
);
109138
}
110139

111-
const icssPluginImports = [];
112-
const icssPluginApi = [];
113-
114-
if (shouldUseIcssPlugin(options)) {
115-
const icssResolver = this.getResolve({
116-
conditionNames: ['style'],
117-
extensions: [],
118-
mainFields: ['css', 'style', 'main', '...'],
119-
mainFiles: ['index', '...'],
120-
});
121-
122-
plugins.push(
123-
icssParser({
124-
imports: icssPluginImports,
125-
api: icssPluginApi,
126-
replacements,
127-
exports,
128-
context: this.context,
129-
rootContext: this.rootContext,
130-
resolver: icssResolver,
131-
urlHandler: (url) =>
132-
stringifyRequest(
133-
this,
134-
getPreRequester(this)(options.importLoaders) + url
135-
),
136-
})
137-
);
138-
}
139-
140140
// Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
141141
if (meta) {
142142
const { ast } = meta;

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,15 +4072,12 @@ exports[`"modules" option should work with "url" and "namedExport": module 1`] =
40724072
"// Imports
40734073
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
40744074
import ___CSS_LOADER_ICSS_IMPORT_0___, * as ___CSS_LOADER_ICSS_IMPORT_0____NAMED___ from \\"-!../../../../src/index.js??[ident]!./shared.css\\";
4075-
import ___CSS_LOADER_GET_URL_IMPORT___ from \\"../../../../src/runtime/getUrl.js\\";
4076-
import ___CSS_LOADER_URL_IMPORT_0___ from \\"./img.png\\";
40774075
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
40784076
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
4079-
var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);
40804077
// Module
4081-
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\nbody {\\\\n background: \\" + ___CSS_LOADER_ICSS_IMPORT_0____NAMED___[\\"vUrlOther\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
4078+
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n background: url('./img.png');\\\\n}\\\\n\\\\nbody {\\\\n background: \\" + ___CSS_LOADER_ICSS_IMPORT_0____NAMED___[\\"vUrlOther\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
40824079
// Exports
4083-
export const vUrl = \\"url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\")\\";
4080+
export const vUrl = \\"url('./img.png')\\";
40844081
export const vUrlOther = \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0____NAMED___[\\"vUrlOther\\"] + \\"\\";
40854082
export default ___CSS_LOADER_EXPORT___;
40864083
"
@@ -4097,11 +4094,11 @@ Array [
40974094
Array [
40984095
"./modules/url/source.css",
40994096
"a {
4100-
background: url(/webpack/public/path/img.png);
4097+
background: url('./img.png');
41014098
}
41024099

41034100
body {
4104-
background: url(/webpack/public/path/img.png);
4101+
background: url('./img.png');
41054102
}
41064103
",
41074104
"",
@@ -4117,16 +4114,13 @@ exports[`"modules" option should work with "url": module 1`] = `
41174114
"// Imports
41184115
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
41194116
import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../src/index.js??[ident]!./shared.css\\";
4120-
import ___CSS_LOADER_GET_URL_IMPORT___ from \\"../../../../src/runtime/getUrl.js\\";
4121-
import ___CSS_LOADER_URL_IMPORT_0___ from \\"./img.png\\";
41224117
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
41234118
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
4124-
var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);
41254119
// Module
4126-
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\nbody {\\\\n background: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-url-other\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
4120+
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n background: url('./img.png');\\\\n}\\\\n\\\\nbody {\\\\n background: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-url-other\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
41274121
// Exports
41284122
___CSS_LOADER_EXPORT___.locals = {
4129-
\\"v-url\\": \\"url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\")\\",
4123+
\\"v-url\\": \\"url('./img.png')\\",
41304124
\\"v-url-other\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-url-other\\"] + \\"\\"
41314125
};
41324126
export default ___CSS_LOADER_EXPORT___;
@@ -4144,11 +4138,11 @@ Array [
41444138
Array [
41454139
"./modules/url/source.css",
41464140
"a {
4147-
background: url(/webpack/public/path/img.png);
4141+
background: url('./img.png');
41484142
}
41494143

41504144
body {
4151-
background: url(/webpack/public/path/img.png);
4145+
background: url('./img.png');
41524146
}
41534147
",
41544148
"",

0 commit comments

Comments
 (0)