@roots/bud-compiler 2023.7.18-645 → 2023.7.20-622
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/service.js +31 -4
- package/package.json +5 -5
- package/src/service.tsx +41 -4
package/lib/service.js
CHANGED
@@ -44,7 +44,11 @@ export class Compiler extends Service {
|
|
44
44
|
: await Promise.all(Object.values(bud.children).map(async (child) => await child.build.make().catch(error => {
|
45
45
|
throw error;
|
46
46
|
})));
|
47
|
-
|
47
|
+
const cores = Math.max(cpus().length, 1);
|
48
|
+
const compilations = Math.max(Object.keys(bud.children ?? []).length, 1);
|
49
|
+
const parallelism = Math.max(Math.floor(cores / compilations), 1);
|
50
|
+
this.config.parallelism = parallelism;
|
51
|
+
this.logger.info(`parallel compilations: ${this.config.parallelism}`);
|
48
52
|
await bud.hooks.fire(`compiler.before`, bud).catch(error => {
|
49
53
|
throw error;
|
50
54
|
});
|
@@ -156,11 +160,34 @@ export class Compiler extends Service {
|
|
156
160
|
const parseError = (error) => {
|
157
161
|
let file;
|
158
162
|
const moduleIdent = error.moduleId ?? error.moduleName;
|
159
|
-
|
163
|
+
/**
|
164
|
+
* In a perfect world webpack plugins would use the
|
165
|
+
* `nameForCondition` property to identify the module.
|
166
|
+
*/
|
167
|
+
let module = this.compilationStats.children
|
160
168
|
.flatMap(child => child?.modules)
|
161
169
|
.find(module => module?.id === moduleIdent || module?.name === moduleIdent);
|
170
|
+
/**
|
171
|
+
* If the module is not found, we try to parse the error message
|
172
|
+
*/
|
173
|
+
if (!moduleIdent) {
|
174
|
+
const stylelintExtracted = error.message.match(/file:\/\/(.*)\x07(.*)\x1B]8;;/);
|
175
|
+
if (stylelintExtracted?.[1]) {
|
176
|
+
module = {
|
177
|
+
name: stylelintExtracted[2] ?? stylelintExtracted[1],
|
178
|
+
nameForCondition: stylelintExtracted[1],
|
179
|
+
};
|
180
|
+
}
|
181
|
+
}
|
182
|
+
/**
|
183
|
+
* If the module is still not found, we return the error as-is
|
184
|
+
*/
|
162
185
|
if (!module)
|
163
186
|
return error;
|
187
|
+
/**
|
188
|
+
* We'll prefer the `nameForCondition` property if it exists,
|
189
|
+
* otherwise we'll use the `name` property.
|
190
|
+
*/
|
164
191
|
if (module.nameForCondition) {
|
165
192
|
file = module.nameForCondition;
|
166
193
|
}
|
@@ -174,8 +201,8 @@ export class Compiler extends Service {
|
|
174
201
|
return errors?.map(parseError).filter(Boolean);
|
175
202
|
}
|
176
203
|
catch (error) {
|
177
|
-
this.
|
178
|
-
return
|
204
|
+
this.logger.warn(`error parsing errors`, error);
|
205
|
+
return errors;
|
179
206
|
}
|
180
207
|
}
|
181
208
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@roots/bud-compiler",
|
3
|
-
"version": "2023.7.
|
3
|
+
"version": "2023.7.20-622",
|
4
4
|
"description": "Compilation handler",
|
5
5
|
"engines": {
|
6
6
|
"node": ">=16"
|
@@ -61,15 +61,15 @@
|
|
61
61
|
"types": "./lib/index.d.ts",
|
62
62
|
"module": "./lib/index.js",
|
63
63
|
"devDependencies": {
|
64
|
-
"@roots/bud-api": "2023.7.
|
64
|
+
"@roots/bud-api": "2023.7.20-622",
|
65
65
|
"@skypack/package-check": "0.2.2",
|
66
66
|
"@types/node": "18.16.19",
|
67
67
|
"@types/react": "18.2.15"
|
68
68
|
},
|
69
69
|
"dependencies": {
|
70
|
-
"@roots/bud-dashboard": "2023.7.
|
71
|
-
"@roots/bud-framework": "2023.7.
|
72
|
-
"@roots/bud-support": "2023.7.
|
70
|
+
"@roots/bud-dashboard": "2023.7.20-622",
|
71
|
+
"@roots/bud-framework": "2023.7.20-622",
|
72
|
+
"@roots/bud-support": "2023.7.20-622",
|
73
73
|
"react": "18.2.0",
|
74
74
|
"tslib": "2.6.0"
|
75
75
|
},
|
package/src/service.tsx
CHANGED
@@ -70,7 +70,16 @@ export class Compiler extends Service implements BudCompiler {
|
|
70
70
|
}),
|
71
71
|
),
|
72
72
|
)
|
73
|
-
|
73
|
+
|
74
|
+
const cores = Math.max(cpus().length, 1)
|
75
|
+
const compilations = Math.max(
|
76
|
+
Object.keys(bud.children ?? []).length,
|
77
|
+
1,
|
78
|
+
)
|
79
|
+
const parallelism = Math.max(Math.floor(cores / compilations), 1)
|
80
|
+
|
81
|
+
this.config.parallelism = parallelism
|
82
|
+
this.logger.info(`parallel compilations: ${this.config.parallelism}`)
|
74
83
|
|
75
84
|
await bud.hooks.fire(`compiler.before`, bud).catch(error => {
|
76
85
|
throw error
|
@@ -158,6 +167,7 @@ export class Compiler extends Service implements BudCompiler {
|
|
158
167
|
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
159
168
|
title: makeNoticeTitle(child),
|
160
169
|
})
|
170
|
+
|
161
171
|
this.app.notifier.openEditor(error.file)
|
162
172
|
} catch (error) {
|
163
173
|
this.logger.error(error)
|
@@ -214,15 +224,42 @@ export class Compiler extends Service implements BudCompiler {
|
|
214
224
|
|
215
225
|
const moduleIdent = error.moduleId ?? error.moduleName
|
216
226
|
|
217
|
-
|
227
|
+
/**
|
228
|
+
* In a perfect world webpack plugins would use the
|
229
|
+
* `nameForCondition` property to identify the module.
|
230
|
+
*/
|
231
|
+
let module = this.compilationStats.children
|
218
232
|
.flatMap(child => child?.modules)
|
219
233
|
.find(
|
220
234
|
module =>
|
221
235
|
module?.id === moduleIdent || module?.name === moduleIdent,
|
222
236
|
)
|
223
237
|
|
238
|
+
/**
|
239
|
+
* If the module is not found, we try to parse the error message
|
240
|
+
*/
|
241
|
+
if (!moduleIdent) {
|
242
|
+
const stylelintExtracted = error.message.match(
|
243
|
+
/file:\/\/(.*)\x07(.*)\x1B]8;;/,
|
244
|
+
)
|
245
|
+
|
246
|
+
if (stylelintExtracted?.[1]) {
|
247
|
+
module = {
|
248
|
+
name: stylelintExtracted[2] ?? stylelintExtracted[1],
|
249
|
+
nameForCondition: stylelintExtracted[1],
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
/**
|
255
|
+
* If the module is still not found, we return the error as-is
|
256
|
+
*/
|
224
257
|
if (!module) return error
|
225
258
|
|
259
|
+
/**
|
260
|
+
* We'll prefer the `nameForCondition` property if it exists,
|
261
|
+
* otherwise we'll use the `name` property.
|
262
|
+
*/
|
226
263
|
if (module.nameForCondition) {
|
227
264
|
file = module.nameForCondition
|
228
265
|
} else if (module.name) {
|
@@ -236,8 +273,8 @@ export class Compiler extends Service implements BudCompiler {
|
|
236
273
|
|
237
274
|
return errors?.map(parseError).filter(Boolean)
|
238
275
|
} catch (error) {
|
239
|
-
this.
|
240
|
-
return
|
276
|
+
this.logger.warn(`error parsing errors`, error)
|
277
|
+
return errors
|
241
278
|
}
|
242
279
|
}
|
243
280
|
}
|