@roots/bud-build 6.12.3 → 6.13.1
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/experiments.js +3 -1
- package/lib/config/externalsType.js +1 -1
- package/lib/config/index.d.ts +1 -1
- package/lib/config/infrastructureLogging.js +6 -6
- package/lib/config/module.js +6 -2
- package/lib/config/optimization.js +13 -3
- package/lib/config/output/index.js +1 -1
- package/lib/config/performance.js +1 -1
- package/lib/config/profile.js +1 -1
- package/lib/config/resolve.js +19 -27
- package/lib/config/resolveLoader.js +2 -2
- package/lib/config/snapshot.js +8 -3
- package/lib/config/stats.js +1 -1
- package/lib/handlers/index.d.ts +1 -1
- package/lib/handlers/items/items.d.ts +1 -5
- package/lib/handlers/items/items.js +2 -6
- package/lib/handlers/loaders/loaders.d.ts +0 -1
- package/lib/handlers/loaders/loaders.js +0 -1
- package/lib/handlers/register.js +2 -2
- package/lib/handlers/rules/csv.js +1 -1
- package/lib/handlers/rules/index.d.ts +9 -10
- package/lib/handlers/rules/index.js +9 -11
- package/lib/handlers/rules/js.js +3 -1
- package/lib/handlers/rules/json.js +3 -1
- package/lib/handlers/rules/toml.js +3 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/item/index.d.ts +11 -11
- package/lib/item/index.js +45 -32
- package/lib/loader/index.js +5 -0
- package/lib/rule/index.d.ts +62 -50
- package/lib/rule/index.js +143 -81
- package/lib/service.d.ts +30 -29
- package/lib/service.js +96 -99
- package/lib/shared/base.d.ts +6 -6
- package/lib/shared/base.js +16 -15
- package/lib/types.d.ts +12 -15
- package/lib/types.js +0 -2
- package/package.json +7 -7
- package/src/config/experiments.ts +3 -1
- package/src/config/externalsType.ts +2 -1
- package/src/config/index.test.ts +5 -5
- package/src/config/index.ts +1 -1
- package/src/config/infrastructureLogging.ts +6 -6
- package/src/config/module.ts +7 -3
- package/src/config/optimization.ts +22 -2
- package/src/config/output/chunkFilename.ts +2 -2
- package/src/config/output/index.ts +3 -2
- package/src/config/performance.ts +1 -1
- package/src/config/profile.ts +2 -2
- package/src/config/resolve.ts +27 -41
- package/src/config/resolveLoader.ts +3 -3
- package/src/config/snapshot.ts +21 -4
- package/src/config/stats.ts +1 -1
- package/src/handlers/index.ts +2 -1
- package/src/handlers/items/items.ts +3 -8
- package/src/handlers/loaders/loaders.ts +1 -5
- package/src/handlers/register.ts +3 -2
- package/src/handlers/rules/csv.test.ts +1 -1
- package/src/handlers/rules/csv.ts +1 -1
- package/src/handlers/rules/index.ts +9 -11
- package/src/handlers/rules/js.ts +3 -1
- package/src/handlers/rules/json.ts +3 -1
- package/src/handlers/rules/svg.inline.test.ts +1 -1
- package/src/handlers/rules/toml.test.ts +1 -1
- package/src/handlers/rules/toml.ts +3 -1
- package/src/index.ts +1 -2
- package/src/item/index.ts +29 -28
- package/src/rule/index.test.ts +1 -1
- package/src/rule/index.ts +108 -79
- package/src/service.ts +80 -77
- package/src/shared/base.ts +12 -11
- package/src/types.ts +12 -18
- package/lib/handlers/rules/xml.d.ts +0 -2
- package/lib/handlers/rules/xml.js +0 -4
- package/src/handlers/rules/xml.test.ts +0 -30
- package/src/handlers/rules/xml.ts +0 -7
package/src/config/resolve.ts
CHANGED
|
@@ -1,45 +1,31 @@
|
|
|
1
|
-
import type {Bud} from '@roots/bud-framework'
|
|
2
|
-
|
|
3
1
|
import type {Factory} from './index.js'
|
|
4
2
|
|
|
5
3
|
export const resolve: Factory<`resolve`> = async bud => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await bud.hooks.filterAsync(`build.resolve.alias`, {
|
|
18
|
-
'@src': bud.path(`@src`),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const getExtensions = (bud: Bud) =>
|
|
22
|
-
Array.from(
|
|
23
|
-
bud.hooks.filter(
|
|
24
|
-
`build.resolve.extensions`,
|
|
25
|
-
new Set([
|
|
26
|
-
`.mjs`,
|
|
27
|
-
`.js`,
|
|
28
|
-
`.jsx`,
|
|
29
|
-
`.css`,
|
|
30
|
-
`.json`,
|
|
31
|
-
`.wasm`,
|
|
32
|
-
`.yml`,
|
|
33
|
-
`.yaml`,
|
|
34
|
-
`.xml`,
|
|
35
|
-
`.toml`,
|
|
36
|
-
`.csv`,
|
|
37
|
-
]),
|
|
4
|
+
return await bud.hooks.filterAsync(`build.resolve`, {
|
|
5
|
+
alias: {
|
|
6
|
+
[`@src`]: bud.path(`@src`),
|
|
7
|
+
...(await bud.hooks.filterAsync(`build.resolve.alias`, {})),
|
|
8
|
+
},
|
|
9
|
+
extensionAlias: await bud.hooks.filterAsync(
|
|
10
|
+
`build.resolve.extensionAlias`,
|
|
11
|
+
{
|
|
12
|
+
[`.js`]: [`.ts`, `.tsx`, `.js`],
|
|
13
|
+
[`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
|
|
14
|
+
},
|
|
38
15
|
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
extensions: Array.from(
|
|
17
|
+
bud.hooks.filter(
|
|
18
|
+
`build.resolve.extensions`,
|
|
19
|
+
new Set([`.js`, `.mjs`, `.jsx`, `.css`]),
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
|
|
23
|
+
bud.hooks.filter(`location.@src`),
|
|
24
|
+
bud.hooks.filter(`location.@modules`),
|
|
25
|
+
]),
|
|
26
|
+
/**
|
|
27
|
+
* Leave `undefined` to use webpack default (true in dev, false in production)
|
|
28
|
+
*/
|
|
29
|
+
unsafeCache: bud.hooks.filter(`build.module.unsafeCache`, undefined),
|
|
30
|
+
})
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {Factory} from './index.js'
|
|
2
2
|
|
|
3
|
-
export const resolveLoader: Factory<`resolveLoader`> = async
|
|
4
|
-
|
|
5
|
-
alias: {},
|
|
3
|
+
export const resolveLoader: Factory<`resolveLoader`> = async ({hooks}) =>
|
|
4
|
+
hooks.filter(`build.resolveLoader`, {
|
|
5
|
+
alias: hooks.filter(`build.resolveLoader.alias`, {}),
|
|
6
6
|
})
|
package/src/config/snapshot.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import type {Factory} from './index.js'
|
|
2
2
|
|
|
3
|
-
export const snapshot: Factory<`snapshot`> = async
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const snapshot: Factory<`snapshot`> = async ({env, hooks, path}) =>
|
|
4
|
+
hooks.filter(`build.snapshot`, {
|
|
5
|
+
buildDependencies: hooks.filter(
|
|
6
|
+
`build.snapshot.buildDependencies`,
|
|
7
|
+
env.isTrue(`CI`) ? {hash: true} : {timestamp: true},
|
|
8
|
+
),
|
|
9
|
+
immutablePaths: hooks.filter(`build.snapshot.immutablePaths`, []),
|
|
10
|
+
managedPaths: hooks.filter(`build.snapshot.managedPaths`, [
|
|
11
|
+
...new Set([path(`@modules`)]),
|
|
7
12
|
]),
|
|
13
|
+
module: hooks.filter(
|
|
14
|
+
`build.snapshot.module`,
|
|
15
|
+
env.isTrue(`CI`) ? {hash: true} : {timestamp: true},
|
|
16
|
+
),
|
|
17
|
+
resolve: hooks.filter(
|
|
18
|
+
`build.snapshot.resolve`,
|
|
19
|
+
env.isTrue(`CI`) ? {hash: true} : {timestamp: true},
|
|
20
|
+
),
|
|
21
|
+
resolveBuildDependencies: hooks.filter(
|
|
22
|
+
`build.snapshot.resolveBuildDependencies`,
|
|
23
|
+
env.isTrue(`CI`) ? {hash: true} : {timestamp: true},
|
|
24
|
+
),
|
|
8
25
|
})
|
package/src/config/stats.ts
CHANGED
package/src/handlers/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
2
|
|
|
3
3
|
import type {Rule} from '../rule/index.js'
|
|
4
|
+
|
|
4
5
|
import * as items from './items/items.js'
|
|
5
6
|
import * as loaders from './loaders/loaders.js'
|
|
6
7
|
import {register} from './register.js'
|
|
@@ -8,10 +9,10 @@ import {rules} from './rules/index.js'
|
|
|
8
9
|
|
|
9
10
|
export interface Props {
|
|
10
11
|
filter: Bud[`hooks`][`filter`]
|
|
12
|
+
isProduction: Bud[`isProduction`]
|
|
11
13
|
makeItem: Bud[`build`][`makeItem`]
|
|
12
14
|
makeLoader: Bud[`build`][`makeLoader`]
|
|
13
15
|
makeRule: Bud[`build`][`makeRule`]
|
|
14
|
-
isProduction: Bud[`isProduction`]
|
|
15
16
|
path: Bud[`path`]
|
|
16
17
|
resolve: Bud[`module`][`resolve`]
|
|
17
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {Item} from '@roots/bud-framework/services/build'
|
|
2
|
+
|
|
2
3
|
import isBoolean from '@roots/bud-support/lodash/isBoolean'
|
|
3
4
|
|
|
4
5
|
import type {Factory} from '../index.js'
|
|
@@ -65,7 +66,7 @@ export const minicss: Factory<Item> = async ({makeItem}) =>
|
|
|
65
66
|
.setLoader(`minicss`)
|
|
66
67
|
.setIdent(`minicss`)
|
|
67
68
|
.setOptions(app => ({
|
|
68
|
-
publicPath: app.
|
|
69
|
+
publicPath: app.publicPath(),
|
|
69
70
|
}))
|
|
70
71
|
|
|
71
72
|
/**
|
|
@@ -75,17 +76,11 @@ export const raw: Factory<Item> = async ({makeItem}) =>
|
|
|
75
76
|
makeItem().setLoader(`raw`).setIdent(`raw`)
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
+
* file-loader
|
|
79
80
|
*/
|
|
80
81
|
export const file: Factory<Item> = async ({makeItem}) =>
|
|
81
82
|
makeItem().setLoader(`file`).setIdent(`file`)
|
|
82
83
|
|
|
83
|
-
/**
|
|
84
|
-
* Xml loader
|
|
85
|
-
*/
|
|
86
|
-
export const xml: Factory<Item> = async ({makeItem}) =>
|
|
87
|
-
makeItem().setLoader(`xml`).setIdent(`xml`)
|
|
88
|
-
|
|
89
84
|
/**
|
|
90
85
|
* Yml loader
|
|
91
86
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {Loader} from '@roots/bud-framework/services/build'
|
|
2
|
+
|
|
2
3
|
import * as MiniCss from '@roots/bud-support/mini-css-extract-plugin'
|
|
3
4
|
|
|
4
5
|
import type {Factory} from '../index.js'
|
|
@@ -36,11 +37,6 @@ export const style: Factory<Loader> = async ({makeLoader, resolve}) =>
|
|
|
36
37
|
await resolve(`@roots/bud-support/style-loader`, import.meta.url),
|
|
37
38
|
)
|
|
38
39
|
|
|
39
|
-
export const xml: Factory<Loader> = async ({makeLoader, resolve}) =>
|
|
40
|
-
makeLoader(
|
|
41
|
-
await resolve(`@roots/bud-support/xml-loader`, import.meta.url),
|
|
42
|
-
)
|
|
43
|
-
|
|
44
40
|
export const yml: Factory<Loader> = async ({makeLoader, resolve}) =>
|
|
45
41
|
makeLoader(
|
|
46
42
|
await resolve(`@roots/bud-support/yml-loader`, import.meta.url),
|
package/src/handlers/register.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
2
|
|
|
3
3
|
import type {Factory} from './index.js'
|
|
4
|
+
|
|
4
5
|
import * as items from './items/items.js'
|
|
5
6
|
import * as loaders from './loaders/loaders.js'
|
|
6
7
|
import {rules} from './rules/index.js'
|
|
@@ -34,16 +35,16 @@ export async function register(bud: Bud) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export const makeRegister: makeRegister =
|
|
37
|
-
({build, hooks, isProduction,
|
|
38
|
+
({build, hooks, isProduction, module: {resolve}, path}, setRule) =>
|
|
38
39
|
async ([key, factory]) =>
|
|
39
40
|
setRule(
|
|
40
41
|
key,
|
|
41
42
|
await factory({
|
|
42
43
|
filter: hooks.filter,
|
|
44
|
+
isProduction,
|
|
43
45
|
makeItem: build.makeItem,
|
|
44
46
|
makeLoader: build.makeLoader,
|
|
45
47
|
makeRule: build.makeRule,
|
|
46
|
-
isProduction,
|
|
47
48
|
path,
|
|
48
49
|
resolve,
|
|
49
50
|
}),
|
|
@@ -12,24 +12,22 @@ import {inlineSvg} from './svg.inline.js'
|
|
|
12
12
|
import {svg} from './svg.js'
|
|
13
13
|
import {toml} from './toml.js'
|
|
14
14
|
import {webp} from './webp.js'
|
|
15
|
-
import {xml} from './xml.js'
|
|
16
15
|
import {yml} from './yml.js'
|
|
17
16
|
|
|
18
17
|
export const rules = {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
css,
|
|
19
|
+
cssModule,
|
|
21
20
|
csv,
|
|
22
|
-
yml,
|
|
23
|
-
html,
|
|
24
|
-
json,
|
|
25
21
|
font,
|
|
26
|
-
|
|
27
|
-
webp,
|
|
22
|
+
html,
|
|
28
23
|
image,
|
|
29
24
|
inlineFont,
|
|
30
|
-
inlineSvg,
|
|
31
25
|
inlineImage,
|
|
32
|
-
|
|
33
|
-
css,
|
|
26
|
+
inlineSvg,
|
|
34
27
|
js,
|
|
28
|
+
json,
|
|
29
|
+
svg,
|
|
30
|
+
toml,
|
|
31
|
+
webp,
|
|
32
|
+
yml,
|
|
35
33
|
}
|
package/src/handlers/rules/js.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {inlineSvg, dataUrl} from './svg.inline.js'
|
|
|
4
4
|
|
|
5
5
|
describe(`svg-inline`, () => {
|
|
6
6
|
it(`should return a rule`, async () => {
|
|
7
|
-
const bud = await import(`@repo/test-kit
|
|
7
|
+
const bud = await import(`@repo/test-kit`).then(
|
|
8
8
|
async ({factory}) => await factory(),
|
|
9
9
|
)
|
|
10
10
|
const result = await inlineSvg({
|
package/src/index.ts
CHANGED
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
* @see https://github.com/roots/bud
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import './types.js'
|
|
12
|
-
|
|
13
11
|
import {Item} from './item/index.js'
|
|
14
12
|
import {Loader} from './loader/index.js'
|
|
15
13
|
import {Rule} from './rule/index.js'
|
|
16
14
|
import {Build} from './service.js'
|
|
15
|
+
import './types.js'
|
|
17
16
|
|
|
18
17
|
export default Build
|
|
19
18
|
|
package/src/item/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {Bud, Loaders} from '@roots/bud-framework'
|
|
2
2
|
import type * as Build from '@roots/bud-framework/services/build'
|
|
3
|
+
|
|
3
4
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
4
5
|
import isString from '@roots/bud-support/lodash/isString'
|
|
5
6
|
import {basename} from 'path'
|
|
@@ -21,7 +22,7 @@ class Item extends Base implements Build.Item {
|
|
|
21
22
|
/**
|
|
22
23
|
* Loader
|
|
23
24
|
*/
|
|
24
|
-
public loader:
|
|
25
|
+
public loader: `${keyof Loaders & string}` | Loader
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Loader options
|
|
@@ -35,7 +36,7 @@ class Item extends Base implements Build.Item {
|
|
|
35
36
|
public override _app: () => Bud,
|
|
36
37
|
constructorParams?: {
|
|
37
38
|
ident?: string
|
|
38
|
-
loader?:
|
|
39
|
+
loader?: `${keyof Loaders & string}` | Loader
|
|
39
40
|
options?: Item['options']
|
|
40
41
|
},
|
|
41
42
|
) {
|
|
@@ -61,12 +62,6 @@ class Item extends Base implements Build.Item {
|
|
|
61
62
|
return this.ident
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
@bind
|
|
65
|
-
public setIdent(ident: Build.Item['ident']): this {
|
|
66
|
-
this.ident = ident
|
|
67
|
-
return this
|
|
68
|
-
}
|
|
69
|
-
|
|
70
65
|
/**
|
|
71
66
|
* Get rule set item loader
|
|
72
67
|
*/
|
|
@@ -78,45 +73,51 @@ class Item extends Base implements Build.Item {
|
|
|
78
73
|
}
|
|
79
74
|
|
|
80
75
|
/**
|
|
81
|
-
*
|
|
76
|
+
* Get rule set item options
|
|
82
77
|
*/
|
|
83
78
|
@bind
|
|
84
|
-
public
|
|
85
|
-
this.
|
|
79
|
+
public getOptions(): Item['options'] {
|
|
80
|
+
return this.unwrap(this.options)
|
|
81
|
+
}
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Merge rule set item options
|
|
85
|
+
*/
|
|
86
|
+
@bind
|
|
87
|
+
public mergeOptions(options: Build.Item.Options): this {
|
|
88
|
+
this.setOptions({
|
|
89
|
+
...(this.getOptions() ?? {}),
|
|
90
|
+
...options,
|
|
91
|
+
})
|
|
89
92
|
|
|
90
93
|
return this
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
/**
|
|
94
|
-
* Get rule set item options
|
|
95
|
-
*/
|
|
96
96
|
@bind
|
|
97
|
-
public
|
|
98
|
-
|
|
97
|
+
public setIdent(ident: Build.Item['ident']): this {
|
|
98
|
+
this.ident = ident
|
|
99
|
+
return this
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
|
-
* Set rule set item
|
|
103
|
+
* Set rule set item loader
|
|
103
104
|
*/
|
|
104
105
|
@bind
|
|
105
|
-
public
|
|
106
|
-
this.
|
|
106
|
+
public setLoader(loader: `${keyof Loaders & string}` | Loader): this {
|
|
107
|
+
this.loader = loader
|
|
108
|
+
|
|
109
|
+
if (!this.ident)
|
|
110
|
+
this.setIdent(basename(isString(loader) ? loader : loader.getSrc()))
|
|
111
|
+
|
|
107
112
|
return this
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
/**
|
|
111
|
-
*
|
|
116
|
+
* Set rule set item options
|
|
112
117
|
*/
|
|
113
118
|
@bind
|
|
114
|
-
public
|
|
115
|
-
this.
|
|
116
|
-
...(this.getOptions() ?? {}),
|
|
117
|
-
...options,
|
|
118
|
-
})
|
|
119
|
-
|
|
119
|
+
public setOptions(options: Item['options']) {
|
|
120
|
+
this.options = options
|
|
120
121
|
return this
|
|
121
122
|
}
|
|
122
123
|
|
package/src/rule/index.test.ts
CHANGED