@roots/bud-build 2023.7.5-318 → 2023.7.18-1836
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/config/output/assetModuleFilename.js +1 -1
- package/lib/config/output/index.js +1 -1
- package/lib/config/resolve.js +3 -2
- package/lib/handlers/register.d.ts +4 -1
- package/lib/handlers/rules/image.js +4 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +5 -5
- package/lib/service.d.ts +23 -20
- package/lib/service.js +19 -16
- package/lib/types.d.ts +1 -1
- package/package.json +44 -40
- package/src/config/output/assetModuleFilename.ts +1 -1
- package/src/config/output/index.ts +1 -1
- package/src/config/resolve.ts +14 -8
- package/src/handlers/register.ts +7 -3
- package/src/handlers/rules/csv.test.ts +1 -1
- package/src/handlers/rules/image.ts +3 -0
- package/src/handlers/rules/svg.inline.test.ts +4 -5
- package/src/handlers/rules/toml.test.ts +1 -1
- package/src/index.ts +5 -5
- package/src/rule/index.test.ts +1 -1
- package/src/service.ts +25 -23
- package/src/types.ts +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export const assetModuleFilename = ({ filter, relPath }) => filter(`build.output.assetModuleFilename`, relPath(`@file`));
|
|
1
|
+
export const assetModuleFilename = ({ filter, relPath }) => filter(`build.output.assetModuleFilename`, relPath(`@file[query]`));
|
|
@@ -15,7 +15,7 @@ export const output = async ({ hooks: { filter }, isProduction, path, relPath, }
|
|
|
15
15
|
iife: filter(`build.output.iife`, undefined),
|
|
16
16
|
module: filter(`build.output.module`, false),
|
|
17
17
|
path: filter(`build.output.path`, path(`@dist`)),
|
|
18
|
-
pathinfo: filter(`build.output.pathinfo`,
|
|
18
|
+
pathinfo: filter(`build.output.pathinfo`, true),
|
|
19
19
|
publicPath: filter(`build.output.publicPath`, `auto`),
|
|
20
20
|
scriptType: filter(`build.output.scriptType`, isMjs(filter) ? `module` : `text/javascript`),
|
|
21
21
|
uniqueName: filter(`build.output.uniqueName`, `@roots/bud`),
|
package/lib/config/resolve.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import isString from '@roots/bud-support/lodash/isString';
|
|
1
2
|
export const resolve = async (bud) => {
|
|
2
3
|
return await bud.hooks.filterAsync(`build.resolve`, {
|
|
3
4
|
alias: {
|
|
@@ -12,10 +13,10 @@ export const resolve = async (bud) => {
|
|
|
12
13
|
modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
|
|
13
14
|
bud.hooks.filter(`location.@src`),
|
|
14
15
|
bud.hooks.filter(`location.@modules`),
|
|
15
|
-
]),
|
|
16
|
+
].filter(v => isString(v) && v.length > 0)),
|
|
16
17
|
/**
|
|
17
18
|
* Leave `undefined` to use webpack default (true in dev, false in production)
|
|
18
19
|
*/
|
|
19
|
-
unsafeCache: bud.hooks.filter(`build.module.unsafeCache`,
|
|
20
|
+
unsafeCache: bud.hooks.filter(`build.module.unsafeCache`, undefined),
|
|
20
21
|
});
|
|
21
22
|
};
|
|
@@ -4,7 +4,10 @@ import type { Factory } from './index.js';
|
|
|
4
4
|
* Registry factory curry function
|
|
5
5
|
*/
|
|
6
6
|
export interface makeRegister {
|
|
7
|
-
<T, F extends CallableFunction>(props: Partial<Bud>, setRule: F): <K extends keyof T & string>([key, factory]: [
|
|
7
|
+
<T, F extends CallableFunction>(props: Partial<Bud>, setRule: F): <K extends keyof T & string>([key, factory]: [
|
|
8
|
+
K,
|
|
9
|
+
Factory<T[K]>
|
|
10
|
+
]) => void;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
13
|
* Register built-in {@link loaders}, {@link items} and {@link rules}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const image = async ({ filter, makeRule, path }) => makeRule()
|
|
2
2
|
.setTest(filter(`pattern.image`))
|
|
3
3
|
.setInclude([() => path(`@src`)])
|
|
4
|
-
.setType(`asset/resource`)
|
|
4
|
+
.setType(`asset/resource`)
|
|
5
|
+
.setGenerator({
|
|
6
|
+
filename: `[path][name].[contenthash][ext][query]`,
|
|
7
|
+
});
|
package/lib/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @see https://bud.js.org
|
|
5
5
|
* @see https://github.com/roots/bud
|
|
6
6
|
*/
|
|
7
|
-
import { Item } from '
|
|
8
|
-
import { Loader } from '
|
|
9
|
-
import { Rule } from '
|
|
10
|
-
import { Build } from '
|
|
11
|
-
import '
|
|
7
|
+
import { Item } from '@roots/bud-build/item';
|
|
8
|
+
import { Loader } from '@roots/bud-build/loader';
|
|
9
|
+
import { Rule } from '@roots/bud-build/rule';
|
|
10
|
+
import { Build } from '@roots/bud-build/service';
|
|
11
|
+
import '@roots/bud-build/types';
|
|
12
12
|
export default Build;
|
|
13
13
|
export { Item, Loader, Rule };
|
package/lib/index.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @see https://bud.js.org
|
|
7
7
|
* @see https://github.com/roots/bud
|
|
8
8
|
*/
|
|
9
|
-
import { Item } from '
|
|
10
|
-
import { Loader } from '
|
|
11
|
-
import { Rule } from '
|
|
12
|
-
import { Build } from '
|
|
13
|
-
import '
|
|
9
|
+
import { Item } from '@roots/bud-build/item';
|
|
10
|
+
import { Loader } from '@roots/bud-build/loader';
|
|
11
|
+
import { Rule } from '@roots/bud-build/rule';
|
|
12
|
+
import { Build } from '@roots/bud-build/service';
|
|
13
|
+
import '@roots/bud-build/types';
|
|
14
14
|
export default Build;
|
|
15
15
|
export { Item, Loader, Rule };
|
package/lib/service.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import type { Options as RuleOptions } from '@roots/bud-build/rule';
|
|
1
2
|
import type { Bud, Build as BudBuild } from '@roots/bud-framework';
|
|
2
3
|
import type { Items, Loaders, Rules } from '@roots/bud-framework';
|
|
3
4
|
import type { Configuration } from '@roots/bud-framework/config';
|
|
5
|
+
import { register } from '@roots/bud-build/handlers';
|
|
6
|
+
import { Item } from '@roots/bud-build/item';
|
|
7
|
+
import { Loader } from '@roots/bud-build/loader';
|
|
8
|
+
import { Rule } from '@roots/bud-build/rule';
|
|
4
9
|
import { Service } from '@roots/bud-framework/service';
|
|
5
|
-
import type { Options as RuleOptions } from './rule/index.js';
|
|
6
|
-
import { register } from './handlers/register.js';
|
|
7
|
-
import { Item } from './item/index.js';
|
|
8
|
-
import { Loader } from './loader/index.js';
|
|
9
|
-
import { Rule } from './rule/index.js';
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* {@link BudBuild}
|
|
12
12
|
*/
|
|
13
13
|
export declare class Build extends Service implements BudBuild {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* {@link BudBuild.config}
|
|
16
16
|
*/
|
|
17
17
|
config: Partial<Configuration>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* {@link BudBuild.items}
|
|
20
20
|
*/
|
|
21
21
|
items: Items;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* {@link BudBuild.loaders}
|
|
24
24
|
*/
|
|
25
25
|
loaders: Loaders;
|
|
26
26
|
/**
|
|
@@ -28,48 +28,51 @@ export declare class Build extends Service implements BudBuild {
|
|
|
28
28
|
*/
|
|
29
29
|
register?: typeof register;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* {@link BudBuild.rules}
|
|
32
32
|
*/
|
|
33
33
|
rules: Rules;
|
|
34
|
+
/**
|
|
35
|
+
* {@link Service.register}
|
|
36
|
+
*/
|
|
34
37
|
bootstrap?(app: Bud): Promise<void>;
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
39
|
+
* {@link BudBuild.getItem}
|
|
37
40
|
*/
|
|
38
41
|
getItem(name: `${keyof Items & string}`): Item;
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* {@link BudBuild.getLoader}
|
|
41
44
|
*/
|
|
42
45
|
getLoader(name: string): Loader;
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
47
|
+
* {@link BudBuild.getRule}
|
|
45
48
|
*/
|
|
46
49
|
getRule<K extends `${keyof Rules & string}`>(ident: K): Rules[K];
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
51
|
+
* {@link BudBuild.make}
|
|
49
52
|
*/
|
|
50
53
|
make(): Promise<Configuration>;
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* {@link BudBuild.makeItem}
|
|
53
56
|
*/
|
|
54
57
|
makeItem(options?: Partial<Item['options']>): Item;
|
|
55
58
|
/**
|
|
56
|
-
*
|
|
59
|
+
* {@link BudBuild.makeLoader}
|
|
57
60
|
*/
|
|
58
61
|
makeLoader(src?: string, definition?: string): Loader;
|
|
59
62
|
/**
|
|
60
|
-
*
|
|
63
|
+
* {@link BudBuild.makeRule}
|
|
61
64
|
*/
|
|
62
65
|
makeRule(options?: RuleOptions): Rule;
|
|
63
66
|
/**
|
|
64
|
-
*
|
|
67
|
+
* {@link BudBuild.setItem}
|
|
65
68
|
*/
|
|
66
69
|
setItem<K extends `${keyof Items & string}`>(ident: K, options?: ((item: Items[K]) => Items[K]) | Items[K]['options']): this;
|
|
67
70
|
/**
|
|
68
|
-
*
|
|
71
|
+
* {@link BudBuild.setLoader}
|
|
69
72
|
*/
|
|
70
73
|
setLoader<K extends `${keyof Loaders & string}`>(name: K, definition?: any): this;
|
|
71
74
|
/**
|
|
72
|
-
*
|
|
75
|
+
* {@link BudBuild.setRule}
|
|
73
76
|
*/
|
|
74
77
|
setRule<K extends `${keyof Rules & string}`>(name: K, input?: Rule | RuleOptions): this;
|
|
75
78
|
}
|
package/lib/service.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
var _a, _b, _c, _d;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { register } from '@roots/bud-build/handlers';
|
|
4
|
+
import { Item } from '@roots/bud-build/item';
|
|
5
|
+
import { Loader } from '@roots/bud-build/loader';
|
|
6
|
+
import { Rule } from '@roots/bud-build/rule';
|
|
3
7
|
import { Service } from '@roots/bud-framework/service';
|
|
4
8
|
import { bind } from '@roots/bud-support/decorators/bind';
|
|
5
9
|
import isFunction from '@roots/bud-support/lodash/isFunction';
|
|
6
10
|
import isUndefined from '@roots/bud-support/lodash/isUndefined';
|
|
7
|
-
import { register } from './handlers/register.js';
|
|
8
|
-
import { Item } from './item/index.js';
|
|
9
|
-
import { Loader } from './loader/index.js';
|
|
10
|
-
import { Rule } from './rule/index.js';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* {@link BudBuild}
|
|
13
13
|
*/
|
|
14
14
|
export class Build extends Service {
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* {@link BudBuild.config}
|
|
17
17
|
*/
|
|
18
18
|
config = {};
|
|
19
19
|
/**
|
|
20
20
|
* {@link BudBuild.register}
|
|
21
21
|
*/
|
|
22
22
|
register = register.bind(this);
|
|
23
|
+
/**
|
|
24
|
+
* {@link Service.register}
|
|
25
|
+
*/
|
|
23
26
|
async bootstrap(app) {
|
|
24
27
|
this.items = {};
|
|
25
28
|
this.loaders = {};
|
|
26
29
|
this.rules = {};
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* {@link BudBuild.getItem}
|
|
30
33
|
*/
|
|
31
34
|
getItem(name) {
|
|
32
35
|
if (!this.items[name])
|
|
@@ -34,7 +37,7 @@ export class Build extends Service {
|
|
|
34
37
|
return this.items[name];
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
|
-
*
|
|
40
|
+
* {@link BudBuild.getLoader}
|
|
38
41
|
*/
|
|
39
42
|
getLoader(name) {
|
|
40
43
|
if (!this.loaders[name])
|
|
@@ -42,13 +45,13 @@ export class Build extends Service {
|
|
|
42
45
|
return this.loaders[name];
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
|
-
*
|
|
48
|
+
* {@link BudBuild.getRule}
|
|
46
49
|
*/
|
|
47
50
|
getRule(ident) {
|
|
48
51
|
return this.rules[ident];
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
|
-
*
|
|
54
|
+
* {@link BudBuild.make}
|
|
52
55
|
*/
|
|
53
56
|
async make() {
|
|
54
57
|
this.logger.log(`bud.build.make called`);
|
|
@@ -70,25 +73,25 @@ export class Build extends Service {
|
|
|
70
73
|
return this.config;
|
|
71
74
|
}
|
|
72
75
|
/**
|
|
73
|
-
*
|
|
76
|
+
* {@link BudBuild.makeItem}
|
|
74
77
|
*/
|
|
75
78
|
makeItem(options) {
|
|
76
79
|
return new Item(() => this.app, options);
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
79
|
-
*
|
|
82
|
+
* {@link BudBuild.makeLoader}
|
|
80
83
|
*/
|
|
81
84
|
makeLoader(src, definition) {
|
|
82
85
|
return new Loader(() => this.app, src, definition);
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* {@link BudBuild.makeRule}
|
|
86
89
|
*/
|
|
87
90
|
makeRule(options) {
|
|
88
91
|
return new Rule(() => this.app, options);
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
|
-
*
|
|
94
|
+
* {@link BudBuild.setItem}
|
|
92
95
|
*/
|
|
93
96
|
setItem(ident, options) {
|
|
94
97
|
const maybeOptionsCallback = isUndefined(options)
|
|
@@ -102,7 +105,7 @@ export class Build extends Service {
|
|
|
102
105
|
return this;
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
|
-
*
|
|
108
|
+
* {@link BudBuild.setLoader}
|
|
106
109
|
*/
|
|
107
110
|
setLoader(name, definition) {
|
|
108
111
|
const loader = isUndefined(definition)
|
|
@@ -115,7 +118,7 @@ export class Build extends Service {
|
|
|
115
118
|
return this;
|
|
116
119
|
}
|
|
117
120
|
/**
|
|
118
|
-
*
|
|
121
|
+
* {@link BudBuild.setRule}
|
|
119
122
|
*/
|
|
120
123
|
setRule(name, input) {
|
|
121
124
|
this.rules[name] =
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Item } from '@roots/bud-build/item';
|
|
2
2
|
import type { Loader } from '@roots/bud-build/loader';
|
|
3
3
|
import type { Rule } from '@roots/bud-build/rule';
|
|
4
|
-
import type { Build } from '
|
|
4
|
+
import type { Build } from '@roots/bud-build/service';
|
|
5
5
|
declare module '@roots/bud-framework' {
|
|
6
6
|
interface Services {
|
|
7
7
|
build: Build;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-build",
|
|
3
|
-
"version": "2023.7.
|
|
3
|
+
"version": "2023.7.18-1836",
|
|
4
4
|
"description": "bud.js core module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
7
7
|
},
|
|
8
8
|
"contributors": [
|
|
9
9
|
{
|
|
10
|
-
"name": "Kelly Mears",
|
|
11
10
|
"email": "developers@tinypixel.dev",
|
|
11
|
+
"name": "Kelly Mears",
|
|
12
12
|
"url": "https://github.com/kellymears"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
"name": "Ben Word",
|
|
16
15
|
"email": "ben@benword.com",
|
|
16
|
+
"name": "Ben Word",
|
|
17
17
|
"url": "https://github.com/retlehs"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "https://github.com/QWp6t"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
"name": "Brandon",
|
|
25
24
|
"email": "brandon@tendency.me",
|
|
25
|
+
"name": "Brandon",
|
|
26
26
|
"url": "https://github.com/Log1x"
|
|
27
27
|
}
|
|
28
28
|
],
|
|
@@ -49,50 +49,54 @@
|
|
|
49
49
|
],
|
|
50
50
|
"type": "module",
|
|
51
51
|
"exports": {
|
|
52
|
-
".":
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"./
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
52
|
+
".": "./lib/index.js",
|
|
53
|
+
"./config": "./lib/config/index.js",
|
|
54
|
+
"./handlers": "./lib/handlers/index.js",
|
|
55
|
+
"./item": "./lib/item/index.js",
|
|
56
|
+
"./loader": "./lib/loader/index.js",
|
|
57
|
+
"./rule": "./lib/rule/index.js",
|
|
58
|
+
"./service": "./lib/service.js",
|
|
59
|
+
"./types": "./lib/types.js"
|
|
60
|
+
},
|
|
61
|
+
"typesVersions": {
|
|
62
|
+
"*": {
|
|
63
|
+
"*": [
|
|
64
|
+
"./lib/types.js"
|
|
65
|
+
],
|
|
66
|
+
"config": [
|
|
67
|
+
"./lib/config/index.d.ts"
|
|
68
|
+
],
|
|
69
|
+
"handlers": [
|
|
70
|
+
"./lib/handlers/index.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"item": [
|
|
73
|
+
"./lib/item/index.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"loader": [
|
|
76
|
+
"./lib/loader/index.d.ts"
|
|
77
|
+
],
|
|
78
|
+
"rule": [
|
|
79
|
+
"./lib/rule/index.d.ts"
|
|
80
|
+
],
|
|
81
|
+
"service": [
|
|
82
|
+
"./lib/service.d.ts"
|
|
83
|
+
],
|
|
84
|
+
"types": [
|
|
85
|
+
"./lib/types.d.ts"
|
|
86
|
+
]
|
|
83
87
|
}
|
|
84
88
|
},
|
|
85
89
|
"types": "./lib/index.d.ts",
|
|
86
90
|
"module": "./lib/index.js",
|
|
87
91
|
"devDependencies": {
|
|
88
|
-
"@roots/bud-api": "2023.7.
|
|
89
|
-
"@roots/bud-hooks": "2023.7.
|
|
92
|
+
"@roots/bud-api": "2023.7.18-1836",
|
|
93
|
+
"@roots/bud-hooks": "2023.7.18-1836",
|
|
90
94
|
"@skypack/package-check": "0.2.2",
|
|
91
|
-
"@types/node": "18.16.
|
|
95
|
+
"@types/node": "18.16.19"
|
|
92
96
|
},
|
|
93
97
|
"dependencies": {
|
|
94
|
-
"@roots/bud-framework": "2023.7.
|
|
95
|
-
"@roots/bud-support": "2023.7.
|
|
98
|
+
"@roots/bud-framework": "2023.7.18-1836",
|
|
99
|
+
"@roots/bud-support": "2023.7.18-1836",
|
|
96
100
|
"tslib": "2.6.0"
|
|
97
101
|
},
|
|
98
102
|
"volta": {
|
|
@@ -24,7 +24,7 @@ export const output: Factory<`output`> = async ({
|
|
|
24
24
|
iife: filter(`build.output.iife`, undefined),
|
|
25
25
|
module: filter(`build.output.module`, false),
|
|
26
26
|
path: filter(`build.output.path`, path(`@dist`)),
|
|
27
|
-
pathinfo: filter(`build.output.pathinfo`,
|
|
27
|
+
pathinfo: filter(`build.output.pathinfo`, true),
|
|
28
28
|
publicPath: filter(`build.output.publicPath`, `auto`),
|
|
29
29
|
scriptType: filter(
|
|
30
30
|
`build.output.scriptType`,
|
package/src/config/resolve.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import isString from '@roots/bud-support/lodash/isString'
|
|
2
|
+
|
|
1
3
|
import type {Factory} from './index.js'
|
|
2
4
|
|
|
3
5
|
export const resolve: Factory<`resolve`> = async bud => {
|
|
@@ -6,6 +8,7 @@ export const resolve: Factory<`resolve`> = async bud => {
|
|
|
6
8
|
[`@src`]: bud.path(`@src`),
|
|
7
9
|
...(await bud.hooks.filterAsync(`build.resolve.alias`, {})),
|
|
8
10
|
},
|
|
11
|
+
|
|
9
12
|
extensionAlias: await bud.hooks.filterAsync(
|
|
10
13
|
`build.resolve.extensionAlias`,
|
|
11
14
|
{
|
|
@@ -13,22 +16,25 @@ export const resolve: Factory<`resolve`> = async bud => {
|
|
|
13
16
|
[`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
|
|
14
17
|
},
|
|
15
18
|
),
|
|
19
|
+
|
|
16
20
|
extensions: Array.from(
|
|
17
21
|
bud.hooks.filter(
|
|
18
22
|
`build.resolve.extensions`,
|
|
19
23
|
new Set([`.js`, `.mjs`, `.jsx`, `.css`]),
|
|
20
24
|
),
|
|
21
25
|
),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
modules: await bud.hooks.filterAsync(
|
|
28
|
+
`build.resolve.modules`,
|
|
29
|
+
[
|
|
30
|
+
bud.hooks.filter(`location.@src`),
|
|
31
|
+
bud.hooks.filter(`location.@modules`),
|
|
32
|
+
].filter(v => isString(v) && v.length > 0),
|
|
33
|
+
),
|
|
34
|
+
|
|
26
35
|
/**
|
|
27
36
|
* Leave `undefined` to use webpack default (true in dev, false in production)
|
|
28
37
|
*/
|
|
29
|
-
unsafeCache: bud.hooks.filter(
|
|
30
|
-
`build.module.unsafeCache`,
|
|
31
|
-
bud.isDevelopment,
|
|
32
|
-
),
|
|
38
|
+
unsafeCache: bud.hooks.filter(`build.module.unsafeCache`, undefined),
|
|
33
39
|
})
|
|
34
40
|
}
|
package/src/handlers/register.ts
CHANGED
|
@@ -10,9 +10,13 @@ import {rules} from './rules/index.js'
|
|
|
10
10
|
* Registry factory curry function
|
|
11
11
|
*/
|
|
12
12
|
export interface makeRegister {
|
|
13
|
-
<T, F extends CallableFunction>(
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
<T, F extends CallableFunction>(
|
|
14
|
+
props: Partial<Bud>,
|
|
15
|
+
setRule: F,
|
|
16
|
+
): <K extends keyof T & string>([key, factory]: [
|
|
17
|
+
K,
|
|
18
|
+
Factory<T[K]>,
|
|
19
|
+
]) => void
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -9,10 +9,10 @@ describe(`csv loader`, () => {
|
|
|
9
9
|
|
|
10
10
|
const result = await csv({
|
|
11
11
|
filter: bud.hooks.filter,
|
|
12
|
+
isProduction: bud.isProduction,
|
|
12
13
|
makeItem: bud.build.makeItem,
|
|
13
14
|
makeLoader: bud.build.makeLoader,
|
|
14
15
|
makeRule: bud.build.makeRule,
|
|
15
|
-
isProduction: bud.isProduction,
|
|
16
16
|
path: bud.path,
|
|
17
17
|
resolve: bud.module.resolve,
|
|
18
18
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {describe, expect, it} from 'vitest'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {dataUrl, inlineSvg} from './svg.inline.js'
|
|
4
4
|
|
|
5
5
|
describe(`svg-inline`, () => {
|
|
6
6
|
it(`should return a rule`, async () => {
|
|
@@ -9,23 +9,22 @@ describe(`svg-inline`, () => {
|
|
|
9
9
|
)
|
|
10
10
|
const result = await inlineSvg({
|
|
11
11
|
filter: bud.hooks.filter,
|
|
12
|
+
isProduction: bud.isProduction,
|
|
12
13
|
makeItem: bud.build.makeItem,
|
|
13
14
|
makeLoader: bud.build.makeLoader,
|
|
14
15
|
makeRule: bud.build.makeRule,
|
|
15
|
-
isProduction: bud.isProduction,
|
|
16
16
|
path: bud.path,
|
|
17
17
|
resolve: bud.module.resolve,
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const webpackOutput = result.toWebpack()
|
|
21
|
+
|
|
21
22
|
expect(webpackOutput.test).toEqual(bud.hooks.filter(`pattern.svg`))
|
|
22
23
|
expect(webpackOutput.include).toEqual([bud.path(`@src`)])
|
|
23
24
|
expect(webpackOutput.resourceQuery).toEqual(/inline/)
|
|
24
25
|
expect(webpackOutput.type).toEqual(`asset/inline`)
|
|
25
26
|
expect(webpackOutput.generator).toEqual(
|
|
26
|
-
expect.objectContaining({
|
|
27
|
-
dataUrl,
|
|
28
|
-
}),
|
|
27
|
+
expect.objectContaining({dataUrl}),
|
|
29
28
|
)
|
|
30
29
|
})
|
|
31
30
|
})
|
|
@@ -10,10 +10,10 @@ describe(`toml loader`, () => {
|
|
|
10
10
|
bud = await factory()
|
|
11
11
|
const result = await toml({
|
|
12
12
|
filter: bud.hooks.filter,
|
|
13
|
+
isProduction: bud.isProduction,
|
|
13
14
|
makeItem: bud.build.makeItem,
|
|
14
15
|
makeLoader: bud.build.makeLoader,
|
|
15
16
|
makeRule: bud.build.makeRule,
|
|
16
|
-
isProduction: bud.isProduction,
|
|
17
17
|
path: bud.path,
|
|
18
18
|
resolve: bud.module.resolve,
|
|
19
19
|
})
|
package/src/index.ts
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* @see https://github.com/roots/bud
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {Item} from '
|
|
12
|
-
import {Loader} from '
|
|
13
|
-
import {Rule} from '
|
|
14
|
-
import {Build} from '
|
|
15
|
-
import '
|
|
11
|
+
import {Item} from '@roots/bud-build/item'
|
|
12
|
+
import {Loader} from '@roots/bud-build/loader'
|
|
13
|
+
import {Rule} from '@roots/bud-build/rule'
|
|
14
|
+
import {Build} from '@roots/bud-build/service'
|
|
15
|
+
import '@roots/bud-build/types'
|
|
16
16
|
|
|
17
17
|
export default Build
|
|
18
18
|
|
package/src/rule/index.test.ts
CHANGED
package/src/service.ts
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
|
+
import type {Records} from '@roots/bud-build/config'
|
|
2
|
+
import type {Options as RuleOptions} from '@roots/bud-build/rule'
|
|
1
3
|
import type {Bud, Build as BudBuild} from '@roots/bud-framework'
|
|
2
4
|
import type {Items, Loaders, Rules} from '@roots/bud-framework'
|
|
3
5
|
import type {Configuration} from '@roots/bud-framework/config'
|
|
4
6
|
|
|
7
|
+
import {register} from '@roots/bud-build/handlers'
|
|
8
|
+
import {Item} from '@roots/bud-build/item'
|
|
9
|
+
import {Loader} from '@roots/bud-build/loader'
|
|
10
|
+
import {Rule} from '@roots/bud-build/rule'
|
|
5
11
|
import {Service} from '@roots/bud-framework/service'
|
|
6
12
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
7
13
|
import isFunction from '@roots/bud-support/lodash/isFunction'
|
|
8
14
|
import isUndefined from '@roots/bud-support/lodash/isUndefined'
|
|
9
15
|
|
|
10
|
-
import type {Records} from './config/index.js'
|
|
11
|
-
import type {Options as RuleOptions} from './rule/index.js'
|
|
12
|
-
|
|
13
|
-
import {register} from './handlers/register.js'
|
|
14
|
-
import {Item} from './item/index.js'
|
|
15
|
-
import {Loader} from './loader/index.js'
|
|
16
|
-
import {Rule} from './rule/index.js'
|
|
17
|
-
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
17
|
+
* {@link BudBuild}
|
|
20
18
|
*/
|
|
21
19
|
export class Build extends Service implements BudBuild {
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
21
|
+
* {@link BudBuild.config}
|
|
24
22
|
*/
|
|
25
23
|
public config: Partial<Configuration> = {}
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* {@link BudBuild.items}
|
|
29
27
|
*/
|
|
30
28
|
public declare items: Items
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
|
-
*
|
|
31
|
+
* {@link BudBuild.loaders}
|
|
34
32
|
*/
|
|
35
33
|
public declare loaders: Loaders
|
|
36
34
|
|
|
@@ -40,10 +38,13 @@ export class Build extends Service implements BudBuild {
|
|
|
40
38
|
public override register? = register.bind(this)
|
|
41
39
|
|
|
42
40
|
/**
|
|
43
|
-
*
|
|
41
|
+
* {@link BudBuild.rules}
|
|
44
42
|
*/
|
|
45
43
|
public declare rules: Rules
|
|
46
44
|
|
|
45
|
+
/**
|
|
46
|
+
* {@link Service.register}
|
|
47
|
+
*/
|
|
47
48
|
public override async bootstrap?(app: Bud) {
|
|
48
49
|
this.items = {} as Items
|
|
49
50
|
this.loaders = {} as Loaders
|
|
@@ -51,7 +52,7 @@ export class Build extends Service implements BudBuild {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
+
* {@link BudBuild.getItem}
|
|
55
56
|
*/
|
|
56
57
|
@bind
|
|
57
58
|
public getItem(name: `${keyof Items & string}`): Item {
|
|
@@ -64,7 +65,7 @@ export class Build extends Service implements BudBuild {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
+
* {@link BudBuild.getLoader}
|
|
68
69
|
*/
|
|
69
70
|
@bind
|
|
70
71
|
public getLoader(name: string): Loader {
|
|
@@ -77,14 +78,15 @@ export class Build extends Service implements BudBuild {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
+
* {@link BudBuild.getRule}
|
|
81
82
|
*/
|
|
82
83
|
@bind
|
|
83
84
|
public getRule<K extends `${keyof Rules & string}`>(ident: K): Rules[K] {
|
|
84
85
|
return this.rules[ident]
|
|
85
86
|
}
|
|
87
|
+
|
|
86
88
|
/**
|
|
87
|
-
*
|
|
89
|
+
* {@link BudBuild.make}
|
|
88
90
|
*/
|
|
89
91
|
@bind
|
|
90
92
|
public async make(): Promise<Configuration> {
|
|
@@ -115,7 +117,7 @@ export class Build extends Service implements BudBuild {
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
/**
|
|
118
|
-
*
|
|
120
|
+
* {@link BudBuild.makeItem}
|
|
119
121
|
*/
|
|
120
122
|
@bind
|
|
121
123
|
public makeItem(options?: Partial<Item['options']>): Item {
|
|
@@ -123,7 +125,7 @@ export class Build extends Service implements BudBuild {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
/**
|
|
126
|
-
*
|
|
128
|
+
* {@link BudBuild.makeLoader}
|
|
127
129
|
*/
|
|
128
130
|
@bind
|
|
129
131
|
public makeLoader(src?: string, definition?: string): Loader {
|
|
@@ -131,7 +133,7 @@ export class Build extends Service implements BudBuild {
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
/**
|
|
134
|
-
*
|
|
136
|
+
* {@link BudBuild.makeRule}
|
|
135
137
|
*/
|
|
136
138
|
@bind
|
|
137
139
|
public makeRule(options?: RuleOptions): Rule {
|
|
@@ -139,7 +141,7 @@ export class Build extends Service implements BudBuild {
|
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
|
142
|
-
*
|
|
144
|
+
* {@link BudBuild.setItem}
|
|
143
145
|
*/
|
|
144
146
|
@bind
|
|
145
147
|
public setItem<K extends `${keyof Items & string}`>(
|
|
@@ -161,7 +163,7 @@ export class Build extends Service implements BudBuild {
|
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
/**
|
|
164
|
-
*
|
|
166
|
+
* {@link BudBuild.setLoader}
|
|
165
167
|
*/
|
|
166
168
|
@bind
|
|
167
169
|
public setLoader<K extends `${keyof Loaders & string}`>(
|
|
@@ -181,7 +183,7 @@ export class Build extends Service implements BudBuild {
|
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
/**
|
|
184
|
-
*
|
|
186
|
+
* {@link BudBuild.setRule}
|
|
185
187
|
*/
|
|
186
188
|
@bind
|
|
187
189
|
public setRule<K extends `${keyof Rules & string}`>(
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type {Item} from '@roots/bud-build/item'
|
|
2
2
|
import type {Loader} from '@roots/bud-build/loader'
|
|
3
3
|
import type {Rule} from '@roots/bud-build/rule'
|
|
4
|
-
|
|
5
|
-
import type {Build} from './service.js'
|
|
4
|
+
import type {Build} from '@roots/bud-build/service'
|
|
6
5
|
|
|
7
6
|
declare module '@roots/bud-framework' {
|
|
8
7
|
interface Services {
|