@roots/bud-compiler 5.0.0-next.9 → 5.3.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.
- package/README.md +8 -28
- package/lib/cjs/Compiler/compiler.service.js +180 -0
- package/lib/cjs/Compiler/process/index.js +26 -0
- package/lib/cjs/Compiler/process/logger.js +7 -0
- package/lib/cjs/Compiler/process/stats.js +110 -0
- package/lib/cjs/index.js +3 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -27
- package/types/Compiler/{index.d.ts → compiler.service.d.ts} +11 -18
- package/types/Compiler/compiler.service.d.ts.map +1 -0
- package/types/Compiler/process/index.d.ts +4 -0
- package/types/Compiler/process/index.d.ts.map +1 -0
- package/types/Compiler/process/logger.d.ts +2 -0
- package/types/Compiler/process/logger.d.ts.map +1 -0
- package/types/Compiler/process/stats.d.ts +4 -0
- package/types/Compiler/process/stats.d.ts.map +1 -0
- package/types/index.d.ts +2 -2
- package/types/index.d.ts.map +1 -1
- package/lib/cjs/Compiler/index.js +0 -190
- package/lib/cjs/Compiler/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/esm/Compiler/index.js +0 -186
- package/lib/esm/Compiler/index.js.map +0 -1
- package/lib/esm/index.js +0 -13
- package/lib/esm/index.js.map +0 -1
- package/lib/tsconfig-esm.tsbuildinfo +0 -1
- package/types/Compiler/index.d.ts.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Compiler/process/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAChC,OAAO,EAAC,KAAK,EAAC,CAAA;AAEd,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/Compiler/process/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,6DAEQ,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/Compiler/process/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAE9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAA;AAmBxC,wBAAgB,KAAK,CACnB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAC1D,IAAI,CAmGN"}
|
package/types/index.d.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* @see https://roots.io/bud
|
6
6
|
* @see https://github.com/roots/bud
|
7
7
|
*
|
8
|
-
*
|
8
|
+
* @packageDocumentation
|
9
9
|
*/
|
10
|
-
export { Compiler } from './Compiler';
|
10
|
+
export { Compiler } from './Compiler/compiler.service';
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA"}
|
@@ -1,190 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Compiler = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const bud_framework_1 = require("@roots/bud-framework");
|
6
|
-
const bud_support_1 = require("@roots/bud-support");
|
7
|
-
const webpack_1 = require("webpack");
|
8
|
-
const { isFunction } = bud_support_1.lodash;
|
9
|
-
const helpful_decorators_1 = require("helpful-decorators");
|
10
|
-
/**
|
11
|
-
* Initial state
|
12
|
-
*
|
13
|
-
* @public
|
14
|
-
*/
|
15
|
-
const INITIAL_STATS = {
|
16
|
-
assets: [],
|
17
|
-
errors: [],
|
18
|
-
warnings: [],
|
19
|
-
};
|
20
|
-
/**
|
21
|
-
* Wepback compilation controller class
|
22
|
-
*
|
23
|
-
* @public
|
24
|
-
*/
|
25
|
-
class Compiler extends bud_framework_1.Service {
|
26
|
-
constructor() {
|
27
|
-
super(...arguments);
|
28
|
-
/**
|
29
|
-
* Compilation stats
|
30
|
-
*
|
31
|
-
* @public
|
32
|
-
*/
|
33
|
-
this.stats = INITIAL_STATS;
|
34
|
-
/**
|
35
|
-
* True if compiler is already instantiated
|
36
|
-
*
|
37
|
-
* @public
|
38
|
-
*/
|
39
|
-
this.isCompiled = false;
|
40
|
-
/**
|
41
|
-
* @public
|
42
|
-
*/
|
43
|
-
this.config = [];
|
44
|
-
}
|
45
|
-
/**
|
46
|
-
* {@inheritDoc @roots/bud-framework#Service.register}
|
47
|
-
*
|
48
|
-
* @public
|
49
|
-
* @decorator `@bind`
|
50
|
-
*/
|
51
|
-
register() {
|
52
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { });
|
53
|
-
}
|
54
|
-
/**
|
55
|
-
* Initiates compilation
|
56
|
-
*
|
57
|
-
* @returns the compiler instance
|
58
|
-
*
|
59
|
-
* @public
|
60
|
-
* @decorator `@bind`
|
61
|
-
*/
|
62
|
-
compile() {
|
63
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
64
|
-
const config = yield this.before();
|
65
|
-
const compiler = yield this.invokeCompiler(config);
|
66
|
-
this.app.timeEnd('bud');
|
67
|
-
return compiler;
|
68
|
-
});
|
69
|
-
}
|
70
|
-
/**
|
71
|
-
* @public
|
72
|
-
* @decorator `@bind`
|
73
|
-
*/
|
74
|
-
invokeCompiler(config) {
|
75
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
76
|
-
this.app.hooks.filter('before.compiler');
|
77
|
-
this.instance = (0, webpack_1.webpack)(config);
|
78
|
-
this.instance.hooks.done.tap(config[0].name, (stats) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
79
|
-
var _a, _b;
|
80
|
-
stats && Object.assign(this.stats, stats.toJson());
|
81
|
-
if (this.app.isProduction) {
|
82
|
-
this.instance.close(err => {
|
83
|
-
if (err) {
|
84
|
-
this.stats.errors.push(err);
|
85
|
-
this.log('error', err);
|
86
|
-
}
|
87
|
-
this.app.close(() => { });
|
88
|
-
});
|
89
|
-
}
|
90
|
-
else {
|
91
|
-
((_b = (_a = this.app.server.middlewareStack) === null || _a === void 0 ? void 0 : _a.hot) === null || _b === void 0 ? void 0 : _b.publish) &&
|
92
|
-
this.app.server.middlewareStack.hot.publish({
|
93
|
-
action: 'webpack_stats',
|
94
|
-
data: { stats: this.stats },
|
95
|
-
});
|
96
|
-
}
|
97
|
-
}));
|
98
|
-
new webpack_1.ProgressPlugin((...args) => {
|
99
|
-
this.progress = args;
|
100
|
-
}).apply(this.instance);
|
101
|
-
this.app.hooks.filter('after.compiler');
|
102
|
-
return this.instance;
|
103
|
-
});
|
104
|
-
}
|
105
|
-
/**
|
106
|
-
* Returns final webpack configuration
|
107
|
-
*
|
108
|
-
* @public
|
109
|
-
* @decorator `@bind`
|
110
|
-
*/
|
111
|
-
before() {
|
112
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
113
|
-
const config = [];
|
114
|
-
this.stats = INITIAL_STATS;
|
115
|
-
this.isCompiled = true;
|
116
|
-
!this.app.isRoot &&
|
117
|
-
this.log('error', `Attempting to compile a child directly. Only the parent instance should be compiled.`);
|
118
|
-
yield this.app.build.make();
|
119
|
-
/**
|
120
|
-
* Attempt to use the parent instance in the compilation if there are entries
|
121
|
-
* registered to it or if it has no child instances registered.
|
122
|
-
*/
|
123
|
-
if (this.app.children.getEntries().length === 0) {
|
124
|
-
this.app.info(`using config from parent compiler`);
|
125
|
-
config.push(this.app.build.config);
|
126
|
-
return config;
|
127
|
-
}
|
128
|
-
else {
|
129
|
-
this.app.warn(`root compiler will not be tapped (child compilers in use)`);
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* If there are {@link Framework.children} instances, iterate through
|
133
|
-
* them and add to `config`
|
134
|
-
*/
|
135
|
-
yield Promise.all(this.app.children.getValues().map((instance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
136
|
-
if (!instance.name)
|
137
|
-
return;
|
138
|
-
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
139
|
-
yield instance.build.make();
|
140
|
-
config.push(instance.build.config);
|
141
|
-
})));
|
142
|
-
return config;
|
143
|
-
});
|
144
|
-
}
|
145
|
-
/**
|
146
|
-
* Compilation callback
|
147
|
-
*
|
148
|
-
* @public
|
149
|
-
* @decorator `@bind`
|
150
|
-
*/
|
151
|
-
callback(...args) {
|
152
|
-
var _a;
|
153
|
-
/**
|
154
|
-
* production mode callback takes two parameters (webpack err and stats)
|
155
|
-
* however, the done hook used in development just takes one (stats)
|
156
|
-
*
|
157
|
-
* here we parse the callback args so that we dont have to
|
158
|
-
* duplicate the callback.
|
159
|
-
*/
|
160
|
-
const [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
161
|
-
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
162
|
-
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
163
|
-
this.app.store.is('features.dashboard', false) &&
|
164
|
-
this.app.log(stats.toString());
|
165
|
-
}
|
166
|
-
if (err) {
|
167
|
-
this.stats.errors.push(err);
|
168
|
-
this.app.store.is('features.dashboard', false) &&
|
169
|
-
this.log('error', err);
|
170
|
-
}
|
171
|
-
}
|
172
|
-
}
|
173
|
-
(0, tslib_1.__decorate)([
|
174
|
-
bud_support_1.bind
|
175
|
-
], Compiler.prototype, "register", null);
|
176
|
-
(0, tslib_1.__decorate)([
|
177
|
-
bud_support_1.bind
|
178
|
-
], Compiler.prototype, "compile", null);
|
179
|
-
(0, tslib_1.__decorate)([
|
180
|
-
bud_support_1.bind
|
181
|
-
], Compiler.prototype, "invokeCompiler", null);
|
182
|
-
(0, tslib_1.__decorate)([
|
183
|
-
bud_support_1.bind,
|
184
|
-
helpful_decorators_1.once
|
185
|
-
], Compiler.prototype, "before", null);
|
186
|
-
(0, tslib_1.__decorate)([
|
187
|
-
bud_support_1.bind
|
188
|
-
], Compiler.prototype, "callback", null);
|
189
|
-
exports.Compiler = Compiler;
|
190
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";;;;AAAA,wDAG6B;AAC7B,oDAA+C;AAC/C,qCAAiE;AACjE,MAAM,EAAC,UAAU,EAAC,GAAG,oBAAM,CAAA;AAC3B,2DAAuC;AAEvC;;;;GAIG;AACH,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;CACb,CAAA;AAED;;;;GAIG;AACH,MAAa,QAAS,SAAQ,uBAAO;IAArC;;QAQE;;;;WAIG;QACI,UAAK,GAAqB,aAAa,CAAA;QAS9C;;;;WAIG;QACI,eAAU,GAAY,KAAK,CAAA;QAElC;;WAEG;QACI,WAAM,GAAQ,EAAE,CAAA;IA4JzB,CAAC;IA1JC;;;;;OAKG;IAEU,QAAQ;2EAAI,CAAC;KAAA;IAE1B;;;;;;;OAOG;IAEU,OAAO;;YAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;YAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;YAClD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,C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;IACJ,yBAAI;sCAiDJ;AASD;IADC,kBAAI;wCAyBJ;AA3LH,4BA4LC"}
|
package/lib/cjs/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC;;;;;;;;GAQG;AAEH,uCAAmC;AAA3B,oGAAA,QAAQ,OAAA"}
|
@@ -1,186 +0,0 @@
|
|
1
|
-
import { __awaiter, __decorate } from "tslib";
|
2
|
-
import { Service, } from '@roots/bud-framework';
|
3
|
-
import { bind, lodash } from '@roots/bud-support';
|
4
|
-
import { ProgressPlugin, webpack } from 'webpack';
|
5
|
-
const { isFunction } = lodash;
|
6
|
-
import { once } from 'helpful-decorators';
|
7
|
-
/**
|
8
|
-
* Initial state
|
9
|
-
*
|
10
|
-
* @public
|
11
|
-
*/
|
12
|
-
const INITIAL_STATS = {
|
13
|
-
assets: [],
|
14
|
-
errors: [],
|
15
|
-
warnings: [],
|
16
|
-
};
|
17
|
-
/**
|
18
|
-
* Wepback compilation controller class
|
19
|
-
*
|
20
|
-
* @public
|
21
|
-
*/
|
22
|
-
export class Compiler extends Service {
|
23
|
-
constructor() {
|
24
|
-
super(...arguments);
|
25
|
-
/**
|
26
|
-
* Compilation stats
|
27
|
-
*
|
28
|
-
* @public
|
29
|
-
*/
|
30
|
-
this.stats = INITIAL_STATS;
|
31
|
-
/**
|
32
|
-
* True if compiler is already instantiated
|
33
|
-
*
|
34
|
-
* @public
|
35
|
-
*/
|
36
|
-
this.isCompiled = false;
|
37
|
-
/**
|
38
|
-
* @public
|
39
|
-
*/
|
40
|
-
this.config = [];
|
41
|
-
}
|
42
|
-
/**
|
43
|
-
* {@inheritDoc @roots/bud-framework#Service.register}
|
44
|
-
*
|
45
|
-
* @public
|
46
|
-
* @decorator `@bind`
|
47
|
-
*/
|
48
|
-
register() {
|
49
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
50
|
-
}
|
51
|
-
/**
|
52
|
-
* Initiates compilation
|
53
|
-
*
|
54
|
-
* @returns the compiler instance
|
55
|
-
*
|
56
|
-
* @public
|
57
|
-
* @decorator `@bind`
|
58
|
-
*/
|
59
|
-
compile() {
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
61
|
-
const config = yield this.before();
|
62
|
-
const compiler = yield this.invokeCompiler(config);
|
63
|
-
this.app.timeEnd('bud');
|
64
|
-
return compiler;
|
65
|
-
});
|
66
|
-
}
|
67
|
-
/**
|
68
|
-
* @public
|
69
|
-
* @decorator `@bind`
|
70
|
-
*/
|
71
|
-
invokeCompiler(config) {
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
73
|
-
this.app.hooks.filter('before.compiler');
|
74
|
-
this.instance = webpack(config);
|
75
|
-
this.instance.hooks.done.tap(config[0].name, (stats) => __awaiter(this, void 0, void 0, function* () {
|
76
|
-
var _a, _b;
|
77
|
-
stats && Object.assign(this.stats, stats.toJson());
|
78
|
-
if (this.app.isProduction) {
|
79
|
-
this.instance.close(err => {
|
80
|
-
if (err) {
|
81
|
-
this.stats.errors.push(err);
|
82
|
-
this.log('error', err);
|
83
|
-
}
|
84
|
-
this.app.close(() => { });
|
85
|
-
});
|
86
|
-
}
|
87
|
-
else {
|
88
|
-
((_b = (_a = this.app.server.middlewareStack) === null || _a === void 0 ? void 0 : _a.hot) === null || _b === void 0 ? void 0 : _b.publish) &&
|
89
|
-
this.app.server.middlewareStack.hot.publish({
|
90
|
-
action: 'webpack_stats',
|
91
|
-
data: { stats: this.stats },
|
92
|
-
});
|
93
|
-
}
|
94
|
-
}));
|
95
|
-
new ProgressPlugin((...args) => {
|
96
|
-
this.progress = args;
|
97
|
-
}).apply(this.instance);
|
98
|
-
this.app.hooks.filter('after.compiler');
|
99
|
-
return this.instance;
|
100
|
-
});
|
101
|
-
}
|
102
|
-
/**
|
103
|
-
* Returns final webpack configuration
|
104
|
-
*
|
105
|
-
* @public
|
106
|
-
* @decorator `@bind`
|
107
|
-
*/
|
108
|
-
before() {
|
109
|
-
return __awaiter(this, void 0, void 0, function* () {
|
110
|
-
const config = [];
|
111
|
-
this.stats = INITIAL_STATS;
|
112
|
-
this.isCompiled = true;
|
113
|
-
!this.app.isRoot &&
|
114
|
-
this.log('error', `Attempting to compile a child directly. Only the parent instance should be compiled.`);
|
115
|
-
yield this.app.build.make();
|
116
|
-
/**
|
117
|
-
* Attempt to use the parent instance in the compilation if there are entries
|
118
|
-
* registered to it or if it has no child instances registered.
|
119
|
-
*/
|
120
|
-
if (this.app.children.getEntries().length === 0) {
|
121
|
-
this.app.info(`using config from parent compiler`);
|
122
|
-
config.push(this.app.build.config);
|
123
|
-
return config;
|
124
|
-
}
|
125
|
-
else {
|
126
|
-
this.app.warn(`root compiler will not be tapped (child compilers in use)`);
|
127
|
-
}
|
128
|
-
/**
|
129
|
-
* If there are {@link Framework.children} instances, iterate through
|
130
|
-
* them and add to `config`
|
131
|
-
*/
|
132
|
-
yield Promise.all(this.app.children.getValues().map((instance) => __awaiter(this, void 0, void 0, function* () {
|
133
|
-
if (!instance.name)
|
134
|
-
return;
|
135
|
-
this.log('success', `\`${instance.name}\` compiler will be tapped`);
|
136
|
-
yield instance.build.make();
|
137
|
-
config.push(instance.build.config);
|
138
|
-
})));
|
139
|
-
return config;
|
140
|
-
});
|
141
|
-
}
|
142
|
-
/**
|
143
|
-
* Compilation callback
|
144
|
-
*
|
145
|
-
* @public
|
146
|
-
* @decorator `@bind`
|
147
|
-
*/
|
148
|
-
callback(...args) {
|
149
|
-
var _a;
|
150
|
-
/**
|
151
|
-
* production mode callback takes two parameters (webpack err and stats)
|
152
|
-
* however, the done hook used in development just takes one (stats)
|
153
|
-
*
|
154
|
-
* here we parse the callback args so that we dont have to
|
155
|
-
* duplicate the callback.
|
156
|
-
*/
|
157
|
-
const [err, stats] = args.length > 1 ? args : [null, args.pop()];
|
158
|
-
if ((stats === null || stats === void 0 ? void 0 : stats.toJson) && isFunction(stats.toJson)) {
|
159
|
-
this.stats = stats.toJson((_a = this.app.build.config.stats) !== null && _a !== void 0 ? _a : { preset: 'normal' });
|
160
|
-
this.app.store.is('features.dashboard', false) &&
|
161
|
-
this.app.log(stats.toString());
|
162
|
-
}
|
163
|
-
if (err) {
|
164
|
-
this.stats.errors.push(err);
|
165
|
-
this.app.store.is('features.dashboard', false) &&
|
166
|
-
this.log('error', err);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
__decorate([
|
171
|
-
bind
|
172
|
-
], Compiler.prototype, "register", null);
|
173
|
-
__decorate([
|
174
|
-
bind
|
175
|
-
], Compiler.prototype, "compile", null);
|
176
|
-
__decorate([
|
177
|
-
bind
|
178
|
-
], Compiler.prototype, "invokeCompiler", null);
|
179
|
-
__decorate([
|
180
|
-
bind,
|
181
|
-
once
|
182
|
-
], Compiler.prototype, "before", null);
|
183
|
-
__decorate([
|
184
|
-
bind
|
185
|
-
], Compiler.prototype, "callback", null);
|
186
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
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;AAC/C,OAAO,EAAC,cAAc,EAAoB,OAAO,EAAC,MAAM,SAAS,CAAA;AACjE,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,CAAA;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAA;AAEvC;;;;GAIG;AACH,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;CACb,CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO;IAArC;;QAQE;;;;WAIG;QACI,UAAK,GAAqB,aAAa,CAAA;Q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;SACjC;QAED,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC;gBAC5C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;SACzB;IACH,CAAC;CACF;AAnJC;IADC,IAAI;wCACqB;AAW1B;IADC,IAAI;uCAMJ;AAOD;IADC,IAAI;8CAiCJ;AAUD;IAFC,IAAI;IACJ,IAAI;sCAiDJ;AASD;IADC,IAAI;wCAyBJ"}
|
package/lib/esm/index.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// Copyright (c) Roots Foundation, LLC. All rights reserved.
|
2
|
-
// Licensed under the MIT license.
|
3
|
-
/**
|
4
|
-
* The {@link @roots/bud-compiler# | @roots/bud-compiler} package implements the
|
5
|
-
* {@link @roots/bud-framework#Compiler | Compiler interface}
|
6
|
-
*
|
7
|
-
* @see https://roots.io/bud
|
8
|
-
* @see https://github.com/roots/bud
|
9
|
-
*
|
10
|
-
* @core @packageDocumentation @betaDocumentation
|
11
|
-
*/
|
12
|
-
export { Compiler } from './Compiler';
|
13
|
-
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC;;;;;;;;GAQG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA"}
|