@roots/bud-compiler 2023.7.18-452 → 2023.7.20-1957
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 +29 -3
- package/package.json +5 -5
- package/src/service.tsx +34 -4
package/lib/service.js
CHANGED
@@ -45,6 +45,7 @@ export class Compiler extends Service {
|
|
45
45
|
throw error;
|
46
46
|
})));
|
47
47
|
this.config.parallelism = Math.max(cpus().length - 1, 1);
|
48
|
+
this.logger.info(`parallel compilations: ${this.config.parallelism}`);
|
48
49
|
await bud.hooks.fire(`compiler.before`, bud).catch(error => {
|
49
50
|
throw error;
|
50
51
|
});
|
@@ -69,6 +70,8 @@ export class Compiler extends Service {
|
|
69
70
|
*/
|
70
71
|
onError(error) {
|
71
72
|
process.exitCode = 1;
|
73
|
+
if (!error)
|
74
|
+
return;
|
72
75
|
this.app.server?.appliedMiddleware?.hot?.publish({ error });
|
73
76
|
this.app.notifier?.notify({
|
74
77
|
group: this.app.label,
|
@@ -156,11 +159,34 @@ export class Compiler extends Service {
|
|
156
159
|
const parseError = (error) => {
|
157
160
|
let file;
|
158
161
|
const moduleIdent = error.moduleId ?? error.moduleName;
|
159
|
-
|
162
|
+
/**
|
163
|
+
* In a perfect world webpack plugins would use the
|
164
|
+
* `nameForCondition` property to identify the module.
|
165
|
+
*/
|
166
|
+
let module = this.compilationStats.children
|
160
167
|
.flatMap(child => child?.modules)
|
161
168
|
.find(module => module?.id === moduleIdent || module?.name === moduleIdent);
|
169
|
+
/**
|
170
|
+
* If the module is not found, we try to parse the error message
|
171
|
+
*/
|
172
|
+
if (!moduleIdent) {
|
173
|
+
const stylelintExtracted = error.message.match(/file:\/\/(.*)\x07(.*)\x1B]8;;/);
|
174
|
+
if (stylelintExtracted?.[1]) {
|
175
|
+
module = {
|
176
|
+
name: stylelintExtracted[2] ?? stylelintExtracted[1],
|
177
|
+
nameForCondition: stylelintExtracted[1],
|
178
|
+
};
|
179
|
+
}
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* If the module is still not found, we return the error as-is
|
183
|
+
*/
|
162
184
|
if (!module)
|
163
185
|
return error;
|
186
|
+
/**
|
187
|
+
* We'll prefer the `nameForCondition` property if it exists,
|
188
|
+
* otherwise we'll use the `name` property.
|
189
|
+
*/
|
164
190
|
if (module.nameForCondition) {
|
165
191
|
file = module.nameForCondition;
|
166
192
|
}
|
@@ -174,8 +200,8 @@ export class Compiler extends Service {
|
|
174
200
|
return errors?.map(parseError).filter(Boolean);
|
175
201
|
}
|
176
202
|
catch (error) {
|
177
|
-
this.
|
178
|
-
return
|
203
|
+
this.logger.warn(`error parsing errors`, error);
|
204
|
+
return errors;
|
179
205
|
}
|
180
206
|
}
|
181
207
|
}
|
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-1957",
|
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-1957",
|
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-1957",
|
71
|
+
"@roots/bud-framework": "2023.7.20-1957",
|
72
|
+
"@roots/bud-support": "2023.7.20-1957",
|
73
73
|
"react": "18.2.0",
|
74
74
|
"tslib": "2.6.0"
|
75
75
|
},
|
package/src/service.tsx
CHANGED
@@ -70,7 +70,9 @@ export class Compiler extends Service implements BudCompiler {
|
|
70
70
|
}),
|
71
71
|
),
|
72
72
|
)
|
73
|
+
|
73
74
|
this.config.parallelism = Math.max(cpus().length - 1, 1)
|
75
|
+
this.logger.info(`parallel compilations: ${this.config.parallelism}`)
|
74
76
|
|
75
77
|
await bud.hooks.fire(`compiler.before`, bud).catch(error => {
|
76
78
|
throw error
|
@@ -87,7 +89,6 @@ export class Compiler extends Service implements BudCompiler {
|
|
87
89
|
|
88
90
|
this.instance.hooks.done.tap(bud.label, (stats: any) => {
|
89
91
|
this.onStats(stats)
|
90
|
-
|
91
92
|
bud.hooks.fire(`compiler.done`, bud, this.stats).catch(error => {
|
92
93
|
throw error
|
93
94
|
})
|
@@ -102,6 +103,7 @@ export class Compiler extends Service implements BudCompiler {
|
|
102
103
|
@bind
|
103
104
|
public onError(error: BudErrorClass | webpack.WebpackError) {
|
104
105
|
process.exitCode = 1
|
106
|
+
if (!error) return
|
105
107
|
|
106
108
|
this.app.server?.appliedMiddleware?.hot?.publish({error})
|
107
109
|
|
@@ -158,6 +160,7 @@ export class Compiler extends Service implements BudCompiler {
|
|
158
160
|
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
159
161
|
title: makeNoticeTitle(child),
|
160
162
|
})
|
163
|
+
|
161
164
|
this.app.notifier.openEditor(error.file)
|
162
165
|
} catch (error) {
|
163
166
|
this.logger.error(error)
|
@@ -214,15 +217,42 @@ export class Compiler extends Service implements BudCompiler {
|
|
214
217
|
|
215
218
|
const moduleIdent = error.moduleId ?? error.moduleName
|
216
219
|
|
217
|
-
|
220
|
+
/**
|
221
|
+
* In a perfect world webpack plugins would use the
|
222
|
+
* `nameForCondition` property to identify the module.
|
223
|
+
*/
|
224
|
+
let module = this.compilationStats.children
|
218
225
|
.flatMap(child => child?.modules)
|
219
226
|
.find(
|
220
227
|
module =>
|
221
228
|
module?.id === moduleIdent || module?.name === moduleIdent,
|
222
229
|
)
|
223
230
|
|
231
|
+
/**
|
232
|
+
* If the module is not found, we try to parse the error message
|
233
|
+
*/
|
234
|
+
if (!moduleIdent) {
|
235
|
+
const stylelintExtracted = error.message.match(
|
236
|
+
/file:\/\/(.*)\x07(.*)\x1B]8;;/,
|
237
|
+
)
|
238
|
+
|
239
|
+
if (stylelintExtracted?.[1]) {
|
240
|
+
module = {
|
241
|
+
name: stylelintExtracted[2] ?? stylelintExtracted[1],
|
242
|
+
nameForCondition: stylelintExtracted[1],
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
/**
|
248
|
+
* If the module is still not found, we return the error as-is
|
249
|
+
*/
|
224
250
|
if (!module) return error
|
225
251
|
|
252
|
+
/**
|
253
|
+
* We'll prefer the `nameForCondition` property if it exists,
|
254
|
+
* otherwise we'll use the `name` property.
|
255
|
+
*/
|
226
256
|
if (module.nameForCondition) {
|
227
257
|
file = module.nameForCondition
|
228
258
|
} else if (module.name) {
|
@@ -236,8 +266,8 @@ export class Compiler extends Service implements BudCompiler {
|
|
236
266
|
|
237
267
|
return errors?.map(parseError).filter(Boolean)
|
238
268
|
} catch (error) {
|
239
|
-
this.
|
240
|
-
return
|
269
|
+
this.logger.warn(`error parsing errors`, error)
|
270
|
+
return errors
|
241
271
|
}
|
242
272
|
}
|
243
273
|
}
|