@roots/bud-compiler 2023.6.12 → 2023.6.13-1651
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/compiler.service.d.ts +11 -11
- package/lib/compiler.service.js +51 -50
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +9 -10
- package/src/compiler.service.tsx +72 -72
- package/src/index.ts +1 -2
@@ -1,12 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import type { MultiCompiler, MultiStats, StatsError } from '@roots/bud-framework/config';
|
2
2
|
import type { Compiler as Contract } from '@roots/bud-framework/services';
|
3
3
|
import type { ErrorWithSourceFile } from '@roots/bud-support/open';
|
4
|
-
import
|
5
|
-
import
|
4
|
+
import { Service } from '@roots/bud-framework/service';
|
5
|
+
import webpack from 'webpack';
|
6
6
|
/**
|
7
7
|
* Wepback compilation controller class
|
8
8
|
*/
|
9
9
|
export declare class Compiler extends Service implements Contract.Service {
|
10
|
+
/**
|
11
|
+
* Configuration
|
12
|
+
*/
|
13
|
+
config: Contract.Service[`config`];
|
10
14
|
/**
|
11
15
|
* Compiler implementation
|
12
16
|
*/
|
@@ -19,22 +23,18 @@ export declare class Compiler extends Service implements Contract.Service {
|
|
19
23
|
* Compilation stats
|
20
24
|
*/
|
21
25
|
stats: Contract.Service[`stats`];
|
22
|
-
/**
|
23
|
-
* Configuration
|
24
|
-
*/
|
25
|
-
config: Contract.Service[`config`];
|
26
26
|
/**
|
27
27
|
* Initiates compilation
|
28
28
|
*/
|
29
29
|
compile(): Promise<MultiCompiler>;
|
30
|
-
/**
|
31
|
-
* Stats handler
|
32
|
-
*/
|
33
|
-
onStats(stats: MultiStats): Promise<void>;
|
34
30
|
/**
|
35
31
|
* Compiler error event
|
36
32
|
*/
|
37
33
|
onError(error: Error): Promise<void>;
|
34
|
+
/**
|
35
|
+
* Stats handler
|
36
|
+
*/
|
37
|
+
onStats(stats: MultiStats): Promise<void>;
|
38
38
|
/**
|
39
39
|
* Parse errors from webpack stats
|
40
40
|
*/
|
package/lib/compiler.service.js
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
|
-
import { pathToFileURL } from 'node:url';
|
4
3
|
import * as App from '@roots/bud-dashboard/app';
|
5
4
|
import { Service } from '@roots/bud-framework/service';
|
6
5
|
import { bind } from '@roots/bud-support/decorators/bind';
|
7
6
|
import { BudError, CompilerError } from '@roots/bud-support/errors';
|
8
7
|
import { duration } from '@roots/bud-support/human-readable';
|
8
|
+
import * as Ink from '@roots/bud-support/ink';
|
9
9
|
import stripAnsi from '@roots/bud-support/strip-ansi';
|
10
|
-
import
|
10
|
+
import { pathToFileURL } from 'node:url';
|
11
|
+
import webpack from 'webpack';
|
11
12
|
/**
|
12
13
|
* Wepback compilation controller class
|
13
14
|
*/
|
14
15
|
export class Compiler extends Service {
|
16
|
+
/**
|
17
|
+
* Configuration
|
18
|
+
*/
|
19
|
+
config = [];
|
15
20
|
/**
|
16
21
|
* Compiler implementation
|
17
22
|
*/
|
@@ -24,10 +29,6 @@ export class Compiler extends Service {
|
|
24
29
|
* Compilation stats
|
25
30
|
*/
|
26
31
|
stats;
|
27
|
-
/**
|
28
|
-
* Configuration
|
29
|
-
*/
|
30
|
-
config = [];
|
31
32
|
/**
|
32
33
|
* Initiates compilation
|
33
34
|
*/
|
@@ -56,6 +57,39 @@ export class Compiler extends Service {
|
|
56
57
|
await this.app.hooks.fire(`compiler.after`, this.app);
|
57
58
|
return this.instance;
|
58
59
|
}
|
60
|
+
/**
|
61
|
+
* Compiler error event
|
62
|
+
*/
|
63
|
+
async onError(error) {
|
64
|
+
process.exitCode = 1;
|
65
|
+
await this.app.hooks.fire(`compiler.error`, error);
|
66
|
+
this.app.isDevelopment &&
|
67
|
+
this.app.server.appliedMiddleware?.hot?.publish({ error });
|
68
|
+
try {
|
69
|
+
this.app.notifier.notify({
|
70
|
+
group: this.app.label,
|
71
|
+
message: error.message,
|
72
|
+
subtitle: error.name,
|
73
|
+
});
|
74
|
+
}
|
75
|
+
catch (error) {
|
76
|
+
this.logger.error(error);
|
77
|
+
}
|
78
|
+
try {
|
79
|
+
Ink.render(_jsx(App.Error, { error: new CompilerError(error.message, {
|
80
|
+
props: {
|
81
|
+
details: `This error was thrown by the webpack compiler itself. It is not the same as a syntax error. It is likely a missing or unresolvable build dependency.`,
|
82
|
+
docs: new URL(`https://bud.js.org/`),
|
83
|
+
issues: new URL(`https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`),
|
84
|
+
stack: error.stack,
|
85
|
+
thrownBy: `webpack`,
|
86
|
+
},
|
87
|
+
}) }));
|
88
|
+
}
|
89
|
+
catch (error) {
|
90
|
+
throw BudError.normalize(error);
|
91
|
+
}
|
92
|
+
}
|
59
93
|
/**
|
60
94
|
* Stats handler
|
61
95
|
*/
|
@@ -80,11 +114,11 @@ export class Compiler extends Service {
|
|
80
114
|
if (!error)
|
81
115
|
return;
|
82
116
|
this.app.notifier.notify({
|
83
|
-
|
84
|
-
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
117
|
+
group: `${this.app.label}-${child.name}`,
|
85
118
|
message: stripAnsi(error.message),
|
86
119
|
open: error.file ? pathToFileURL(error.file) : ``,
|
87
|
-
|
120
|
+
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
121
|
+
title: makeNoticeTitle(child),
|
88
122
|
});
|
89
123
|
this.app.notifier.openEditor(error.file);
|
90
124
|
}
|
@@ -98,13 +132,13 @@ export class Compiler extends Service {
|
|
98
132
|
.forEach(child => {
|
99
133
|
try {
|
100
134
|
this.app.notifier.notify({
|
101
|
-
|
102
|
-
subtitle: `Build successful`,
|
135
|
+
group: `${this.app.label}-${child.name}`,
|
103
136
|
message: child.modules
|
104
137
|
? `${child.modules.length} modules compiled in ${duration(child.time)}`
|
105
138
|
: `Compiled in ${duration(child.time)}`,
|
106
|
-
group: `${this.app.label}-${child.name}`,
|
107
139
|
open: this.app.server?.publicUrl.href,
|
140
|
+
subtitle: `Build successful`,
|
141
|
+
title: makeNoticeTitle(child),
|
108
142
|
});
|
109
143
|
this.app.notifier.openBrowser(this.app.server?.publicUrl.href);
|
110
144
|
}
|
@@ -114,39 +148,6 @@ export class Compiler extends Service {
|
|
114
148
|
});
|
115
149
|
await statsUpdate;
|
116
150
|
}
|
117
|
-
/**
|
118
|
-
* Compiler error event
|
119
|
-
*/
|
120
|
-
async onError(error) {
|
121
|
-
process.exitCode = 1;
|
122
|
-
await this.app.hooks.fire(`compiler.error`, error);
|
123
|
-
this.app.isDevelopment &&
|
124
|
-
this.app.server.appliedMiddleware?.hot?.publish({ error });
|
125
|
-
try {
|
126
|
-
this.app.notifier.notify({
|
127
|
-
subtitle: error.name,
|
128
|
-
message: error.message,
|
129
|
-
group: this.app.label,
|
130
|
-
});
|
131
|
-
}
|
132
|
-
catch (error) {
|
133
|
-
this.logger.error(error);
|
134
|
-
}
|
135
|
-
try {
|
136
|
-
Ink.render(_jsx(App.Error, { error: new CompilerError(error.message, {
|
137
|
-
props: {
|
138
|
-
details: `This error was thrown by the webpack compiler itself. It is not the same as a syntax error. It is likely a missing or unresolvable build dependency.`,
|
139
|
-
stack: error.stack,
|
140
|
-
thrownBy: `webpack`,
|
141
|
-
docs: new URL(`https://bud.js.org/`),
|
142
|
-
issues: new URL(`https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`),
|
143
|
-
},
|
144
|
-
}) }));
|
145
|
-
}
|
146
|
-
catch (error) {
|
147
|
-
throw BudError.normalize(error);
|
148
|
-
}
|
149
|
-
}
|
150
151
|
/**
|
151
152
|
* Parse errors from webpack stats
|
152
153
|
*/
|
@@ -171,7 +172,7 @@ export class Compiler extends Service {
|
|
171
172
|
if (!file) {
|
172
173
|
return error;
|
173
174
|
}
|
174
|
-
return { ...error, name: module.name ?? error.name
|
175
|
+
return { ...error, file, name: module.name ?? error.name };
|
175
176
|
};
|
176
177
|
return errors?.map(parseError).filter(Boolean);
|
177
178
|
}
|
@@ -190,15 +191,15 @@ __decorate([
|
|
190
191
|
__decorate([
|
191
192
|
bind,
|
192
193
|
__metadata("design:type", Function),
|
193
|
-
__metadata("design:paramtypes", [
|
194
|
+
__metadata("design:paramtypes", [Error]),
|
194
195
|
__metadata("design:returntype", Promise)
|
195
|
-
], Compiler.prototype, "
|
196
|
+
], Compiler.prototype, "onError", null);
|
196
197
|
__decorate([
|
197
198
|
bind,
|
198
199
|
__metadata("design:type", Function),
|
199
|
-
__metadata("design:paramtypes", [
|
200
|
+
__metadata("design:paramtypes", [Function]),
|
200
201
|
__metadata("design:returntype", Promise)
|
201
|
-
], Compiler.prototype, "
|
202
|
+
], Compiler.prototype, "onStats", null);
|
202
203
|
__decorate([
|
203
204
|
bind,
|
204
205
|
__metadata("design:type", Function),
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@roots/bud-compiler",
|
3
|
-
"version": "2023.6.
|
3
|
+
"version": "2023.6.13-1651",
|
4
4
|
"description": "Compilation handler",
|
5
5
|
"engines": {
|
6
6
|
"node": ">=16"
|
@@ -71,19 +71,18 @@
|
|
71
71
|
"types": "./lib/index.d.ts",
|
72
72
|
"module": "./lib/index.js",
|
73
73
|
"devDependencies": {
|
74
|
-
"@roots/bud-api": "2023.6.
|
74
|
+
"@roots/bud-api": "2023.6.13-1651",
|
75
75
|
"@skypack/package-check": "0.2.2",
|
76
|
-
"@types/node": "18.16.
|
77
|
-
"@types/react": "18.2.
|
76
|
+
"@types/node": "18.16.16",
|
77
|
+
"@types/react": "18.2.9"
|
78
78
|
},
|
79
79
|
"dependencies": {
|
80
|
-
"@roots/bud-dashboard": "2023.6.
|
81
|
-
"@roots/bud-framework": "2023.6.
|
82
|
-
"@roots/bud-support": "2023.6.
|
83
|
-
"ink": "4.2.0",
|
80
|
+
"@roots/bud-dashboard": "2023.6.13-1651",
|
81
|
+
"@roots/bud-framework": "2023.6.13-1651",
|
82
|
+
"@roots/bud-support": "2023.6.13-1651",
|
84
83
|
"react": "18.2.0",
|
85
|
-
"tslib": "2.5.
|
86
|
-
"webpack": "5.
|
84
|
+
"tslib": "2.5.3",
|
85
|
+
"webpack": "5.86.0"
|
87
86
|
},
|
88
87
|
"volta": {
|
89
88
|
"extends": "../../../package.json"
|
package/src/compiler.service.tsx
CHANGED
@@ -1,30 +1,35 @@
|
|
1
|
-
import {
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
2
|
+
import type {
|
3
|
+
MultiCompiler,
|
4
|
+
MultiStats,
|
5
|
+
StatsCompilation,
|
6
|
+
StatsError,
|
7
|
+
} from '@roots/bud-framework/config'
|
8
|
+
import type {Compiler as Contract} from '@roots/bud-framework/services'
|
9
|
+
import type {
|
10
|
+
ErrorWithSourceFile,
|
11
|
+
SourceFile,
|
12
|
+
} from '@roots/bud-support/open'
|
2
13
|
|
3
14
|
import * as App from '@roots/bud-dashboard/app'
|
4
|
-
import type {Bud} from '@roots/bud-framework/bud'
|
5
15
|
import {Service} from '@roots/bud-framework/service'
|
6
|
-
import type {Compiler as Contract} from '@roots/bud-framework/services'
|
7
16
|
import {bind} from '@roots/bud-support/decorators/bind'
|
8
17
|
import {BudError, CompilerError} from '@roots/bud-support/errors'
|
9
18
|
import {duration} from '@roots/bud-support/human-readable'
|
10
|
-
import
|
11
|
-
ErrorWithSourceFile,
|
12
|
-
SourceFile,
|
13
|
-
} from '@roots/bud-support/open'
|
19
|
+
import * as Ink from '@roots/bud-support/ink'
|
14
20
|
import stripAnsi from '@roots/bud-support/strip-ansi'
|
15
|
-
import
|
16
|
-
import
|
17
|
-
MultiCompiler,
|
18
|
-
MultiStats,
|
19
|
-
StatsCompilation,
|
20
|
-
StatsError,
|
21
|
-
} from '@roots/bud-support/webpack'
|
22
|
-
import * as Ink from 'ink'
|
21
|
+
import {pathToFileURL} from 'node:url'
|
22
|
+
import webpack from 'webpack'
|
23
23
|
|
24
24
|
/**
|
25
25
|
* Wepback compilation controller class
|
26
26
|
*/
|
27
27
|
export class Compiler extends Service implements Contract.Service {
|
28
|
+
/**
|
29
|
+
* Configuration
|
30
|
+
*/
|
31
|
+
public config: Contract.Service[`config`] = []
|
32
|
+
|
28
33
|
/**
|
29
34
|
* Compiler implementation
|
30
35
|
*/
|
@@ -40,11 +45,6 @@ export class Compiler extends Service implements Contract.Service {
|
|
40
45
|
*/
|
41
46
|
public stats: Contract.Service[`stats`]
|
42
47
|
|
43
|
-
/**
|
44
|
-
* Configuration
|
45
|
-
*/
|
46
|
-
public config: Contract.Service[`config`] = []
|
47
|
-
|
48
48
|
/**
|
49
49
|
* Initiates compilation
|
50
50
|
*/
|
@@ -89,6 +89,51 @@ export class Compiler extends Service implements Contract.Service {
|
|
89
89
|
return this.instance
|
90
90
|
}
|
91
91
|
|
92
|
+
/**
|
93
|
+
* Compiler error event
|
94
|
+
*/
|
95
|
+
@bind
|
96
|
+
public async onError(error: Error) {
|
97
|
+
process.exitCode = 1
|
98
|
+
|
99
|
+
await this.app.hooks.fire(`compiler.error`, error)
|
100
|
+
|
101
|
+
this.app.isDevelopment &&
|
102
|
+
this.app.server.appliedMiddleware?.hot?.publish({error})
|
103
|
+
|
104
|
+
try {
|
105
|
+
this.app.notifier.notify({
|
106
|
+
group: this.app.label,
|
107
|
+
message: error.message,
|
108
|
+
subtitle: error.name,
|
109
|
+
})
|
110
|
+
} catch (error) {
|
111
|
+
this.logger.error(error)
|
112
|
+
}
|
113
|
+
|
114
|
+
try {
|
115
|
+
Ink.render(
|
116
|
+
<App.Error
|
117
|
+
error={
|
118
|
+
new CompilerError(error.message, {
|
119
|
+
props: {
|
120
|
+
details: `This error was thrown by the webpack compiler itself. It is not the same as a syntax error. It is likely a missing or unresolvable build dependency.`,
|
121
|
+
docs: new URL(`https://bud.js.org/`),
|
122
|
+
issues: new URL(
|
123
|
+
`https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`,
|
124
|
+
),
|
125
|
+
stack: error.stack,
|
126
|
+
thrownBy: `webpack`,
|
127
|
+
},
|
128
|
+
})
|
129
|
+
}
|
130
|
+
/>,
|
131
|
+
)
|
132
|
+
} catch (error) {
|
133
|
+
throw BudError.normalize(error)
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
92
137
|
/**
|
93
138
|
* Stats handler
|
94
139
|
*/
|
@@ -121,11 +166,11 @@ export class Compiler extends Service implements Contract.Service {
|
|
121
166
|
if (!error) return
|
122
167
|
|
123
168
|
this.app.notifier.notify({
|
124
|
-
|
125
|
-
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
169
|
+
group: `${this.app.label}-${child.name}`,
|
126
170
|
message: stripAnsi(error.message),
|
127
171
|
open: error.file ? pathToFileURL(error.file) : ``,
|
128
|
-
|
172
|
+
subtitle: error.file ? `Error in ${error.name}` : error.name,
|
173
|
+
title: makeNoticeTitle(child),
|
129
174
|
})
|
130
175
|
this.app.notifier.openEditor(error.file)
|
131
176
|
} catch (error) {
|
@@ -139,15 +184,15 @@ export class Compiler extends Service implements Contract.Service {
|
|
139
184
|
.forEach(child => {
|
140
185
|
try {
|
141
186
|
this.app.notifier.notify({
|
142
|
-
|
143
|
-
subtitle: `Build successful`,
|
187
|
+
group: `${this.app.label}-${child.name}`,
|
144
188
|
message: child.modules
|
145
189
|
? `${child.modules.length} modules compiled in ${duration(
|
146
190
|
child.time,
|
147
191
|
)}`
|
148
192
|
: `Compiled in ${duration(child.time)}`,
|
149
|
-
group: `${this.app.label}-${child.name}`,
|
150
193
|
open: this.app.server?.publicUrl.href,
|
194
|
+
subtitle: `Build successful`,
|
195
|
+
title: makeNoticeTitle(child),
|
151
196
|
})
|
152
197
|
this.app.notifier.openBrowser(this.app.server?.publicUrl.href)
|
153
198
|
} catch (error) {
|
@@ -158,51 +203,6 @@ export class Compiler extends Service implements Contract.Service {
|
|
158
203
|
await statsUpdate
|
159
204
|
}
|
160
205
|
|
161
|
-
/**
|
162
|
-
* Compiler error event
|
163
|
-
*/
|
164
|
-
@bind
|
165
|
-
public async onError(error: Error) {
|
166
|
-
process.exitCode = 1
|
167
|
-
|
168
|
-
await this.app.hooks.fire(`compiler.error`, error)
|
169
|
-
|
170
|
-
this.app.isDevelopment &&
|
171
|
-
this.app.server.appliedMiddleware?.hot?.publish({error})
|
172
|
-
|
173
|
-
try {
|
174
|
-
this.app.notifier.notify({
|
175
|
-
subtitle: error.name,
|
176
|
-
message: error.message,
|
177
|
-
group: this.app.label,
|
178
|
-
})
|
179
|
-
} catch (error) {
|
180
|
-
this.logger.error(error)
|
181
|
-
}
|
182
|
-
|
183
|
-
try {
|
184
|
-
Ink.render(
|
185
|
-
<App.Error
|
186
|
-
error={
|
187
|
-
new CompilerError(error.message, {
|
188
|
-
props: {
|
189
|
-
details: `This error was thrown by the webpack compiler itself. It is not the same as a syntax error. It is likely a missing or unresolvable build dependency.`,
|
190
|
-
stack: error.stack,
|
191
|
-
thrownBy: `webpack`,
|
192
|
-
docs: new URL(`https://bud.js.org/`),
|
193
|
-
issues: new URL(
|
194
|
-
`https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`,
|
195
|
-
),
|
196
|
-
},
|
197
|
-
})
|
198
|
-
}
|
199
|
-
/>,
|
200
|
-
)
|
201
|
-
} catch (error) {
|
202
|
-
throw BudError.normalize(error)
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
206
|
/**
|
207
207
|
* Parse errors from webpack stats
|
208
208
|
*/
|
@@ -240,7 +240,7 @@ export class Compiler extends Service implements Contract.Service {
|
|
240
240
|
return error
|
241
241
|
}
|
242
242
|
|
243
|
-
return {...error, name: module.name ?? error.name
|
243
|
+
return {...error, file, name: module.name ?? error.name}
|
244
244
|
}
|
245
245
|
|
246
246
|
return errors?.map(parseError).filter(Boolean)
|