@roots/bud-build 2024.7.23-8 → 2024.7.25-8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/config/module.js +24 -53
- package/lib/items/index.js +1 -1
- package/lib/rules/css.module.js +1 -1
- package/package.json +5 -5
- package/src/config/module.ts +29 -59
- package/src/items/index.ts +1 -1
- package/src/rules/css.module.ts +1 -1
package/lib/config/module.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export const module = async ({ build: { rules }, hooks: { filter }, path, }) => filter(`build.module`, {
|
2
|
-
noParse:
|
2
|
+
noParse: filter(`build.module.noParse`, undefined),
|
3
3
|
rules: getRules({ filter, path, rules }),
|
4
|
-
unsafeCache:
|
4
|
+
unsafeCache: filter(`build.module.unsafeCache`, undefined),
|
5
5
|
});
|
6
6
|
/**
|
7
7
|
* Get all module.rules
|
@@ -18,7 +18,7 @@ const getRules = ({ filter, path, rules }) => {
|
|
18
18
|
? {
|
19
19
|
oneOf: [
|
20
20
|
rules[`inline-image`]?.toWebpack?.(),
|
21
|
-
rules.image
|
21
|
+
rules.image?.toWebpack?.(),
|
22
22
|
].filter(Boolean),
|
23
23
|
test: filter(`pattern.image`),
|
24
24
|
}
|
@@ -27,7 +27,7 @@ const getRules = ({ filter, path, rules }) => {
|
|
27
27
|
? {
|
28
28
|
oneOf: [
|
29
29
|
rules[`inline-font`]?.toWebpack?.(),
|
30
|
-
rules.font
|
30
|
+
rules.font?.toWebpack?.(),
|
31
31
|
].filter(Boolean),
|
32
32
|
test: filter(`pattern.font`),
|
33
33
|
}
|
@@ -36,61 +36,38 @@ const getRules = ({ filter, path, rules }) => {
|
|
36
36
|
? {
|
37
37
|
oneOf: [
|
38
38
|
rules[`inline-svg`]?.toWebpack?.(),
|
39
|
-
rules.svg
|
39
|
+
rules.svg?.toWebpack?.(),
|
40
40
|
].filter(Boolean),
|
41
41
|
test: filter(`pattern.svg`),
|
42
42
|
}
|
43
43
|
: undefined,
|
44
44
|
]),
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
...makeIssuerRuleSet({ filter, path, rules }),
|
50
|
-
]),
|
51
|
-
].filter(Boolean),
|
52
|
-
},
|
45
|
+
...filter(`build.module.rules.oneOf`, [
|
46
|
+
...makeDefinedRuleSet({ rules }),
|
47
|
+
...makeIssuerRuleSet({ filter, path, rules }),
|
48
|
+
]).filter(Boolean),
|
53
49
|
...filter(`build.module.rules.after`, []),
|
54
50
|
].filter(Boolean);
|
55
51
|
};
|
56
52
|
/**
|
57
|
-
*
|
53
|
+
* Make defined rule set
|
58
54
|
*/
|
59
|
-
const
|
60
|
-
return
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
const makeDefinedRuleSet = ({ rules }) => {
|
56
|
+
return Object.entries(rules)
|
57
|
+
.filter(([key]) => ![
|
58
|
+
`font`,
|
59
|
+
`image`,
|
60
|
+
`inline-font`,
|
61
|
+
`inline-image`,
|
62
|
+
`inline-svg`,
|
63
|
+
`svg`,
|
64
|
+
].includes(key))
|
65
|
+
.map(([, rule]) => rule)
|
68
66
|
.filter(Boolean)
|
69
|
-
.map(rule =>
|
67
|
+
.map(rule => {
|
68
|
+
return `toWebpack` in rule ? rule.toWebpack() : rule;
|
69
|
+
});
|
70
70
|
};
|
71
|
-
const RESOURCES = [
|
72
|
-
`image`,
|
73
|
-
`font`,
|
74
|
-
`svg`,
|
75
|
-
`inline-font`,
|
76
|
-
`inline-image`,
|
77
|
-
`inline-svg`,
|
78
|
-
];
|
79
|
-
const DEFINED = [
|
80
|
-
`csv`,
|
81
|
-
`toml`,
|
82
|
-
`yml`,
|
83
|
-
`json`,
|
84
|
-
`html`,
|
85
|
-
`webp`,
|
86
|
-
`css-module`,
|
87
|
-
`css`,
|
88
|
-
`sass-module`,
|
89
|
-
`sass`,
|
90
|
-
`vue`,
|
91
|
-
`js`,
|
92
|
-
`ts`,
|
93
|
-
];
|
94
71
|
/**
|
95
72
|
* Get rules for css and css-module imports issued by non-css files.
|
96
73
|
*/
|
@@ -126,9 +103,3 @@ const makeIssuerRuleSet = ({ filter, path, rules }) => {
|
|
126
103
|
});
|
127
104
|
return results;
|
128
105
|
};
|
129
|
-
const getNoParse = (filter) => filter(`build.module.noParse`, undefined);
|
130
|
-
/**
|
131
|
-
* By leaving undefined, webpack will strongly cache parsed modules from node_modules
|
132
|
-
* but leave the rest. This is the default behavior.
|
133
|
-
*/
|
134
|
-
const getUnsafeCache = (filter) => filter(`build.module.unsafeCache`, undefined);
|
package/lib/items/index.js
CHANGED
@@ -5,8 +5,8 @@ import isBoolean from '@roots/bud-support/isBoolean';
|
|
5
5
|
export const css = async ({ makeItem }) => makeItem({
|
6
6
|
ident: `css`,
|
7
7
|
loader: `css`,
|
8
|
-
options: { modules: false },
|
9
8
|
}).setOptions(({ hooks: { filter } }) => ({
|
9
|
+
modules: false,
|
10
10
|
sourceMap: isBoolean(filter(`build.devtool`))
|
11
11
|
? filter(`build.devtool`)
|
12
12
|
: true,
|
package/lib/rules/css.module.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@roots/bud-build",
|
3
|
-
"version": "2024.7.
|
3
|
+
"version": "2024.7.25-8",
|
4
4
|
"description": "bud.js core module",
|
5
5
|
"engines": {
|
6
6
|
"node": ">=16"
|
@@ -169,14 +169,14 @@
|
|
169
169
|
"types": "./lib/index.d.ts",
|
170
170
|
"module": "./lib/index.js",
|
171
171
|
"devDependencies": {
|
172
|
-
"@roots/bud-api": "2024.7.
|
173
|
-
"@roots/bud-hooks": "2024.7.
|
172
|
+
"@roots/bud-api": "2024.7.25-8",
|
173
|
+
"@roots/bud-hooks": "2024.7.25-8",
|
174
174
|
"@skypack/package-check": "0.2.2",
|
175
175
|
"@types/node": "20.14.9"
|
176
176
|
},
|
177
177
|
"dependencies": {
|
178
|
-
"@roots/bud-framework": "2024.7.
|
179
|
-
"@roots/bud-support": "2024.7.
|
178
|
+
"@roots/bud-framework": "2024.7.25-8",
|
179
|
+
"@roots/bud-support": "2024.7.25-8",
|
180
180
|
"tslib": "2.6.3"
|
181
181
|
},
|
182
182
|
"volta": {
|
package/src/config/module.ts
CHANGED
@@ -13,9 +13,9 @@ export const module: Factory<`module`> = async ({
|
|
13
13
|
path,
|
14
14
|
}) =>
|
15
15
|
filter(`build.module`, {
|
16
|
-
noParse:
|
16
|
+
noParse: filter(`build.module.noParse`, undefined),
|
17
17
|
rules: getRules({filter, path, rules}),
|
18
|
-
unsafeCache:
|
18
|
+
unsafeCache: filter(`build.module.unsafeCache`, undefined),
|
19
19
|
})
|
20
20
|
|
21
21
|
/**
|
@@ -33,7 +33,7 @@ const getRules = ({filter, path, rules}: Props): Array<RuleSetRule> => {
|
|
33
33
|
? {
|
34
34
|
oneOf: [
|
35
35
|
rules[`inline-image`]?.toWebpack?.(),
|
36
|
-
rules.image
|
36
|
+
rules.image?.toWebpack?.(),
|
37
37
|
].filter(Boolean),
|
38
38
|
test: filter(`pattern.image`),
|
39
39
|
}
|
@@ -43,7 +43,7 @@ const getRules = ({filter, path, rules}: Props): Array<RuleSetRule> => {
|
|
43
43
|
? {
|
44
44
|
oneOf: [
|
45
45
|
rules[`inline-font`]?.toWebpack?.(),
|
46
|
-
rules.font
|
46
|
+
rules.font?.toWebpack?.(),
|
47
47
|
].filter(Boolean),
|
48
48
|
test: filter(`pattern.font`),
|
49
49
|
}
|
@@ -53,65 +53,45 @@ const getRules = ({filter, path, rules}: Props): Array<RuleSetRule> => {
|
|
53
53
|
? {
|
54
54
|
oneOf: [
|
55
55
|
rules[`inline-svg`]?.toWebpack?.(),
|
56
|
-
rules.svg
|
56
|
+
rules.svg?.toWebpack?.(),
|
57
57
|
].filter(Boolean),
|
58
58
|
test: filter(`pattern.svg`),
|
59
59
|
}
|
60
60
|
: undefined,
|
61
61
|
]),
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
].filter(Boolean),
|
69
|
-
},
|
62
|
+
|
63
|
+
...filter(`build.module.rules.oneOf`, [
|
64
|
+
...makeDefinedRuleSet({rules}),
|
65
|
+
...makeIssuerRuleSet({filter, path, rules}),
|
66
|
+
]).filter(Boolean),
|
67
|
+
|
70
68
|
...filter(`build.module.rules.after`, []),
|
71
69
|
].filter(Boolean)
|
72
70
|
}
|
73
71
|
|
74
72
|
/**
|
75
|
-
*
|
73
|
+
* Make defined rule set
|
76
74
|
*/
|
77
|
-
const
|
78
|
-
return
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
const makeDefinedRuleSet = ({rules}: {rules: Props['rules']}) => {
|
76
|
+
return Object.entries(rules)
|
77
|
+
.filter(
|
78
|
+
([key]) =>
|
79
|
+
![
|
80
|
+
`font`,
|
81
|
+
`image`,
|
82
|
+
`inline-font`,
|
83
|
+
`inline-image`,
|
84
|
+
`inline-svg`,
|
85
|
+
`svg`,
|
86
|
+
].includes(key),
|
87
|
+
)
|
88
|
+
.map(([, rule]) => rule)
|
86
89
|
.filter(Boolean)
|
87
|
-
.map(rule =>
|
90
|
+
.map(rule => {
|
91
|
+
return `toWebpack` in rule ? rule.toWebpack() : rule
|
92
|
+
})
|
88
93
|
}
|
89
94
|
|
90
|
-
const RESOURCES = [
|
91
|
-
`image`,
|
92
|
-
`font`,
|
93
|
-
`svg`,
|
94
|
-
`inline-font`,
|
95
|
-
`inline-image`,
|
96
|
-
`inline-svg`,
|
97
|
-
]
|
98
|
-
|
99
|
-
const DEFINED = [
|
100
|
-
`csv`,
|
101
|
-
`toml`,
|
102
|
-
`yml`,
|
103
|
-
`json`,
|
104
|
-
`html`,
|
105
|
-
`webp`,
|
106
|
-
`css-module`,
|
107
|
-
`css`,
|
108
|
-
`sass-module`,
|
109
|
-
`sass`,
|
110
|
-
`vue`,
|
111
|
-
`js`,
|
112
|
-
`ts`,
|
113
|
-
]
|
114
|
-
|
115
95
|
/**
|
116
96
|
* Get rules for css and css-module imports issued by non-css files.
|
117
97
|
*/
|
@@ -152,13 +132,3 @@ const makeIssuerRuleSet = ({filter, path, rules}: Props) => {
|
|
152
132
|
|
153
133
|
return results
|
154
134
|
}
|
155
|
-
|
156
|
-
const getNoParse = (filter: Props[`filter`]) =>
|
157
|
-
filter(`build.module.noParse`, undefined)
|
158
|
-
|
159
|
-
/**
|
160
|
-
* By leaving undefined, webpack will strongly cache parsed modules from node_modules
|
161
|
-
* but leave the rest. This is the default behavior.
|
162
|
-
*/
|
163
|
-
const getUnsafeCache = (filter: Props[`filter`]) =>
|
164
|
-
filter(`build.module.unsafeCache`, undefined)
|
package/src/items/index.ts
CHANGED
@@ -10,8 +10,8 @@ export const css: Factory<Item> = async ({makeItem}) =>
|
|
10
10
|
makeItem({
|
11
11
|
ident: `css`,
|
12
12
|
loader: `css`,
|
13
|
-
options: {modules: false},
|
14
13
|
}).setOptions(({hooks: {filter}}) => ({
|
14
|
+
modules: false,
|
15
15
|
sourceMap: isBoolean(filter(`build.devtool`))
|
16
16
|
? filter(`build.devtool`)
|
17
17
|
: true,
|
package/src/rules/css.module.ts
CHANGED
@@ -3,7 +3,7 @@ import type {Factory} from '@roots/bud-build/registry'
|
|
3
3
|
const cssModule: Factory = async ({filter, makeRule, path}) =>
|
4
4
|
makeRule()
|
5
5
|
.setTest(filter(`pattern.cssModule`))
|
6
|
-
.setInclude([() => path(`@src`)])
|
6
|
+
.setInclude([({path}) => path(`@src`)])
|
7
7
|
.setUse([`precss`, `css-module`])
|
8
8
|
|
9
9
|
export {cssModule as default}
|