@roots/bud-compiler 4.7.0-next.11 → 5.0.0-next.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/lib/cjs/Compiler/index.js +67 -57
- package/lib/cjs/Compiler/index.js.map +1 -1
- package/lib/cjs/index.js +9 -6
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/Compiler/index.js +63 -54
- package/lib/esm/Compiler/index.js.map +1 -1
- package/lib/esm/index.js +7 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig-esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -5
- package/types/Compiler/index.d.ts +34 -20
- package/types/Compiler/index.d.ts.map +1 -1
- package/types/index.d.ts +5 -4
- package/types/index.d.ts.map +1 -1
@@ -1,45 +1,45 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
3
|
exports.Compiler = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
10
5
|
const bud_framework_1 = require("@roots/bud-framework");
|
11
6
|
const autobind_decorator_1 = require("autobind-decorator");
|
12
|
-
const lodash_1 = require("lodash");
|
13
7
|
const webpack_1 = require("webpack");
|
8
|
+
/**
|
9
|
+
* Initial state
|
10
|
+
*
|
11
|
+
* @public
|
12
|
+
*/
|
14
13
|
const INITIAL_STATS = {
|
15
14
|
assets: [],
|
16
15
|
errors: [],
|
17
16
|
warnings: [],
|
18
17
|
};
|
18
|
+
/**
|
19
|
+
* Wepback compilation controller class
|
20
|
+
*
|
21
|
+
* @public
|
22
|
+
*/
|
19
23
|
class Compiler extends bud_framework_1.Service {
|
20
24
|
constructor() {
|
21
25
|
super(...arguments);
|
22
|
-
/**
|
23
|
-
* {@link Service} name
|
24
|
-
*/
|
25
|
-
this.name = 'compiler';
|
26
26
|
/**
|
27
27
|
* Compilation stats
|
28
|
+
*
|
29
|
+
* @public
|
28
30
|
*/
|
29
31
|
this.stats = INITIAL_STATS;
|
30
32
|
/**
|
31
33
|
* True if compiler is already instantiated
|
34
|
+
*
|
35
|
+
* @public
|
32
36
|
*/
|
33
37
|
this.isCompiled = false;
|
34
38
|
}
|
35
39
|
/**
|
36
|
-
*
|
37
|
-
*
|
38
|
-
* @remarks
|
39
|
-
* Registers hooks filtered before and after
|
40
|
-
* the instantiation of Webpack as well as one additional hook
|
41
|
-
* which is filtered at the tail of the Webpack compiler callback.
|
40
|
+
* {@inheritDoc @roots/bud-framework#Service.register}
|
42
41
|
*
|
42
|
+
* @public
|
43
43
|
* @decorator `@bind`
|
44
44
|
*/
|
45
45
|
register() {
|
@@ -47,20 +47,49 @@ class Compiler extends bud_framework_1.Service {
|
|
47
47
|
this.app.hooks.on('after', () => []);
|
48
48
|
}
|
49
49
|
/**
|
50
|
-
*
|
50
|
+
* Initiates compilation
|
51
|
+
*
|
52
|
+
* @returns the compiler instance
|
53
|
+
*
|
54
|
+
* @public
|
55
|
+
* @decorator `@bind`
|
51
56
|
*/
|
52
57
|
compile() {
|
53
|
-
let
|
58
|
+
let instance;
|
54
59
|
if (this.isCompiled)
|
55
60
|
this.instance.close(() => {
|
56
|
-
|
61
|
+
instance = this.setup(this.before());
|
57
62
|
});
|
58
63
|
else
|
59
|
-
|
60
|
-
return
|
64
|
+
instance = this.setup(this.before());
|
65
|
+
return instance;
|
66
|
+
}
|
67
|
+
/**
|
68
|
+
* @public
|
69
|
+
* @decorator `@bind`
|
70
|
+
*/
|
71
|
+
setup(config) {
|
72
|
+
this.instance = this.app.isDevelopment
|
73
|
+
? (0, webpack_1.webpack)(config, this.callback)
|
74
|
+
: (0, webpack_1.webpack)(config);
|
75
|
+
if (this.app.isProduction) {
|
76
|
+
this.instance.hooks.done.tap(this.app.name, stats => {
|
77
|
+
stats && Object.assign(this.stats, stats.toJson());
|
78
|
+
this.instance.close(err => {
|
79
|
+
err && this.stats.errors.push(err);
|
80
|
+
});
|
81
|
+
});
|
82
|
+
}
|
83
|
+
new webpack_1.ProgressPlugin((...args) => {
|
84
|
+
this.progress = args;
|
85
|
+
}).apply(this.instance);
|
86
|
+
return this.instance;
|
61
87
|
}
|
62
88
|
/**
|
63
89
|
* Returns final webpack configuration
|
90
|
+
*
|
91
|
+
* @public
|
92
|
+
* @decorator `@bind`
|
64
93
|
*/
|
65
94
|
before() {
|
66
95
|
const config = [];
|
@@ -73,10 +102,9 @@ class Compiler extends bud_framework_1.Service {
|
|
73
102
|
* Attempt to use the parent instance in the compilation if there are entries
|
74
103
|
* registered to it or if it has no child instances registered.
|
75
104
|
*/
|
76
|
-
if (this.app.build.
|
77
|
-
!this.app.hasChildren) {
|
105
|
+
if (this.app.build.config.entry || !this.app.hasChildren) {
|
78
106
|
this.app.info('using parent compiler');
|
79
|
-
config.push(this.app.build.
|
107
|
+
config.push(this.app.build.config);
|
80
108
|
}
|
81
109
|
/**
|
82
110
|
* If there are {@link Framework.children} instances, iterate through
|
@@ -87,27 +115,16 @@ class Compiler extends bud_framework_1.Service {
|
|
87
115
|
name &&
|
88
116
|
(() => {
|
89
117
|
this.app.info(`using ${name} compiler`);
|
90
|
-
config.push(build.
|
118
|
+
config.push(build.config);
|
91
119
|
})();
|
92
120
|
});
|
93
|
-
this.app.debug(config);
|
94
121
|
return config;
|
95
122
|
}
|
96
|
-
setup(config) {
|
97
|
-
this.instance = webpack_1.webpack(config);
|
98
|
-
this.instance.hooks.done.tap(this.app.name, stats => {
|
99
|
-
stats && Object.assign(this.stats, stats.toJson());
|
100
|
-
this.instance.close(err => {
|
101
|
-
err && this.stats.errors.push(err);
|
102
|
-
});
|
103
|
-
});
|
104
|
-
new webpack_1.ProgressPlugin((...args) => {
|
105
|
-
this.progress = args;
|
106
|
-
}).apply(this.instance);
|
107
|
-
return this.instance;
|
108
|
-
}
|
109
123
|
/**
|
110
|
-
*
|
124
|
+
* Compilation callback
|
125
|
+
*
|
126
|
+
* @public
|
127
|
+
* @decorator `@bind`
|
111
128
|
*/
|
112
129
|
callback(...args) {
|
113
130
|
/**
|
@@ -121,31 +138,24 @@ class Compiler extends bud_framework_1.Service {
|
|
121
138
|
this.app.when(stats, () => {
|
122
139
|
this.stats = stats.toJson(this.app.build.config.stats);
|
123
140
|
});
|
124
|
-
this.
|
125
|
-
this.stats.errors.push(err);
|
126
|
-
});
|
127
|
-
this.app.when(this.app.store.isTrue('ci'), () => {
|
128
|
-
stats && process.stdout.write(stats.toString());
|
129
|
-
err &&
|
130
|
-
process.stderr.write(lodash_1.isString(err) ? err : JSON.stringify(err));
|
131
|
-
});
|
141
|
+
err && this.stats.errors.push(err);
|
132
142
|
const doneCallbacks = this.app.hooks.filter('done');
|
133
|
-
doneCallbacks
|
143
|
+
doneCallbacks === null || doneCallbacks === void 0 ? void 0 : doneCallbacks.map((cb) => cb(this.app));
|
134
144
|
}
|
135
145
|
}
|
136
|
-
__decorate([
|
146
|
+
(0, tslib_1.__decorate)([
|
137
147
|
autobind_decorator_1.boundMethod
|
138
148
|
], Compiler.prototype, "register", null);
|
139
|
-
__decorate([
|
149
|
+
(0, tslib_1.__decorate)([
|
140
150
|
autobind_decorator_1.boundMethod
|
141
151
|
], Compiler.prototype, "compile", null);
|
142
|
-
__decorate([
|
143
|
-
autobind_decorator_1.boundMethod
|
144
|
-
], Compiler.prototype, "before", null);
|
145
|
-
__decorate([
|
152
|
+
(0, tslib_1.__decorate)([
|
146
153
|
autobind_decorator_1.boundMethod
|
147
154
|
], Compiler.prototype, "setup", null);
|
148
|
-
__decorate([
|
155
|
+
(0, tslib_1.__decorate)([
|
156
|
+
autobind_decorator_1.boundMethod
|
157
|
+
], Compiler.prototype, "before", null);
|
158
|
+
(0, tslib_1.__decorate)([
|
149
159
|
autobind_decorator_1.boundMethod
|
150
160
|
], Compiler.prototype, "callback", null);
|
151
161
|
exports.Compiler = Compiler;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";;;;AAAA,wDAI6B;AAC7B,2DAAsD;AACtD,qCAAiE;AAEjE;;;;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;IAwIpC,CAAC;IAtIC;;;;;OAKG;IAEI,QAAQ;QACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QACrC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;IAED;;;;;;;OAOG;IAEI,OAAO;QACZ,IAAI,QAAQ,CAAA;QAEZ,IAAI,IAAI,CAAC,UAAU;YACjB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE;gBACvB,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;YACtC,CAAC,CAAC,CAAA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AAE;YACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;QAEF,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAElC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEnD,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,GAAG,CAAC,CAAC,EAA2B,EAAE,EAAE,CACjD,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CACb,CAAA;IACH,CAAC;CACF;AA/HC;IADC,gCAAI;wCAIJ;AAWD;IADC,gCAAI;uCAWJ;AAOD;IADC,gCAAI;qCAqBJ;AASD;IADC,gCAAI;sCAoCJ;AASD;IADC,gCAAI;wCAuBJ;AAlKH,4BAmKC"}
|
package/lib/cjs/index.js
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
"use strict";
|
2
|
+
// Copyright (c) Roots Foundation, LLC. All rights reserved.
|
3
|
+
// Licensed under the MIT license.
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
+
exports.Compiler = void 0;
|
2
6
|
/**
|
3
|
-
*
|
7
|
+
* The {@link @roots/bud-compiler# | @roots/bud-compiler} package implements the
|
8
|
+
* {@link @roots/bud-framework#Compiler | Compiler interface}
|
4
9
|
*
|
5
|
-
* @
|
6
|
-
*
|
10
|
+
* @see https://roots.io/bud
|
11
|
+
* @see https://github.com/roots/bud
|
7
12
|
*
|
8
|
-
* @packageDocumentation
|
13
|
+
* @core @packageDocumentation @betaDocumentation
|
9
14
|
*/
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
-
exports.Compiler = void 0;
|
12
15
|
var Compiler_1 = require("./Compiler");
|
13
16
|
Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return Compiler_1.Compiler; } });
|
14
17
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA
|
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,42 +1,42 @@
|
|
1
|
-
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
-
};
|
1
|
+
import { __decorate } from "tslib";
|
7
2
|
import { Service, } from '@roots/bud-framework';
|
8
3
|
import { boundMethod as bind } from 'autobind-decorator';
|
9
|
-
import { isString } from 'lodash';
|
10
4
|
import { ProgressPlugin, webpack } from 'webpack';
|
5
|
+
/**
|
6
|
+
* Initial state
|
7
|
+
*
|
8
|
+
* @public
|
9
|
+
*/
|
11
10
|
const INITIAL_STATS = {
|
12
11
|
assets: [],
|
13
12
|
errors: [],
|
14
13
|
warnings: [],
|
15
14
|
};
|
16
|
-
|
15
|
+
/**
|
16
|
+
* Wepback compilation controller class
|
17
|
+
*
|
18
|
+
* @public
|
19
|
+
*/
|
20
|
+
export class Compiler extends Service {
|
17
21
|
constructor() {
|
18
22
|
super(...arguments);
|
19
|
-
/**
|
20
|
-
* {@link Service} name
|
21
|
-
*/
|
22
|
-
this.name = 'compiler';
|
23
23
|
/**
|
24
24
|
* Compilation stats
|
25
|
+
*
|
26
|
+
* @public
|
25
27
|
*/
|
26
28
|
this.stats = INITIAL_STATS;
|
27
29
|
/**
|
28
30
|
* True if compiler is already instantiated
|
31
|
+
*
|
32
|
+
* @public
|
29
33
|
*/
|
30
34
|
this.isCompiled = false;
|
31
35
|
}
|
32
36
|
/**
|
33
|
-
*
|
34
|
-
*
|
35
|
-
* @remarks
|
36
|
-
* Registers hooks filtered before and after
|
37
|
-
* the instantiation of Webpack as well as one additional hook
|
38
|
-
* which is filtered at the tail of the Webpack compiler callback.
|
37
|
+
* {@inheritDoc @roots/bud-framework#Service.register}
|
39
38
|
*
|
39
|
+
* @public
|
40
40
|
* @decorator `@bind`
|
41
41
|
*/
|
42
42
|
register() {
|
@@ -44,20 +44,49 @@ class Compiler extends Service {
|
|
44
44
|
this.app.hooks.on('after', () => []);
|
45
45
|
}
|
46
46
|
/**
|
47
|
-
*
|
47
|
+
* Initiates compilation
|
48
|
+
*
|
49
|
+
* @returns the compiler instance
|
50
|
+
*
|
51
|
+
* @public
|
52
|
+
* @decorator `@bind`
|
48
53
|
*/
|
49
54
|
compile() {
|
50
|
-
let
|
55
|
+
let instance;
|
51
56
|
if (this.isCompiled)
|
52
57
|
this.instance.close(() => {
|
53
|
-
|
58
|
+
instance = this.setup(this.before());
|
54
59
|
});
|
55
60
|
else
|
56
|
-
|
57
|
-
return
|
61
|
+
instance = this.setup(this.before());
|
62
|
+
return instance;
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* @public
|
66
|
+
* @decorator `@bind`
|
67
|
+
*/
|
68
|
+
setup(config) {
|
69
|
+
this.instance = this.app.isDevelopment
|
70
|
+
? webpack(config, this.callback)
|
71
|
+
: webpack(config);
|
72
|
+
if (this.app.isProduction) {
|
73
|
+
this.instance.hooks.done.tap(this.app.name, stats => {
|
74
|
+
stats && Object.assign(this.stats, stats.toJson());
|
75
|
+
this.instance.close(err => {
|
76
|
+
err && this.stats.errors.push(err);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
}
|
80
|
+
new ProgressPlugin((...args) => {
|
81
|
+
this.progress = args;
|
82
|
+
}).apply(this.instance);
|
83
|
+
return this.instance;
|
58
84
|
}
|
59
85
|
/**
|
60
86
|
* Returns final webpack configuration
|
87
|
+
*
|
88
|
+
* @public
|
89
|
+
* @decorator `@bind`
|
61
90
|
*/
|
62
91
|
before() {
|
63
92
|
const config = [];
|
@@ -70,10 +99,9 @@ class Compiler extends Service {
|
|
70
99
|
* Attempt to use the parent instance in the compilation if there are entries
|
71
100
|
* registered to it or if it has no child instances registered.
|
72
101
|
*/
|
73
|
-
if (this.app.build.
|
74
|
-
!this.app.hasChildren) {
|
102
|
+
if (this.app.build.config.entry || !this.app.hasChildren) {
|
75
103
|
this.app.info('using parent compiler');
|
76
|
-
config.push(this.app.build.
|
104
|
+
config.push(this.app.build.config);
|
77
105
|
}
|
78
106
|
/**
|
79
107
|
* If there are {@link Framework.children} instances, iterate through
|
@@ -84,27 +112,16 @@ class Compiler extends Service {
|
|
84
112
|
name &&
|
85
113
|
(() => {
|
86
114
|
this.app.info(`using ${name} compiler`);
|
87
|
-
config.push(build.
|
115
|
+
config.push(build.config);
|
88
116
|
})();
|
89
117
|
});
|
90
|
-
this.app.debug(config);
|
91
118
|
return config;
|
92
119
|
}
|
93
|
-
setup(config) {
|
94
|
-
this.instance = webpack(config);
|
95
|
-
this.instance.hooks.done.tap(this.app.name, stats => {
|
96
|
-
stats && Object.assign(this.stats, stats.toJson());
|
97
|
-
this.instance.close(err => {
|
98
|
-
err && this.stats.errors.push(err);
|
99
|
-
});
|
100
|
-
});
|
101
|
-
new ProgressPlugin((...args) => {
|
102
|
-
this.progress = args;
|
103
|
-
}).apply(this.instance);
|
104
|
-
return this.instance;
|
105
|
-
}
|
106
120
|
/**
|
107
|
-
*
|
121
|
+
* Compilation callback
|
122
|
+
*
|
123
|
+
* @public
|
124
|
+
* @decorator `@bind`
|
108
125
|
*/
|
109
126
|
callback(...args) {
|
110
127
|
/**
|
@@ -118,16 +135,9 @@ class Compiler extends Service {
|
|
118
135
|
this.app.when(stats, () => {
|
119
136
|
this.stats = stats.toJson(this.app.build.config.stats);
|
120
137
|
});
|
121
|
-
this.
|
122
|
-
this.stats.errors.push(err);
|
123
|
-
});
|
124
|
-
this.app.when(this.app.store.isTrue('ci'), () => {
|
125
|
-
stats && process.stdout.write(stats.toString());
|
126
|
-
err &&
|
127
|
-
process.stderr.write(isString(err) ? err : JSON.stringify(err));
|
128
|
-
});
|
138
|
+
err && this.stats.errors.push(err);
|
129
139
|
const doneCallbacks = this.app.hooks.filter('done');
|
130
|
-
doneCallbacks
|
140
|
+
doneCallbacks === null || doneCallbacks === void 0 ? void 0 : doneCallbacks.map((cb) => cb(this.app));
|
131
141
|
}
|
132
142
|
}
|
133
143
|
__decorate([
|
@@ -138,12 +148,11 @@ __decorate([
|
|
138
148
|
], Compiler.prototype, "compile", null);
|
139
149
|
__decorate([
|
140
150
|
bind
|
141
|
-
], Compiler.prototype, "
|
151
|
+
], Compiler.prototype, "setup", null);
|
142
152
|
__decorate([
|
143
153
|
bind
|
144
|
-
], Compiler.prototype, "
|
154
|
+
], Compiler.prototype, "before", null);
|
145
155
|
__decorate([
|
146
156
|
bind
|
147
157
|
], Compiler.prototype, "callback", null);
|
148
|
-
export { Compiler };
|
149
158
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Compiler/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAGL,OAAO,GACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAC,WAAW,IAAI,IAAI,EAAC,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAC,cAAc,EAAoB,OAAO,EAAC,MAAM,SAAS,CAAA;AAEjE;;;;GAIG;AACH,MAAM,aAAa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AWD;IADC,IAAI;uCAWJ;AAOD;IADC,IAAI;qCAqBJ;AASD;IADC,IAAI;sCAoCJ;AASD;IADC,IAAI;wCAuBJ"}
|
package/lib/esm/index.js
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
// Copyright (c) Roots Foundation, LLC. All rights reserved.
|
2
|
+
// Licensed under the MIT license.
|
1
3
|
/**
|
2
|
-
*
|
4
|
+
* The {@link @roots/bud-compiler# | @roots/bud-compiler} package implements the
|
5
|
+
* {@link @roots/bud-framework#Compiler | Compiler interface}
|
3
6
|
*
|
4
|
-
* @
|
5
|
-
*
|
7
|
+
* @see https://roots.io/bud
|
8
|
+
* @see https://github.com/roots/bud
|
6
9
|
*
|
7
|
-
* @packageDocumentation
|
10
|
+
* @core @packageDocumentation @betaDocumentation
|
8
11
|
*/
|
9
12
|
export { Compiler } from './Compiler';
|
10
13
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
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"}
|