@roots/bud-build 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Build/config.js +247 -252
- package/lib/cjs/Build/index.js +120 -77
- package/lib/cjs/Build/items.js +14 -18
- package/lib/cjs/Build/loaders.js +4 -3
- package/lib/cjs/Build/rules.js +129 -94
- package/lib/cjs/Item/index.js +16 -9
- package/lib/cjs/Item/item.dependencies.js +0 -1
- package/lib/cjs/Item/item.interface.js +0 -1
- package/lib/cjs/Loader/index.js +27 -4
- package/lib/cjs/Rule/index.js +178 -81
- package/lib/cjs/index.js +22 -5
- package/lib/cjs/shared/Base.js +0 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -26
- package/types/Build/config.d.ts.map +1 -1
- package/types/Build/index.d.ts +19 -4
- package/types/Build/index.d.ts.map +1 -1
- package/types/Build/items.d.ts +3 -3
- package/types/Build/items.d.ts.map +1 -1
- package/types/Build/loaders.d.ts.map +1 -1
- package/types/Build/rules.d.ts +38 -21
- package/types/Build/rules.d.ts.map +1 -1
- package/types/Item/index.d.ts +1 -1
- package/types/Item/index.d.ts.map +1 -1
- package/types/Rule/index.d.ts +122 -24
- package/types/Rule/index.d.ts.map +1 -1
- package/types/shared/Base.d.ts.map +1 -1
- package/lib/cjs/Build/config.js.map +0 -1
- package/lib/cjs/Build/index.js.map +0 -1
- package/lib/cjs/Build/items.js.map +0 -1
- package/lib/cjs/Build/loaders.js.map +0 -1
- package/lib/cjs/Build/rules.js.map +0 -1
- package/lib/cjs/Item/index.js.map +0 -1
- package/lib/cjs/Item/item.dependencies.js.map +0 -1
- package/lib/cjs/Item/item.interface.js.map +0 -1
- package/lib/cjs/Loader/index.js.map +0 -1
- package/lib/cjs/Rule/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/shared/Base.js.map +0 -1
- package/lib/esm/Build/config.js +0 -263
- package/lib/esm/Build/config.js.map +0 -1
- package/lib/esm/Build/index.js +0 -133
- package/lib/esm/Build/index.js.map +0 -1
- package/lib/esm/Build/items.js +0 -119
- package/lib/esm/Build/items.js.map +0 -1
- package/lib/esm/Build/loaders.js +0 -55
- package/lib/esm/Build/loaders.js.map +0 -1
- package/lib/esm/Build/rules.js +0 -129
- package/lib/esm/Build/rules.js.map +0 -1
- package/lib/esm/Item/index.js +0 -80
- package/lib/esm/Item/index.js.map +0 -1
- package/lib/esm/Item/item.dependencies.js +0 -4
- package/lib/esm/Item/item.dependencies.js.map +0 -1
- package/lib/esm/Item/item.interface.js +0 -2
- package/lib/esm/Item/item.interface.js.map +0 -1
- package/lib/esm/Loader/index.js +0 -49
- package/lib/esm/Loader/index.js.map +0 -1
- package/lib/esm/Rule/index.js +0 -155
- package/lib/esm/Rule/index.js.map +0 -1
- package/lib/esm/index.js +0 -26
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/shared/Base.js +0 -8
- package/lib/esm/shared/Base.js.map +0 -1
- package/lib/tsconfig-esm.tsbuildinfo +0 -1
package/lib/cjs/Build/config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.config = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const bud_support_1 = require("@roots/bud-support");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const { dirname } = path_1.posix;
|
|
@@ -12,256 +11,252 @@ const { dirname } = path_1.posix;
|
|
|
12
11
|
*
|
|
13
12
|
* @public
|
|
14
13
|
*/
|
|
15
|
-
function config(app) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
*/
|
|
263
|
-
.hooks.on('build.watchOptions', () => app.store.get('build.watchOptions'));
|
|
264
|
-
});
|
|
14
|
+
async function config(app) {
|
|
15
|
+
app.hooks
|
|
16
|
+
.async('build', async () => {
|
|
17
|
+
const entry = await app.hooks.filterAsync('build.entry');
|
|
18
|
+
const plugins = await app.hooks.filterAsync('build.plugins');
|
|
19
|
+
const resolve = await app.hooks.filterAsync('build.resolve');
|
|
20
|
+
return {
|
|
21
|
+
entry,
|
|
22
|
+
plugins,
|
|
23
|
+
resolve,
|
|
24
|
+
bail: app.hooks.filter('build.bail'),
|
|
25
|
+
cache: app.hooks.filter('build.cache'),
|
|
26
|
+
context: app.hooks.filter('build.context'),
|
|
27
|
+
devtool: app.hooks.filter('build.devtool'),
|
|
28
|
+
experiments: app.hooks.filter('build.experiments'),
|
|
29
|
+
externals: app.hooks.filter('build.externals'),
|
|
30
|
+
infrastructureLogging: app.hooks.filter('build.infrastructureLogging'),
|
|
31
|
+
mode: app.hooks.filter('build.mode'),
|
|
32
|
+
module: app.hooks.filter('build.module'),
|
|
33
|
+
name: app.hooks.filter('build.name'),
|
|
34
|
+
node: app.hooks.filter('build.node'),
|
|
35
|
+
output: app.hooks.filter('build.output'),
|
|
36
|
+
optimization: app.hooks.filter('build.optimization'),
|
|
37
|
+
parallelism: app.hooks.filter('build.parallelism'),
|
|
38
|
+
performance: app.hooks.filter('build.performance'),
|
|
39
|
+
profile: app.hooks.filter('build.profile'),
|
|
40
|
+
recordsPath: app.hooks.filter('build.recordsPath'),
|
|
41
|
+
stats: app.hooks.filter('build.stats'),
|
|
42
|
+
target: app.hooks.filter('build.target'),
|
|
43
|
+
watch: app.hooks.filter('build.watch'),
|
|
44
|
+
watchOptions: app.hooks.filter('build.watchOptions'),
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
/**
|
|
48
|
+
* build.bail
|
|
49
|
+
*/
|
|
50
|
+
.hooks.on('build.bail', () => app.store.get('build.bail'))
|
|
51
|
+
/**
|
|
52
|
+
* build.context
|
|
53
|
+
*/
|
|
54
|
+
.hooks.on('build.context', () => app.path('project'))
|
|
55
|
+
/**
|
|
56
|
+
* build.devtool
|
|
57
|
+
*/
|
|
58
|
+
.hooks.on('build.devtool', () => app.store.get('build.devtool'))
|
|
59
|
+
/**
|
|
60
|
+
* build.infrastructureLogging
|
|
61
|
+
*/
|
|
62
|
+
.hooks.on('build.infrastructureLogging', () => app.store.get('build.infrastructureLogging'))
|
|
63
|
+
/**
|
|
64
|
+
* build.mode
|
|
65
|
+
*/
|
|
66
|
+
.hooks.on('build.mode', () => app.mode)
|
|
67
|
+
/**
|
|
68
|
+
* build.module
|
|
69
|
+
*/
|
|
70
|
+
.hooks.on('build.module', () => ({
|
|
71
|
+
rules: app.hooks.filter('build.module.rules'),
|
|
72
|
+
}))
|
|
73
|
+
/**
|
|
74
|
+
* build.module.rules
|
|
75
|
+
*/
|
|
76
|
+
.hooks.on('build.module.rules', () => [
|
|
77
|
+
...app.hooks.filter('build.module.rules.before'),
|
|
78
|
+
{
|
|
79
|
+
oneOf: app.hooks.filter('build.module.rules.oneOf'),
|
|
80
|
+
},
|
|
81
|
+
...app.hooks.filter('build.module.rules.after'),
|
|
82
|
+
])
|
|
83
|
+
/**
|
|
84
|
+
* build.module.rules[1].oneOf
|
|
85
|
+
*/
|
|
86
|
+
.hooks.on('build.module.rules.oneOf', () => Object.values(app.build.rules).map(rule => rule.make()))
|
|
87
|
+
/**
|
|
88
|
+
* build.module.rules[0]
|
|
89
|
+
*/
|
|
90
|
+
.hooks.on('build.module.rules.before', () => [
|
|
91
|
+
{
|
|
92
|
+
test: /\.[cm]?(jsx?|tsx?)$/,
|
|
93
|
+
parser: { requireEnsure: false },
|
|
94
|
+
},
|
|
95
|
+
])
|
|
96
|
+
/**
|
|
97
|
+
* build.module.rules[2]
|
|
98
|
+
*/
|
|
99
|
+
.hooks.on('build.module.rules.after', () => [])
|
|
100
|
+
/**
|
|
101
|
+
* build.name
|
|
102
|
+
*/
|
|
103
|
+
.hooks.on('build.name', () => app.name)
|
|
104
|
+
/**
|
|
105
|
+
* build.node
|
|
106
|
+
*/
|
|
107
|
+
.hooks.on('build.node', () => false)
|
|
108
|
+
/**
|
|
109
|
+
* build.optimization
|
|
110
|
+
*/
|
|
111
|
+
.hooks.on('build.optimization', () => ({
|
|
112
|
+
emitOnErrors: app.hooks.filter('build.optimization.emitOnErrors'),
|
|
113
|
+
minimize: app.hooks.filter('build.optimization.minimize'),
|
|
114
|
+
minimizer: app.hooks.filter('build.optimization.minimizer'),
|
|
115
|
+
moduleIds: app.hooks.filter('build.optimization.moduleIds'),
|
|
116
|
+
runtimeChunk: app.hooks.filter('build.optimization.runtimeChunk'),
|
|
117
|
+
splitChunks: app.hooks.filter('build.optimization.splitChunks'),
|
|
118
|
+
}))
|
|
119
|
+
/**
|
|
120
|
+
* build.optimization.emitOnErrors
|
|
121
|
+
*/
|
|
122
|
+
.hooks.on('build.optimization.emitOnErrors', () => app.store.get('build.optimization.emitOnErrors'))
|
|
123
|
+
/**
|
|
124
|
+
* build.optimization.minimize
|
|
125
|
+
*/
|
|
126
|
+
.hooks.on('build.optimization.minimize', () => app.store.is('features.minimize', true))
|
|
127
|
+
/**
|
|
128
|
+
* build.optimization.minimizer
|
|
129
|
+
*/
|
|
130
|
+
.hooks.on('build.optimization.minimizer', () => ['...'])
|
|
131
|
+
/**
|
|
132
|
+
* build.optimization.moduleIds
|
|
133
|
+
*/
|
|
134
|
+
.hooks.on('build.optimization.moduleIds', () => app.store.get('build.optimization.moduleIds'))
|
|
135
|
+
/**
|
|
136
|
+
* build.optimization.removeEmptyChunks
|
|
137
|
+
*/
|
|
138
|
+
.hooks.on('build.optimization.removeEmptyChunks', () => app.store.get('build.optimization.removeEmptyChunks'))
|
|
139
|
+
/**
|
|
140
|
+
* build.optimization.runtimeChunk
|
|
141
|
+
*/
|
|
142
|
+
.hooks.on('build.optimization.runtimeChunk', () => app.store.is('features.runtimeChunk', true))
|
|
143
|
+
/**
|
|
144
|
+
* build.optimization.splitChunks
|
|
145
|
+
*/
|
|
146
|
+
.hooks.on('build.optimization.splitChunks', () => app.store.is('features.splitChunks', true))
|
|
147
|
+
/**
|
|
148
|
+
* build.output
|
|
149
|
+
*/
|
|
150
|
+
.hooks.on('build.output', () => ({
|
|
151
|
+
assetModuleFilename: app.hooks.filter('build.output.assetModuleFilename'),
|
|
152
|
+
chunkFilename: app.hooks.filter('build.output.chunkFilename'),
|
|
153
|
+
clean: app.hooks.filter('build.output.clean'),
|
|
154
|
+
filename: app.hooks.filter('build.output.filename'),
|
|
155
|
+
path: app.hooks.filter('build.output.path'),
|
|
156
|
+
pathinfo: app.hooks.filter('build.output.pathinfo'),
|
|
157
|
+
publicPath: app.hooks.filter('build.output.publicPath'),
|
|
158
|
+
}))
|
|
159
|
+
/**
|
|
160
|
+
* build.output.assetModuleFilename
|
|
161
|
+
*/
|
|
162
|
+
.hooks.on('build.output.assetModuleFilename', () => app.isProduction && app.store.is('features.hash', true)
|
|
163
|
+
? `assets/${app.store.get('hashFormat')}[ext]`
|
|
164
|
+
: app.store.get('fileFormat'))
|
|
165
|
+
.hooks.on('build.output.clean', () => app.store.get('build.output.clean'))
|
|
166
|
+
/**
|
|
167
|
+
* build.output.filename
|
|
168
|
+
*/
|
|
169
|
+
.hooks.on('build.output.filename', () => `${app.store.is('features.hash', true) && app.isProduction
|
|
170
|
+
? app.store.get('hashFormat')
|
|
171
|
+
: app.store.get('fileFormat')}.js`)
|
|
172
|
+
/**
|
|
173
|
+
* build.output.path
|
|
174
|
+
*/
|
|
175
|
+
.hooks.on('build.output.path', () => app.path('dist'))
|
|
176
|
+
/**
|
|
177
|
+
* build.output.pathinfo
|
|
178
|
+
*/
|
|
179
|
+
.hooks.on('build.output.pathinfo', () => app.store.get('build.output.pathinfo'))
|
|
180
|
+
/**
|
|
181
|
+
* build.output.publicPath
|
|
182
|
+
*/
|
|
183
|
+
.hooks.on('build.output.publicPath', () => app.store.get('location.publicPath'))
|
|
184
|
+
/**
|
|
185
|
+
* Parallelism
|
|
186
|
+
*/
|
|
187
|
+
.hooks.on('build.parallelism', () => app.store.get('build.parallelism'))
|
|
188
|
+
/**
|
|
189
|
+
* build.performance
|
|
190
|
+
*/
|
|
191
|
+
.hooks.on('build.performance', () => app.store.get('build.performance'))
|
|
192
|
+
.hooks.async('build.plugins', async () => {
|
|
193
|
+
const newExtensions = await app.extensions.make();
|
|
194
|
+
return newExtensions;
|
|
195
|
+
})
|
|
196
|
+
/**
|
|
197
|
+
* build.profile
|
|
198
|
+
*/
|
|
199
|
+
.hooks.on('build.profile', () => app.store.get('build.profile'))
|
|
200
|
+
/**
|
|
201
|
+
* build.recordsPath
|
|
202
|
+
*/
|
|
203
|
+
.hooks.on('build.recordsPath', () => app.path('storage', app.name, `modules.json`))
|
|
204
|
+
.hooks.async('build.resolve', async () => {
|
|
205
|
+
const modules = await app.hooks.filterAsync('build.resolve.modules');
|
|
206
|
+
const alias = await app.hooks.filter('build.resolve.alias');
|
|
207
|
+
const extensions = app.hooks.filter('build.resolve.extensions');
|
|
208
|
+
return { modules, alias, extensions };
|
|
209
|
+
})
|
|
210
|
+
/**
|
|
211
|
+
* build.resolve.alias
|
|
212
|
+
*/
|
|
213
|
+
.hooks.on('build.resolve.alias', () => ({}))
|
|
214
|
+
/**
|
|
215
|
+
* build.resolve.modules
|
|
216
|
+
*/
|
|
217
|
+
.hooks.async('build.resolve.modules', async (value) => {
|
|
218
|
+
const budPkg = await (0, bud_support_1.pkgUp)({
|
|
219
|
+
cwd: require.resolve('@roots/bud'),
|
|
220
|
+
});
|
|
221
|
+
const bud = dirname(budPkg);
|
|
222
|
+
const roots = bud
|
|
223
|
+
.split('/')
|
|
224
|
+
.splice(0, bud.split('/').length - 1)
|
|
225
|
+
.join('/');
|
|
226
|
+
const peers = roots
|
|
227
|
+
.split('/')
|
|
228
|
+
.splice(0, roots.split('/').length - 1)
|
|
229
|
+
.join('/');
|
|
230
|
+
return [
|
|
231
|
+
...new Set([
|
|
232
|
+
...(value ?? []),
|
|
233
|
+
app.hooks.filter('location.src'),
|
|
234
|
+
app.hooks.filter('location.modules'),
|
|
235
|
+
peers,
|
|
236
|
+
...(app.project?.get('resolve') ?? []),
|
|
237
|
+
...(app.root?.project.get('resolve') ?? []),
|
|
238
|
+
]),
|
|
239
|
+
];
|
|
240
|
+
})
|
|
241
|
+
/**
|
|
242
|
+
* build.resolve.extensions
|
|
243
|
+
*/
|
|
244
|
+
.hooks.on('build.resolve.extensions', () => app.store.get('build.resolve.extensions'))
|
|
245
|
+
/**
|
|
246
|
+
* build.stats
|
|
247
|
+
*/
|
|
248
|
+
.hooks.on('build.stats', () => app.store.get('build.stats'))
|
|
249
|
+
/**
|
|
250
|
+
* build.target
|
|
251
|
+
*/
|
|
252
|
+
.hooks.on('build.target', () => `browserslist:${app.path('project', 'package.json')}`)
|
|
253
|
+
/**
|
|
254
|
+
* build.watch
|
|
255
|
+
*/
|
|
256
|
+
.hooks.on('build.watch', () => app.store.get('build.watch'))
|
|
257
|
+
/**
|
|
258
|
+
* build.watchOptions
|
|
259
|
+
*/
|
|
260
|
+
.hooks.on('build.watchOptions', () => app.store.get('build.watchOptions'));
|
|
265
261
|
}
|
|
266
262
|
exports.config = config;
|
|
267
|
-
//# sourceMappingURL=config.js.map
|