@roots/bud-compiler 6.11.0 → 6.12.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.
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.service.d.ts","sourceRoot":"","sources":["../src/compiler.service.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACpD,OAAO,KAAK,EAAC,QAAQ,IAAI,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAGvE,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAA;AACrD,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAEV,UAAU,EACX,MAAM,4BAA4B,CAAA;AAEnC;;GAEG;AACH,qBAAa,QAAS,SAAQ,OAAQ,YAAW,QAAQ,CAAC,OAAO;IAC/D;;OAEG;IACI,cAAc,EAAE,OAAO,OAAO,CAAA;IAErC;;OAEG;IACI,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAE7C;;OAEG;IACI,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvC;;OAEG;IACI,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAK;IAE9C;;OAEG;IAEU,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAsC9C;;OAEG;IAEU,OAAO,CAAC,KAAK,EAAE,UAAU;IAwDtC;;OAEG;IAEU,OAAO,CAAC,KAAK,EAAE,KAAK;IAuBjC;;OAEG;IAEI,YAAY,CACjB,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,GACxB,KAAK,CAAC,mBAAmB,GAAG,UAAU,CAAC;CAwC3C"}
1
+ {"version":3,"file":"compiler.service.d.ts","sourceRoot":"","sources":["../src/compiler.service.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACpD,OAAO,KAAK,EAAC,QAAQ,IAAI,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAIvE,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAA;AACrD,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAEV,UAAU,EACX,MAAM,4BAA4B,CAAA;AAGnC;;GAEG;AACH,qBAAa,QAAS,SAAQ,OAAQ,YAAW,QAAQ,CAAC,OAAO;IAC/D;;OAEG;IACI,cAAc,EAAE,OAAO,OAAO,CAAA;IAErC;;OAEG;IACI,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAE7C;;OAEG;IACI,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvC;;OAEG;IACI,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAK;IAE9C;;OAEG;IAEU,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAyC9C;;OAEG;IAEU,OAAO,CAAC,KAAK,EAAE,UAAU;IAiEtC;;OAEG;IAEU,OAAO,CAAC,KAAK,EAAE,KAAK;IAyCjC;;OAEG;IAEI,YAAY,CACjB,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,GACxB,KAAK,CAAC,mBAAmB,GAAG,UAAU,CAAC;CAwC3C"}
@@ -1,11 +1,13 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { pathToFileURL } from 'node:url';
3
4
  import * as App from '@roots/bud-dashboard/app';
4
5
  import { Service } from '@roots/bud-framework/service';
5
6
  import { bind } from '@roots/bud-support/decorators';
7
+ import { BudError, CompilerError } from '@roots/bud-support/errors';
6
8
  import { duration } from '@roots/bud-support/human-readable';
7
- import React from '@roots/bud-support/react';
8
9
  import stripAnsi from '@roots/bud-support/strip-ansi';
10
+ import * as Ink from 'ink';
9
11
  /**
10
12
  * Wepback compilation controller class
11
13
  */
@@ -21,7 +23,7 @@ export class Compiler extends Service {
21
23
  * Initiates compilation
22
24
  */
23
25
  async compile() {
24
- this.implementation = await this.app.module.import(`webpack`);
26
+ this.implementation = await this.app.module.import(`webpack`, import.meta.url);
25
27
  this.logger.log(`imported webpack`, this.implementation.version);
26
28
  this.config = !this.app.hasChildren
27
29
  ? [await this.app.build.make()]
@@ -35,11 +37,12 @@ export class Compiler extends Service {
35
37
  }));
36
38
  await this.app.hooks.fire(`compiler.before`, this.app);
37
39
  if (this.app.isCLI() && this.app.context.args.dry) {
38
- this.app.context.logger.timeEnd(`initialize`);
40
+ this.logger.timeEnd(`initialize`);
39
41
  this.logger.log(`running in dry mode. exiting early.`);
40
42
  return;
41
43
  }
42
- this.app.context.logger.timeEnd(`initialize`);
44
+ this.logger.timeEnd(`initialize`);
45
+ this.logger.await(`compilation`);
43
46
  this.instance = this.implementation(this.config);
44
47
  this.instance.hooks.done.tap(this.app.label, async (stats) => {
45
48
  await this.onStats(stats);
@@ -67,32 +70,42 @@ export class Compiler extends Service {
67
70
  this.stats.children
68
71
  ?.filter(child => child.errorsCount > 0)
69
72
  .forEach(child => {
70
- const error = child.errors?.shift();
71
- if (!error)
72
- return;
73
- this.app.notifier.notify({
74
- title: makeNoticeTitle(child),
75
- subtitle: error.file ? `Error in ${error.name}` : error.name,
76
- message: stripAnsi(error.message),
77
- open: error.file ? pathToFileURL(error.file) : ``,
78
- group: `${this.app.label}-${child.name}`,
79
- });
80
- this.app.notifier.openEditor(error.file);
73
+ try {
74
+ const error = child.errors?.shift();
75
+ if (!error)
76
+ return;
77
+ this.app.notifier.notify({
78
+ title: makeNoticeTitle(child),
79
+ subtitle: error.file ? `Error in ${error.name}` : error.name,
80
+ message: stripAnsi(error.message),
81
+ open: error.file ? pathToFileURL(error.file) : ``,
82
+ group: `${this.app.label}-${child.name}`,
83
+ });
84
+ this.app.notifier.openEditor(error.file);
85
+ }
86
+ catch (error) {
87
+ this.logger.error(error);
88
+ }
81
89
  });
82
90
  }
83
91
  this.stats.children
84
92
  ?.filter(child => child.errorsCount === 0)
85
93
  .forEach(child => {
86
- this.app.notifier.notify({
87
- title: makeNoticeTitle(child),
88
- subtitle: `Build successful`,
89
- message: child.modules
90
- ? `${child.modules.length} modules compiled in ${duration(child.time)}`
91
- : `Compiled in ${duration(child.time)}`,
92
- group: `${this.app.label}-${child.name}`,
93
- open: this.app.server?.publicUrl.href,
94
- });
95
- this.app.notifier.openBrowser(this.app.server?.publicUrl.href);
94
+ try {
95
+ this.app.notifier.notify({
96
+ title: makeNoticeTitle(child),
97
+ subtitle: `Build successful`,
98
+ message: child.modules
99
+ ? `${child.modules.length} modules compiled in ${duration(child.time)}`
100
+ : `Compiled in ${duration(child.time)}`,
101
+ group: `${this.app.label}-${child.name}`,
102
+ open: this.app.server?.publicUrl.href,
103
+ });
104
+ this.app.notifier.openBrowser(this.app.server?.publicUrl.href);
105
+ }
106
+ catch (error) {
107
+ this.logger.error(error);
108
+ }
96
109
  });
97
110
  await statsUpdate;
98
111
  }
@@ -104,12 +117,30 @@ export class Compiler extends Service {
104
117
  await this.app.hooks.fire(`compiler.error`, error);
105
118
  this.app.isDevelopment &&
106
119
  this.app.server.appliedMiddleware?.hot?.publish({ error });
107
- this.app.notifier.notify({
108
- subtitle: error.name,
109
- message: error.message,
110
- group: this.app.label,
111
- });
112
- await this.app.dashboard.renderer.once(React.createElement(App.Error, { name: "Compiler error", message: error.message, stack: error.stack }));
120
+ try {
121
+ this.app.notifier.notify({
122
+ subtitle: error.name,
123
+ message: error.message,
124
+ group: this.app.label,
125
+ });
126
+ }
127
+ catch (error) {
128
+ this.logger.error(error);
129
+ }
130
+ try {
131
+ Ink.render(_jsx(App.Error, { error: new CompilerError(error.message, {
132
+ props: {
133
+ 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.`,
134
+ stack: error.stack,
135
+ thrownBy: `webpack`,
136
+ docs: new URL(`https://bud.js.org/`),
137
+ issues: new URL(`https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`),
138
+ },
139
+ }) }));
140
+ }
141
+ catch (error) {
142
+ throw BudError.normalize(error);
143
+ }
113
144
  }
114
145
  /**
115
146
  * Parse errors from webpack stats
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.service.js","sourceRoot":"","sources":["../src/compiler.service.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAA;AAE/C,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AAEpD,OAAO,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAA;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAK1D,OAAO,KAAK,MAAM,0BAA0B,CAAA;AAC5C,OAAO,SAAS,MAAM,+BAA+B,CAAA;AASrD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO;IAArC;;QAgBE;;WAEG;QACI,WAAM,GAA+B,EAAE,CAAA;IAiLhD,CAAC;IA/KC;;OAEG;IAEU,AAAN,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC,cAAc,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAEhE,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW;YACjC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC/B,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GA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,OAAO,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;SAC/C;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;YAC5C,OAAO,EAAE,CAAA;SACV;IACH,CAAC;CACF;AAzMc;IADZ,IAAI;;;;uCAwCJ;AAMY;IADZ,IAAI;;;;uCAgEJ;AAMY;IADZ,IAAI;;qCACuB,KAAK;;uCAuChC;AAKD;IAAC,IAAI;;qCAEK,KAAK;oCACZ,KAAK;4CAuCP"}
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
+ import './types.js';
9
10
  import { Compiler } from './compiler.service.js';
10
11
  export default Compiler;
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,YAAY,CAAA;AAEnB,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,eAAe,QAAQ,CAAA"}
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@
8
8
  *
9
9
  * @packageDocumentation
10
10
  */
11
+ import './types.js';
11
12
  import { Compiler } from './compiler.service.js';
12
13
  export default Compiler;
13
14
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,kCAAkC;AAElC;;;;;;;GAOG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,kCAAkC;AAElC;;;;;;;GAOG;AAEH,OAAO,YAAY,CAAA;AAEnB,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,eAAe,QAAQ,CAAA"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * @package @roots/bud-compiler
4
+ */
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
package/lib/types.js ADDED
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * @package @roots/bud-compiler
4
+ */
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@roots/bud-compiler",
3
+ "version": "6.12.0",
3
4
  "description": "Compilation handler",
4
- "version": "6.11.0",
5
- "homepage": "https://roots.io/bud",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/roots/bud.git",
9
- "directory": "sources/@roots/bud-compiler"
5
+ "engines": {
6
+ "node": ">=16"
10
7
  },
11
8
  "contributors": [
12
9
  {
@@ -25,47 +22,63 @@
25
22
  }
26
23
  ],
27
24
  "license": "MIT",
28
- "bugs": {
29
- "url": "https://github.com/roots/bud/issues"
30
- },
25
+ "homepage": "https://roots.io/bud",
31
26
  "funding": {
32
27
  "type": "github sponsors",
33
28
  "url": "https://github.com/sponsors/roots"
34
29
  },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/roots/bud.git",
33
+ "directory": "sources/@roots/bud-compiler"
34
+ },
35
+ "bugs": "https://github.com/roots/bud/issues",
35
36
  "keywords": [
36
37
  "bud",
37
38
  "bud-framework"
38
39
  ],
39
- "engines": {
40
- "node": ">=16"
41
- },
42
40
  "files": [
43
41
  "docs",
44
42
  "lib",
45
43
  "src"
46
44
  ],
47
45
  "type": "module",
48
- "module": "./lib/index.js",
49
- "types": "./lib/index.d.ts",
50
46
  "exports": {
51
- ".": "./lib/index.js"
47
+ ".": {
48
+ "import": "./lib/index.js",
49
+ "default": "./lib/index.js"
50
+ },
51
+ "./types": {
52
+ "import": "./lib/types.js",
53
+ "default": "./lib/types.js"
54
+ }
52
55
  },
53
56
  "typesVersions": {
54
57
  "*": {
55
58
  ".": [
56
59
  "./lib/index.d.ts"
60
+ ],
61
+ "types": [
62
+ "./lib/types.d.ts"
57
63
  ]
58
64
  }
59
65
  },
66
+ "types": "./lib/index.d.ts",
67
+ "module": "./lib/index.js",
60
68
  "devDependencies": {
61
- "@roots/bud-api": "6.11.0",
69
+ "@roots/bud-api": "6.12.0",
62
70
  "@skypack/package-check": "0.2.2",
63
- "@types/node": "18.11.18"
71
+ "@types/node": "18.15.10",
72
+ "@types/react": "18.0.30"
64
73
  },
65
74
  "dependencies": {
66
- "@roots/bud-dashboard": "6.11.0",
67
- "@roots/bud-framework": "6.11.0",
68
- "@roots/bud-support": "6.11.0"
75
+ "@roots/bud-dashboard": "6.12.0",
76
+ "@roots/bud-framework": "6.12.0",
77
+ "@roots/bud-support": "6.12.0",
78
+ "ink": "4.1.0",
79
+ "react": "18.2.0",
80
+ "tslib": "2.5.0",
81
+ "webpack": "5.76.3"
69
82
  },
70
83
  "volta": {
71
84
  "extends": "../../../package.json"
@@ -5,12 +5,12 @@ import type {Bud} from '@roots/bud-framework/bud'
5
5
  import {Service} from '@roots/bud-framework/service'
6
6
  import type {Compiler as Contract} from '@roots/bud-framework/services'
7
7
  import {bind} from '@roots/bud-support/decorators'
8
+ import {BudError, CompilerError} from '@roots/bud-support/errors'
8
9
  import {duration} from '@roots/bud-support/human-readable'
9
10
  import type {
10
11
  ErrorWithSourceFile,
11
12
  SourceFile,
12
13
  } from '@roots/bud-support/open'
13
- import React from '@roots/bud-support/react'
14
14
  import stripAnsi from '@roots/bud-support/strip-ansi'
15
15
  import type webpack from '@roots/bud-support/webpack'
16
16
  import type {
@@ -19,6 +19,7 @@ import type {
19
19
  StatsCompilation,
20
20
  StatsError,
21
21
  } from '@roots/bud-support/webpack'
22
+ import * as Ink from 'ink'
22
23
 
23
24
  /**
24
25
  * Wepback compilation controller class
@@ -49,7 +50,10 @@ export class Compiler extends Service implements Contract.Service {
49
50
  */
50
51
  @bind
51
52
  public async compile(): Promise<MultiCompiler> {
52
- this.implementation = await this.app.module.import(`webpack`)
53
+ this.implementation = await this.app.module.import(
54
+ `webpack`,
55
+ import.meta.url,
56
+ )
53
57
  this.logger.log(`imported webpack`, this.implementation.version)
54
58
 
55
59
  this.config = !this.app.hasChildren
@@ -67,15 +71,15 @@ export class Compiler extends Service implements Contract.Service {
67
71
  await this.app.hooks.fire(`compiler.before`, this.app)
68
72
 
69
73
  if (this.app.isCLI() && this.app.context.args.dry) {
70
- this.app.context.logger.timeEnd(`initialize`)
74
+ this.logger.timeEnd(`initialize`)
71
75
  this.logger.log(`running in dry mode. exiting early.`)
72
76
  return
73
77
  }
74
78
 
75
- this.app.context.logger.timeEnd(`initialize`)
79
+ this.logger.timeEnd(`initialize`)
80
+ this.logger.await(`compilation`)
76
81
 
77
82
  this.instance = this.implementation(this.config)
78
-
79
83
  this.instance.hooks.done.tap(this.app.label, async (stats: any) => {
80
84
  await this.onStats(stats)
81
85
  await this.app.hooks.fire(`compiler.close`, this.app)
@@ -113,34 +117,43 @@ export class Compiler extends Service implements Contract.Service {
113
117
  this.stats.children
114
118
  ?.filter(child => child.errorsCount > 0)
115
119
  .forEach(child => {
116
- const error = child.errors?.shift()
117
- if (!error) return
118
- this.app.notifier.notify({
119
- title: makeNoticeTitle(child),
120
- subtitle: error.file ? `Error in ${error.name}` : error.name,
121
- message: stripAnsi(error.message),
122
- open: error.file ? pathToFileURL(error.file) : ``,
123
- group: `${this.app.label}-${child.name}`,
124
- })
125
- this.app.notifier.openEditor(error.file)
120
+ try {
121
+ const error = child.errors?.shift()
122
+ if (!error) return
123
+
124
+ this.app.notifier.notify({
125
+ title: makeNoticeTitle(child),
126
+ subtitle: error.file ? `Error in ${error.name}` : error.name,
127
+ message: stripAnsi(error.message),
128
+ open: error.file ? pathToFileURL(error.file) : ``,
129
+ group: `${this.app.label}-${child.name}`,
130
+ })
131
+ this.app.notifier.openEditor(error.file)
132
+ } catch (error) {
133
+ this.logger.error(error)
134
+ }
126
135
  })
127
136
  }
128
137
 
129
138
  this.stats.children
130
139
  ?.filter(child => child.errorsCount === 0)
131
140
  .forEach(child => {
132
- this.app.notifier.notify({
133
- title: makeNoticeTitle(child),
134
- subtitle: `Build successful`,
135
- message: child.modules
136
- ? `${child.modules.length} modules compiled in ${duration(
137
- child.time,
138
- )}`
139
- : `Compiled in ${duration(child.time)}`,
140
- group: `${this.app.label}-${child.name}`,
141
- open: this.app.server?.publicUrl.href,
142
- })
143
- this.app.notifier.openBrowser(this.app.server?.publicUrl.href)
141
+ try {
142
+ this.app.notifier.notify({
143
+ title: makeNoticeTitle(child),
144
+ subtitle: `Build successful`,
145
+ message: child.modules
146
+ ? `${child.modules.length} modules compiled in ${duration(
147
+ child.time,
148
+ )}`
149
+ : `Compiled in ${duration(child.time)}`,
150
+ group: `${this.app.label}-${child.name}`,
151
+ open: this.app.server?.publicUrl.href,
152
+ })
153
+ this.app.notifier.openBrowser(this.app.server?.publicUrl.href)
154
+ } catch (error) {
155
+ this.logger.error(error)
156
+ }
144
157
  })
145
158
 
146
159
  await statsUpdate
@@ -158,19 +171,37 @@ export class Compiler extends Service implements Contract.Service {
158
171
  this.app.isDevelopment &&
159
172
  this.app.server.appliedMiddleware?.hot?.publish({error})
160
173
 
161
- this.app.notifier.notify({
162
- subtitle: error.name,
163
- message: error.message,
164
- group: this.app.label,
165
- })
174
+ try {
175
+ this.app.notifier.notify({
176
+ subtitle: error.name,
177
+ message: error.message,
178
+ group: this.app.label,
179
+ })
180
+ } catch (error) {
181
+ this.logger.error(error)
182
+ }
166
183
 
167
- await this.app.dashboard.renderer.once(
168
- <App.Error
169
- name="Compiler error"
170
- message={error.message}
171
- stack={error.stack}
172
- />,
173
- )
184
+ try {
185
+ Ink.render(
186
+ <App.Error
187
+ error={
188
+ new CompilerError(error.message, {
189
+ props: {
190
+ 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.`,
191
+ stack: error.stack,
192
+ thrownBy: `webpack`,
193
+ docs: new URL(`https://bud.js.org/`),
194
+ issues: new URL(
195
+ `https://github.com/roots/bud/search?q=is:issue+"compiler" in:title`,
196
+ ),
197
+ },
198
+ })
199
+ }
200
+ />,
201
+ )
202
+ } catch (error) {
203
+ throw BudError.normalize(error)
204
+ }
174
205
  }
175
206
 
176
207
  /**
@@ -48,7 +48,7 @@ describe(`@roots/bud-compiler`, function () {
48
48
  bud.context.args.dry = true
49
49
  const logSpy = vi.spyOn(compiler.logger, `log`)
50
50
  await compiler.compile()
51
- expect(logSpy).toHaveBeenCalledTimes(2)
51
+ expect(logSpy).toHaveBeenCalledTimes(3)
52
52
  })
53
53
 
54
54
  it(`should set done tap`, async () => {
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  * @packageDocumentation
11
11
  */
12
12
 
13
+ import './types.js'
14
+
13
15
  import {Compiler} from './compiler.service.js'
14
16
 
15
17
  export default Compiler
package/src/types.ts ADDED
@@ -0,0 +1,3 @@
1
+ /**
2
+ * @package @roots/bud-compiler
3
+ */