@roots/bud-compiler 5.0.0-next.13 → 5.0.0-next.17
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/README.md +10 -13
- package/lib/cjs/Compiler/index.js +29 -13
- package/lib/cjs/Compiler/index.js.map +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/esm/Compiler/index.js +28 -12
- package/lib/esm/Compiler/index.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/tsconfig-esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -5
- package/types/Compiler/index.d.ts +1 -1
- package/types/Compiler/index.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
package/README.md
CHANGED
@@ -7,14 +7,17 @@
|
|
7
7
|
alt="MIT License"
|
8
8
|
src="https://img.shields.io/github/license/roots/bud?color=%23525ddc&style=flat-square"
|
9
9
|
/>
|
10
|
-
<a
|
11
|
-
|
10
|
+
<a
|
11
|
+
href="https://app.fossa.com/projects/git%2Bgithub.com%2Froots%2Fbud?ref=badge_small"
|
12
|
+
alt="FOSSA Status"
|
13
|
+
>
|
14
|
+
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Froots%2Fbud.svg?type=small" />
|
12
15
|
</a>
|
13
16
|
<a href="https://www.npmjs.com/package/@roots/bud">
|
14
17
|
<img src="https://img.shields.io/npm/v/@roots/bud.svg?color=%23525ddc&style=flat-square" />
|
15
18
|
</a>
|
16
19
|
<a href="https://codecov.io/gh/roots/bud">
|
17
|
-
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD"/>
|
20
|
+
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD" />
|
18
21
|
</a>
|
19
22
|
<a href="https://twitter.com/rootswp">
|
20
23
|
<img
|
@@ -24,18 +27,18 @@
|
|
24
27
|
</a>
|
25
28
|
</p>
|
26
29
|
|
27
|
-
|
28
30
|
<h1 align="center">
|
29
31
|
<strong>@roots/bud-compiler</strong>
|
30
32
|
</h1>
|
31
33
|
|
32
|
-
|
34
|
+
Compilation handler
|
35
|
+
|
33
36
|
## Installation
|
34
37
|
|
35
38
|
Install **@roots/bud-compiler** to your project.
|
36
39
|
|
37
40
|
```shell
|
38
|
-
yarn add @roots/bud-compiler
|
41
|
+
yarn add @roots/bud-compiler --dev
|
39
42
|
```
|
40
43
|
|
41
44
|
## Documentation
|
@@ -55,20 +58,14 @@ Keep track of development and community news.
|
|
55
58
|
## Contributing
|
56
59
|
|
57
60
|
Contributions are welcome from everyone.
|
58
|
-
|
59
61
|
We have [contribution guidelines](https://github.com/roots/guidelines/blob/master/CONTRIBUTING.md) to help you get started.
|
60
62
|
|
61
63
|
## Sponsors
|
62
64
|
|
63
65
|
Help support our open-source development efforts by [becoming a patron](https://www.patreon.com/rootsdev).
|
64
|
-
|
65
66
|
<a href="https://kinsta.com/?kaid=OFDHAJIXUDIV"><img src="https://cdn.roots.io/app/uploads/kinsta.svg" alt="Kinsta" width="200" height="150"/></a>
|
66
67
|
<a href="https://k-m.com/"><img src="https://cdn.roots.io/app/uploads/km-digital.svg" alt="KM Digital" width="200" height="150"/></a>
|
67
68
|
<a href="https://carrot.com/"><img src="https://cdn.roots.io/app/uploads/carrot.svg" alt="Carrot" width="200" height="150"/></a>
|
68
69
|
<a href="https://www.c21redwood.com/"><img src="https://cdn.roots.io/app/uploads/c21redwood.svg" alt="C21 Redwood Realty" width="200" height="150"/></a>
|
69
70
|
<a href="https://wordpress.com/"><img src="https://cdn.roots.io/app/uploads/wordpress.svg" alt="WordPress.com" width="200" height="150"/></a>
|
70
|
-
<a href="https://
|
71
|
-
<a href="https://www.harnessup.com/"><img src="https://cdn.roots.io/app/uploads/harness-software.svg" alt="Harness Software" width="200" height="150"/></a>
|
72
|
-
<a href="https://www.codersclan.com/"><img src="https://cdn.roots.io/app/uploads/coders-clan.svg" alt="Coders Clan" width="200" height="150"/></a>
|
73
|
-
<a href="https://generodigital.com/"><img src="https://cdn.roots.io/app/uploads/genero.svg" alt="Genero" width="200" height="150"/></a>
|
74
|
-
<a href="https://motto.ca/roots"><img src="https://cdn.roots.io/app/uploads/motto.svg" alt="Motto" width="200" height="150"/></a>
|
71
|
+
<a href="https://pantheon.io/"><img src="https://cdn.roots.io/app/uploads/pantheon.svg" alt="Pantheon" width="200" height="150"/></a>
|
@@ -6,7 +6,6 @@ const bud_framework_1 = require("@roots/bud-framework");
|
|
6
6
|
const bud_support_1 = require("@roots/bud-support");
|
7
7
|
const webpack_1 = require("webpack");
|
8
8
|
const { isFunction } = bud_support_1.lodash;
|
9
|
-
const helpful_decorators_1 = require("helpful-decorators");
|
10
9
|
/**
|
11
10
|
* Initial state
|
12
11
|
*
|
@@ -43,13 +42,16 @@ class Compiler extends bud_framework_1.Service {
|
|
43
42
|
this.config = [];
|
44
43
|
}
|
45
44
|
/**
|
46
|
-
*
|
45
|
+
* Service register event
|
47
46
|
*
|
48
47
|
* @public
|
49
48
|
* @decorator `@bind`
|
50
49
|
*/
|
51
50
|
register() {
|
52
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
51
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
52
|
+
this.app.hooks.filter('event.compiler.register.before', this.app);
|
53
|
+
this.app.hooks.filter('event.compiler.register.after', this.app);
|
54
|
+
});
|
53
55
|
}
|
54
56
|
/**
|
55
57
|
* Initiates compilation
|
@@ -73,18 +75,31 @@ class Compiler extends bud_framework_1.Service {
|
|
73
75
|
*/
|
74
76
|
invoke(config) {
|
75
77
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
76
|
-
yield this.app.hooks.promised('event.compiler.
|
78
|
+
config = yield this.app.hooks.promised('event.compiler.before', config);
|
79
|
+
config = this.app.hooks.filter('config.override', config);
|
77
80
|
this.instance = (0, webpack_1.webpack)(config);
|
78
81
|
this.instance.hooks.done.tap(config[0].name, (stats) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
79
|
-
this.app.hooks.filter('event.compiler.done', stats);
|
82
|
+
yield this.app.hooks.filter('event.compiler.done', stats);
|
80
83
|
stats && Object.assign(this.stats, stats.toJson());
|
84
|
+
if (this.app.store.is('features.dashboard', false)) {
|
85
|
+
this.log('log', stats.toString({
|
86
|
+
colors: true,
|
87
|
+
modules: false,
|
88
|
+
children: false,
|
89
|
+
chunks: false,
|
90
|
+
chunkModules: false,
|
91
|
+
entrypoints: false,
|
92
|
+
performance: false,
|
93
|
+
}));
|
94
|
+
}
|
81
95
|
if (this.app.isProduction) {
|
82
96
|
this.instance.close(err => {
|
83
97
|
if (err) {
|
98
|
+
err = this.app.hooks.filter('compiler.error', err);
|
84
99
|
this.stats.errors.push(err);
|
85
100
|
this.log('error', err);
|
86
101
|
}
|
87
|
-
this.app.close(
|
102
|
+
!this.app.dashboard.instance && this.app.close();
|
88
103
|
});
|
89
104
|
}
|
90
105
|
}));
|
@@ -102,6 +117,7 @@ class Compiler extends bud_framework_1.Service {
|
|
102
117
|
* @decorator `@bind`
|
103
118
|
*/
|
104
119
|
before() {
|
120
|
+
var _a;
|
105
121
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
106
122
|
const config = [];
|
107
123
|
this.stats = INITIAL_STATS;
|
@@ -113,7 +129,7 @@ class Compiler extends bud_framework_1.Service {
|
|
113
129
|
* Attempt to use the parent instance in the compilation if there are entries
|
114
130
|
* registered to it or if it has no child instances registered.
|
115
131
|
*/
|
116
|
-
if (this.app.
|
132
|
+
if (!this.app.hasChildren) {
|
117
133
|
this.app.info(`using config from parent compiler`);
|
118
134
|
config.push(this.app.build.config);
|
119
135
|
return config;
|
@@ -125,7 +141,7 @@ class Compiler extends bud_framework_1.Service {
|
|
125
141
|
* If there are {@link Framework.children} instances, iterate through
|
126
142
|
* them and add to `config`
|
127
143
|
*/
|
128
|
-
yield Promise.all(this.app.children.getValues().map((instance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
144
|
+
yield Promise.all((_a = this.app.children) === null || _a === void 0 ? void 0 : _a.getValues().map((instance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
129
145
|
if (!instance.name)
|
130
146
|
return;
|
131
147
|
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
@@ -150,13 +166,13 @@ class Compiler extends bud_framework_1.Service {
|
|
150
166
|
* here we parse the callback args so that we dont have to
|
151
167
|
* duplicate the callback.
|
152
168
|
*/
|
153
|
-
|
169
|
+
let [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
154
170
|
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
155
171
|
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
156
|
-
this.app.
|
157
|
-
this.app.log(stats.toString());
|
172
|
+
this.stats = this.app.hooks.filter('compiler.stats', this.stats);
|
158
173
|
}
|
159
174
|
if (err) {
|
175
|
+
err = this.app.hooks.filter('compiler.error', err);
|
160
176
|
this.stats.errors.push(err);
|
161
177
|
this.app.store.is('features.dashboard', false) &&
|
162
178
|
this.log('error', err);
|
@@ -168,14 +184,14 @@ class Compiler extends bud_framework_1.Service {
|
|
168
184
|
], Compiler.prototype, "register", null);
|
169
185
|
(0, tslib_1.__decorate)([
|
170
186
|
bud_support_1.bind,
|
171
|
-
|
187
|
+
bud_support_1.once
|
172
188
|
], Compiler.prototype, "compile", null);
|
173
189
|
(0, tslib_1.__decorate)([
|
174
190
|
bud_support_1.bind
|
175
191
|
], Compiler.prototype, "invoke", null);
|
176
192
|
(0, tslib_1.__decorate)([
|
177
193
|
bud_support_1.bind,
|
178
|
-
|
194
|
+
bud_support_1.once
|
179
195
|
], Compiler.prototype, "before", null);
|
180
196
|
(0, tslib_1.__decorate)([
|
181
197
|
bud_support_1.bind
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index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E,KAAK,CAAC;gBAC5C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;SACzB;IACH,CAAC;CACF;AAtLC;IADC,kBAAI;wCAWJ;AAYD;IAFC,kBAAI;IACJ,kBAAI;uCAOJ;AAOD;IADC,kBAAI;sCAmDJ;AAUD;IAFC,kBAAI;IACJ,kBAAI;sCAiDJ;AASD;IADC,kBAAI;wCA8BJ;AA9NH,4BA+NC"}
|
package/lib/cjs/index.js
CHANGED
@@ -10,7 +10,7 @@ exports.Compiler = void 0;
|
|
10
10
|
* @see https://roots.io/bud
|
11
11
|
* @see https://github.com/roots/bud
|
12
12
|
*
|
13
|
-
* @core @packageDocumentation
|
13
|
+
* @core @packageDocumentation
|
14
14
|
*/
|
15
15
|
var Compiler_1 = require("./Compiler");
|
16
16
|
Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return Compiler_1.Compiler; } });
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
2
2
|
import { Service, } from '@roots/bud-framework';
|
3
|
-
import { bind, lodash } from '@roots/bud-support';
|
3
|
+
import { bind, lodash, once } from '@roots/bud-support';
|
4
4
|
import { ProgressPlugin, webpack } from 'webpack';
|
5
5
|
const { isFunction } = lodash;
|
6
|
-
import { once } from 'helpful-decorators';
|
7
6
|
/**
|
8
7
|
* Initial state
|
9
8
|
*
|
@@ -40,13 +39,16 @@ export class Compiler extends Service {
|
|
40
39
|
this.config = [];
|
41
40
|
}
|
42
41
|
/**
|
43
|
-
*
|
42
|
+
* Service register event
|
44
43
|
*
|
45
44
|
* @public
|
46
45
|
* @decorator `@bind`
|
47
46
|
*/
|
48
47
|
register() {
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
49
|
+
this.app.hooks.filter('event.compiler.register.before', this.app);
|
50
|
+
this.app.hooks.filter('event.compiler.register.after', this.app);
|
51
|
+
});
|
50
52
|
}
|
51
53
|
/**
|
52
54
|
* Initiates compilation
|
@@ -70,18 +72,31 @@ export class Compiler extends Service {
|
|
70
72
|
*/
|
71
73
|
invoke(config) {
|
72
74
|
return __awaiter(this, void 0, void 0, function* () {
|
73
|
-
yield this.app.hooks.promised('event.compiler.
|
75
|
+
config = yield this.app.hooks.promised('event.compiler.before', config);
|
76
|
+
config = this.app.hooks.filter('config.override', config);
|
74
77
|
this.instance = webpack(config);
|
75
78
|
this.instance.hooks.done.tap(config[0].name, (stats) => __awaiter(this, void 0, void 0, function* () {
|
76
|
-
this.app.hooks.filter('event.compiler.done', stats);
|
79
|
+
yield this.app.hooks.filter('event.compiler.done', stats);
|
77
80
|
stats && Object.assign(this.stats, stats.toJson());
|
81
|
+
if (this.app.store.is('features.dashboard', false)) {
|
82
|
+
this.log('log', stats.toString({
|
83
|
+
colors: true,
|
84
|
+
modules: false,
|
85
|
+
children: false,
|
86
|
+
chunks: false,
|
87
|
+
chunkModules: false,
|
88
|
+
entrypoints: false,
|
89
|
+
performance: false,
|
90
|
+
}));
|
91
|
+
}
|
78
92
|
if (this.app.isProduction) {
|
79
93
|
this.instance.close(err => {
|
80
94
|
if (err) {
|
95
|
+
err = this.app.hooks.filter('compiler.error', err);
|
81
96
|
this.stats.errors.push(err);
|
82
97
|
this.log('error', err);
|
83
98
|
}
|
84
|
-
this.app.close(
|
99
|
+
!this.app.dashboard.instance && this.app.close();
|
85
100
|
});
|
86
101
|
}
|
87
102
|
}));
|
@@ -99,6 +114,7 @@ export class Compiler extends Service {
|
|
99
114
|
* @decorator `@bind`
|
100
115
|
*/
|
101
116
|
before() {
|
117
|
+
var _a;
|
102
118
|
return __awaiter(this, void 0, void 0, function* () {
|
103
119
|
const config = [];
|
104
120
|
this.stats = INITIAL_STATS;
|
@@ -110,7 +126,7 @@ export class Compiler extends Service {
|
|
110
126
|
* Attempt to use the parent instance in the compilation if there are entries
|
111
127
|
* registered to it or if it has no child instances registered.
|
112
128
|
*/
|
113
|
-
if (this.app.
|
129
|
+
if (!this.app.hasChildren) {
|
114
130
|
this.app.info(`using config from parent compiler`);
|
115
131
|
config.push(this.app.build.config);
|
116
132
|
return config;
|
@@ -122,7 +138,7 @@ export class Compiler extends Service {
|
|
122
138
|
* If there are {@link Framework.children} instances, iterate through
|
123
139
|
* them and add to `config`
|
124
140
|
*/
|
125
|
-
yield Promise.all(this.app.children.getValues().map((instance) => __awaiter(this, void 0, void 0, function* () {
|
141
|
+
yield Promise.all((_a = this.app.children) === null || _a === void 0 ? void 0 : _a.getValues().map((instance) => __awaiter(this, void 0, void 0, function* () {
|
126
142
|
if (!instance.name)
|
127
143
|
return;
|
128
144
|
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
@@ -147,13 +163,13 @@ export class Compiler extends Service {
|
|
147
163
|
* here we parse the callback args so that we dont have to
|
148
164
|
* duplicate the callback.
|
149
165
|
*/
|
150
|
-
|
166
|
+
let [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
151
167
|
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
152
168
|
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
153
|
-
this.app.
|
154
|
-
this.app.log(stats.toString());
|
169
|
+
this.stats = this.app.hooks.filter('compiler.stats', this.stats);
|
155
170
|
}
|
156
171
|
if (err) {
|
172
|
+
err = this.app.hooks.filter('compiler.error', err);
|
157
173
|
this.stats.errors.push(err);
|
158
174
|
this.app.store.is('features.dashboard', false) &&
|
159
175
|
this.log('error', err);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,OAAO,GACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAA;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"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