@roots/bud-build 0.0.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/LICENSE.md +19 -0
- package/README.md +120 -0
- package/docs/exports.md +13 -0
- package/docs/rules.md +32 -0
- package/lib/config/bail.d.ts +3 -0
- package/lib/config/bail.d.ts.map +1 -0
- package/lib/config/bail.js +2 -0
- package/lib/config/bail.js.map +1 -0
- package/lib/config/cache.d.ts +3 -0
- package/lib/config/cache.d.ts.map +1 -0
- package/lib/config/cache.js +2 -0
- package/lib/config/cache.js.map +1 -0
- package/lib/config/context.d.ts +3 -0
- package/lib/config/context.d.ts.map +1 -0
- package/lib/config/context.js +2 -0
- package/lib/config/context.js.map +1 -0
- package/lib/config/dependencies.d.ts +3 -0
- package/lib/config/dependencies.d.ts.map +1 -0
- package/lib/config/dependencies.js +5 -0
- package/lib/config/dependencies.js.map +1 -0
- package/lib/config/devtool.d.ts +3 -0
- package/lib/config/devtool.d.ts.map +1 -0
- package/lib/config/devtool.js +2 -0
- package/lib/config/devtool.js.map +1 -0
- package/lib/config/entry.d.ts +3 -0
- package/lib/config/entry.d.ts.map +1 -0
- package/lib/config/entry.js +2 -0
- package/lib/config/entry.js.map +1 -0
- package/lib/config/experiments.d.ts +3 -0
- package/lib/config/experiments.d.ts.map +1 -0
- package/lib/config/experiments.js +2 -0
- package/lib/config/experiments.js.map +1 -0
- package/lib/config/externals.d.ts +3 -0
- package/lib/config/externals.d.ts.map +1 -0
- package/lib/config/externals.js +2 -0
- package/lib/config/externals.js.map +1 -0
- package/lib/config/externalsType.d.ts +3 -0
- package/lib/config/externalsType.d.ts.map +1 -0
- package/lib/config/externalsType.js +2 -0
- package/lib/config/externalsType.js.map +1 -0
- package/lib/config/index.d.ts +35 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/config/index.js +27 -0
- package/lib/config/index.js.map +1 -0
- package/lib/config/infrastructureLogging.d.ts +3 -0
- package/lib/config/infrastructureLogging.d.ts.map +1 -0
- package/lib/config/infrastructureLogging.js +14 -0
- package/lib/config/infrastructureLogging.js.map +1 -0
- package/lib/config/loader.d.ts +3 -0
- package/lib/config/loader.d.ts.map +1 -0
- package/lib/config/loader.js +2 -0
- package/lib/config/loader.js.map +1 -0
- package/lib/config/mode.d.ts +3 -0
- package/lib/config/mode.d.ts.map +1 -0
- package/lib/config/mode.js +2 -0
- package/lib/config/mode.js.map +1 -0
- package/lib/config/module.d.ts +3 -0
- package/lib/config/module.d.ts.map +1 -0
- package/lib/config/module.js +23 -0
- package/lib/config/module.js.map +1 -0
- package/lib/config/name.d.ts +3 -0
- package/lib/config/name.d.ts.map +1 -0
- package/lib/config/name.js +2 -0
- package/lib/config/name.js.map +1 -0
- package/lib/config/node.d.ts +3 -0
- package/lib/config/node.d.ts.map +1 -0
- package/lib/config/node.js +2 -0
- package/lib/config/node.js.map +1 -0
- package/lib/config/optimization.d.ts +3 -0
- package/lib/config/optimization.d.ts.map +1 -0
- package/lib/config/optimization.js +11 -0
- package/lib/config/optimization.js.map +1 -0
- package/lib/config/output/assetModuleFilename.d.ts +8 -0
- package/lib/config/output/assetModuleFilename.d.ts.map +1 -0
- package/lib/config/output/assetModuleFilename.js +2 -0
- package/lib/config/output/assetModuleFilename.js.map +1 -0
- package/lib/config/output/chunkFilename.d.ts +8 -0
- package/lib/config/output/chunkFilename.d.ts.map +1 -0
- package/lib/config/output/chunkFilename.js +4 -0
- package/lib/config/output/chunkFilename.js.map +1 -0
- package/lib/config/output/filename.d.ts +8 -0
- package/lib/config/output/filename.d.ts.map +1 -0
- package/lib/config/output/filename.js +3 -0
- package/lib/config/output/filename.js.map +1 -0
- package/lib/config/output/index.d.ts +3 -0
- package/lib/config/output/index.d.ts.map +1 -0
- package/lib/config/output/index.js +18 -0
- package/lib/config/output/index.js.map +1 -0
- package/lib/config/parallelism.d.ts +3 -0
- package/lib/config/parallelism.d.ts.map +1 -0
- package/lib/config/parallelism.js +3 -0
- package/lib/config/parallelism.js.map +1 -0
- package/lib/config/performance.d.ts +3 -0
- package/lib/config/performance.d.ts.map +1 -0
- package/lib/config/performance.js +2 -0
- package/lib/config/performance.js.map +1 -0
- package/lib/config/plugins.d.ts +3 -0
- package/lib/config/plugins.d.ts.map +1 -0
- package/lib/config/plugins.js +2 -0
- package/lib/config/plugins.js.map +1 -0
- package/lib/config/profile.d.ts +3 -0
- package/lib/config/profile.d.ts.map +1 -0
- package/lib/config/profile.js +2 -0
- package/lib/config/profile.js.map +1 -0
- package/lib/config/recordsPath.d.ts +3 -0
- package/lib/config/recordsPath.d.ts.map +1 -0
- package/lib/config/recordsPath.js +2 -0
- package/lib/config/recordsPath.js.map +1 -0
- package/lib/config/resolve.d.ts +3 -0
- package/lib/config/resolve.d.ts.map +1 -0
- package/lib/config/resolve.js +30 -0
- package/lib/config/resolve.js.map +1 -0
- package/lib/config/stats.d.ts +3 -0
- package/lib/config/stats.d.ts.map +1 -0
- package/lib/config/stats.js +17 -0
- package/lib/config/stats.js.map +1 -0
- package/lib/config/target.d.ts +3 -0
- package/lib/config/target.d.ts.map +1 -0
- package/lib/config/target.js +4 -0
- package/lib/config/target.js.map +1 -0
- package/lib/handlers/index.d.ts +19 -0
- package/lib/handlers/index.d.ts.map +1 -0
- package/lib/handlers/index.js +6 -0
- package/lib/handlers/index.js.map +1 -0
- package/lib/handlers/items/items.d.ts +47 -0
- package/lib/handlers/items/items.d.ts.map +1 -0
- package/lib/handlers/items/items.js +69 -0
- package/lib/handlers/items/items.js.map +1 -0
- package/lib/handlers/loaders/loaders.d.ts +12 -0
- package/lib/handlers/loaders/loaders.d.ts.map +1 -0
- package/lib/handlers/loaders/loaders.js +11 -0
- package/lib/handlers/loaders/loaders.js.map +1 -0
- package/lib/handlers/register.d.ts +14 -0
- package/lib/handlers/register.d.ts.map +1 -0
- package/lib/handlers/register.js +26 -0
- package/lib/handlers/register.js.map +1 -0
- package/lib/handlers/rules/css.d.ts +3 -0
- package/lib/handlers/rules/css.d.ts.map +1 -0
- package/lib/handlers/rules/css.js +5 -0
- package/lib/handlers/rules/css.js.map +1 -0
- package/lib/handlers/rules/css.module.d.ts +3 -0
- package/lib/handlers/rules/css.module.d.ts.map +1 -0
- package/lib/handlers/rules/css.module.js +5 -0
- package/lib/handlers/rules/css.module.js.map +1 -0
- package/lib/handlers/rules/csv.d.ts +3 -0
- package/lib/handlers/rules/csv.d.ts.map +1 -0
- package/lib/handlers/rules/csv.js +5 -0
- package/lib/handlers/rules/csv.js.map +1 -0
- package/lib/handlers/rules/font.d.ts +3 -0
- package/lib/handlers/rules/font.d.ts.map +1 -0
- package/lib/handlers/rules/font.inline.d.ts +3 -0
- package/lib/handlers/rules/font.inline.d.ts.map +1 -0
- package/lib/handlers/rules/font.inline.js +6 -0
- package/lib/handlers/rules/font.inline.js.map +1 -0
- package/lib/handlers/rules/font.js +5 -0
- package/lib/handlers/rules/font.js.map +1 -0
- package/lib/handlers/rules/html.d.ts +3 -0
- package/lib/handlers/rules/html.d.ts.map +1 -0
- package/lib/handlers/rules/html.js +5 -0
- package/lib/handlers/rules/html.js.map +1 -0
- package/lib/handlers/rules/image.d.ts +3 -0
- package/lib/handlers/rules/image.d.ts.map +1 -0
- package/lib/handlers/rules/image.inline.d.ts +3 -0
- package/lib/handlers/rules/image.inline.d.ts.map +1 -0
- package/lib/handlers/rules/image.inline.js +6 -0
- package/lib/handlers/rules/image.inline.js.map +1 -0
- package/lib/handlers/rules/image.js +5 -0
- package/lib/handlers/rules/image.js.map +1 -0
- package/lib/handlers/rules/index.d.ts +19 -0
- package/lib/handlers/rules/index.d.ts.map +1 -0
- package/lib/handlers/rules/index.js +35 -0
- package/lib/handlers/rules/index.js.map +1 -0
- package/lib/handlers/rules/js.d.ts +3 -0
- package/lib/handlers/rules/js.d.ts.map +1 -0
- package/lib/handlers/rules/js.js +5 -0
- package/lib/handlers/rules/js.js.map +1 -0
- package/lib/handlers/rules/json.d.ts +3 -0
- package/lib/handlers/rules/json.d.ts.map +1 -0
- package/lib/handlers/rules/json.js +7 -0
- package/lib/handlers/rules/json.js.map +1 -0
- package/lib/handlers/rules/svg.d.ts +3 -0
- package/lib/handlers/rules/svg.d.ts.map +1 -0
- package/lib/handlers/rules/svg.inline.d.ts +5 -0
- package/lib/handlers/rules/svg.inline.d.ts.map +1 -0
- package/lib/handlers/rules/svg.inline.js +9 -0
- package/lib/handlers/rules/svg.inline.js.map +1 -0
- package/lib/handlers/rules/svg.js +5 -0
- package/lib/handlers/rules/svg.js.map +1 -0
- package/lib/handlers/rules/toml.d.ts +3 -0
- package/lib/handlers/rules/toml.d.ts.map +1 -0
- package/lib/handlers/rules/toml.js +7 -0
- package/lib/handlers/rules/toml.js.map +1 -0
- package/lib/handlers/rules/webp.d.ts +3 -0
- package/lib/handlers/rules/webp.d.ts.map +1 -0
- package/lib/handlers/rules/webp.js +5 -0
- package/lib/handlers/rules/webp.js.map +1 -0
- package/lib/handlers/rules/xml.d.ts +3 -0
- package/lib/handlers/rules/xml.d.ts.map +1 -0
- package/lib/handlers/rules/xml.js +5 -0
- package/lib/handlers/rules/xml.js.map +1 -0
- package/lib/handlers/rules/yml.d.ts +3 -0
- package/lib/handlers/rules/yml.d.ts.map +1 -0
- package/lib/handlers/rules/yml.js +5 -0
- package/lib/handlers/rules/yml.js.map +1 -0
- package/lib/helpers/isMjs.d.ts +3 -0
- package/lib/helpers/isMjs.d.ts.map +1 -0
- package/lib/helpers/isMjs.js +2 -0
- package/lib/helpers/isMjs.js.map +1 -0
- package/lib/helpers/scriptExtension.d.ts +3 -0
- package/lib/helpers/scriptExtension.d.ts.map +1 -0
- package/lib/helpers/scriptExtension.js +5 -0
- package/lib/helpers/scriptExtension.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -0
- package/lib/item/index.d.ts +84 -0
- package/lib/item/index.d.ts.map +1 -0
- package/lib/item/index.js +165 -0
- package/lib/item/index.js.map +1 -0
- package/lib/loader/index.d.ts +26 -0
- package/lib/loader/index.d.ts.map +1 -0
- package/lib/loader/index.js +28 -0
- package/lib/loader/index.js.map +1 -0
- package/lib/rule/index.d.ts +118 -0
- package/lib/rule/index.d.ts.map +1 -0
- package/lib/rule/index.js +261 -0
- package/lib/rule/index.js.map +1 -0
- package/lib/service.d.ts +84 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +212 -0
- package/lib/service.js.map +1 -0
- package/lib/shared/base.d.ts +20 -0
- package/lib/shared/base.d.ts.map +1 -0
- package/lib/shared/base.js +43 -0
- package/lib/shared/base.js.map +1 -0
- package/lib/types.d.ts +52 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +4 -0
- package/lib/types.js.map +1 -0
- package/package.json +97 -0
- package/src/config/bail.ts +4 -0
- package/src/config/cache.ts +4 -0
- package/src/config/context.ts +3 -0
- package/src/config/dependencies.ts +11 -0
- package/src/config/devtool.ts +4 -0
- package/src/config/entry.ts +4 -0
- package/src/config/experiments.ts +4 -0
- package/src/config/externals.ts +4 -0
- package/src/config/externalsType.ts +3 -0
- package/src/config/index.test.ts +129 -0
- package/src/config/index.ts +67 -0
- package/src/config/infrastructureLogging.ts +18 -0
- package/src/config/loader.ts +4 -0
- package/src/config/mode.ts +4 -0
- package/src/config/module.ts +45 -0
- package/src/config/name.ts +4 -0
- package/src/config/node.ts +4 -0
- package/src/config/optimization.ts +20 -0
- package/src/config/output/assetModuleFilename.ts +9 -0
- package/src/config/output/chunkFilename.ts +18 -0
- package/src/config/output/filename.ts +14 -0
- package/src/config/output/index.ts +28 -0
- package/src/config/parallelism.ts +6 -0
- package/src/config/performance.ts +4 -0
- package/src/config/plugins.ts +4 -0
- package/src/config/profile.ts +4 -0
- package/src/config/recordsPath.ts +7 -0
- package/src/config/resolve.ts +45 -0
- package/src/config/stats.ts +22 -0
- package/src/config/target.ts +9 -0
- package/src/handlers/index.ts +22 -0
- package/src/handlers/items/items.ts +93 -0
- package/src/handlers/loaders/loaders.ts +31 -0
- package/src/handlers/register.ts +47 -0
- package/src/handlers/rules/css.module.ts +7 -0
- package/src/handlers/rules/css.ts +7 -0
- package/src/handlers/rules/csv.test.ts +28 -0
- package/src/handlers/rules/csv.ts +7 -0
- package/src/handlers/rules/font.inline.ts +8 -0
- package/src/handlers/rules/font.ts +7 -0
- package/src/handlers/rules/html.ts +7 -0
- package/src/handlers/rules/image.inline.ts +8 -0
- package/src/handlers/rules/image.ts +7 -0
- package/src/handlers/rules/index.ts +35 -0
- package/src/handlers/rules/js.ts +7 -0
- package/src/handlers/rules/json.ts +10 -0
- package/src/handlers/rules/svg.inline.test.ts +30 -0
- package/src/handlers/rules/svg.inline.ts +13 -0
- package/src/handlers/rules/svg.ts +7 -0
- package/src/handlers/rules/toml.test.ts +22 -0
- package/src/handlers/rules/toml.ts +10 -0
- package/src/handlers/rules/webp.ts +7 -0
- package/src/handlers/rules/xml.test.ts +27 -0
- package/src/handlers/rules/xml.ts +7 -0
- package/src/handlers/rules/yml.ts +7 -0
- package/src/helpers/isMjs.ts +4 -0
- package/src/helpers/scriptExtension.ts +11 -0
- package/src/index.ts +17 -0
- package/src/item/index.ts +179 -0
- package/src/loader/index.ts +38 -0
- package/src/rule/index.test.ts +88 -0
- package/src/rule/index.ts +257 -0
- package/src/service.ts +204 -0
- package/src/shared/base.ts +37 -0
- package/src/types.ts +57 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {Bud, factory} from '@repo/test-kit/bud'
|
|
2
|
+
import {beforeEach, describe, expect, it} from 'vitest'
|
|
3
|
+
|
|
4
|
+
import {Build} from '../service.js'
|
|
5
|
+
|
|
6
|
+
describe(`bud.build.config`, function () {
|
|
7
|
+
let bud: Bud
|
|
8
|
+
let build: Build
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
bud = await factory()
|
|
12
|
+
build = new Build(() => bud)
|
|
13
|
+
await build.register(bud)
|
|
14
|
+
await build.make()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it(`should not include deprecated properties`, async () => {
|
|
18
|
+
expect(build.config.hasOwnProperty(`devServer`)).toBe(false)
|
|
19
|
+
expect(build.config.hasOwnProperty(`unsafeCache`)).toBe(false)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it(`should have expected bail default`, async () => {
|
|
23
|
+
expect(build.config.bail).toEqual(true)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it(`should have expected cache default`, async () => {
|
|
27
|
+
const {cache}: any = build.config
|
|
28
|
+
|
|
29
|
+
expect(cache.type).toStrictEqual(`filesystem`)
|
|
30
|
+
|
|
31
|
+
expect(cache.cacheDirectory).toStrictEqual(
|
|
32
|
+
expect.stringContaining(`.budfiles`),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect(cache.version).toStrictEqual(expect.any(String))
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it(`should have expected context default`, async () => {
|
|
39
|
+
expect(build.config.context).toEqual(bud.path(`@src`))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it(`should have expected devtool default`, async () => {
|
|
43
|
+
expect(build.config.devtool).toBe(false)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it(`should have expected entry default`, async () => {
|
|
47
|
+
expect(build.config.entry).toEqual({main: {import: [`index`]}})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it(`should have expected mode default`, async () => {
|
|
51
|
+
expect(build.config.mode).toEqual(`production`)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it(`should have expected name default`, async () => {
|
|
55
|
+
expect(build.config.name).toEqual(`@tests/project`)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it(`should have expected node default`, async () => {
|
|
59
|
+
expect(build.config.node).toEqual(false)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it(`should have expected optimization.minimize default`, async () => {
|
|
63
|
+
expect(build.config.optimization?.minimize).toEqual(true)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it(`should have expected optimization.emitOnErrors default`, async () => {
|
|
67
|
+
expect((build.config.optimization as any).emitOnErrors).toEqual(false)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it(`should have expected optimization.runtimeChunk default`, async () => {
|
|
71
|
+
expect(build.config.optimization?.runtimeChunk).toBe(false)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it(`should have expected profile default`, async () => {
|
|
75
|
+
expect(build.config.profile).toBeUndefined()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it(`should have expected resolve.alias default`, async () => {
|
|
79
|
+
expect(build.config.resolve?.alias).toEqual({
|
|
80
|
+
'@src': bud.path(`@src`),
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it(`should have expected resolve.extensions default`, async () => {
|
|
85
|
+
expect(build.config.resolve?.extensions?.sort()).toEqual(
|
|
86
|
+
expect.arrayContaining([
|
|
87
|
+
`.css`,
|
|
88
|
+
`.js`,
|
|
89
|
+
`.json`,
|
|
90
|
+
`.jsx`,
|
|
91
|
+
`.mjs`,
|
|
92
|
+
`.wasm`,
|
|
93
|
+
`.yml`,
|
|
94
|
+
]),
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it(`should have expected target default`, async () => {
|
|
99
|
+
expect(build.config.target).toMatch(/browserslist.*/)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it(`should have expected watch default`, async () => {
|
|
103
|
+
expect(build.config.watch).toBeUndefined()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it(`should have expected watchOptions default`, async () => {
|
|
107
|
+
expect(build.config.watchOptions).toBeUndefined()
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it(`should have expected plugins`, async () => {
|
|
111
|
+
const plugins = build.config.plugins
|
|
112
|
+
?.map(plugin => plugin.constructor.name)
|
|
113
|
+
.sort()
|
|
114
|
+
|
|
115
|
+
expect(plugins).toContain(`CleanWebpackPlugin`)
|
|
116
|
+
expect(plugins).toContain(`FixStyleOnlyEntrypoints`)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it(`should have expected default requireEnsure rule`, async () => {
|
|
120
|
+
if (!build.config.module?.rules?.length) throw new Error()
|
|
121
|
+
expect(build.config.module.rules[0]).toEqual(
|
|
122
|
+
expect.objectContaining({
|
|
123
|
+
parser: {
|
|
124
|
+
requireEnsure: false,
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
import type {Configuration} from '@roots/bud-support/webpack'
|
|
3
|
+
|
|
4
|
+
import {bail} from './bail.js'
|
|
5
|
+
import {cache} from './cache.js'
|
|
6
|
+
import {context} from './context.js'
|
|
7
|
+
import {dependencies} from './dependencies.js'
|
|
8
|
+
import {devtool} from './devtool.js'
|
|
9
|
+
import {entry} from './entry.js'
|
|
10
|
+
import {experiments} from './experiments.js'
|
|
11
|
+
import {externals} from './externals.js'
|
|
12
|
+
import {externalsType} from './externalsType.js'
|
|
13
|
+
import {infrastructureLogging} from './infrastructureLogging.js'
|
|
14
|
+
import {loader} from './loader.js'
|
|
15
|
+
import {mode} from './mode.js'
|
|
16
|
+
import {module} from './module.js'
|
|
17
|
+
import {name} from './name.js'
|
|
18
|
+
import {node} from './node.js'
|
|
19
|
+
import {optimization} from './optimization.js'
|
|
20
|
+
import {output} from './output/index.js'
|
|
21
|
+
import {parallelism} from './parallelism.js'
|
|
22
|
+
import {performance} from './performance.js'
|
|
23
|
+
import {plugins} from './plugins.js'
|
|
24
|
+
import {profile} from './profile.js'
|
|
25
|
+
import {recordsPath} from './recordsPath.js'
|
|
26
|
+
import {resolve} from './resolve.js'
|
|
27
|
+
import {stats} from './stats.js'
|
|
28
|
+
import {target} from './target.js'
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
bail,
|
|
32
|
+
cache,
|
|
33
|
+
context,
|
|
34
|
+
dependencies,
|
|
35
|
+
devtool,
|
|
36
|
+
entry,
|
|
37
|
+
experiments,
|
|
38
|
+
externals,
|
|
39
|
+
externalsType,
|
|
40
|
+
infrastructureLogging,
|
|
41
|
+
loader,
|
|
42
|
+
mode,
|
|
43
|
+
module,
|
|
44
|
+
name,
|
|
45
|
+
node,
|
|
46
|
+
optimization,
|
|
47
|
+
output,
|
|
48
|
+
parallelism,
|
|
49
|
+
performance,
|
|
50
|
+
plugins,
|
|
51
|
+
profile,
|
|
52
|
+
recordsPath,
|
|
53
|
+
resolve,
|
|
54
|
+
stats,
|
|
55
|
+
target,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface Factory<
|
|
59
|
+
Key extends keyof Config,
|
|
60
|
+
Config = Configuration,
|
|
61
|
+
> {
|
|
62
|
+
(app: Bud): Promise<Config[Key]>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type Records<Config = Configuration> = {
|
|
66
|
+
[Key in keyof Config as `${Key & string}`]: Factory<Key, Config>
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {Factory} from './index.js'
|
|
2
|
+
|
|
3
|
+
export const infrastructureLogging: Factory<
|
|
4
|
+
`infrastructureLogging`
|
|
5
|
+
> = async bud =>
|
|
6
|
+
bud.hooks.filter(`build.infrastructureLogging`, {
|
|
7
|
+
console: bud.hooks.filter(`build.infrastructureLogging.console`, {
|
|
8
|
+
...console,
|
|
9
|
+
log: bud.context.logger.log,
|
|
10
|
+
info: bud.context.logger.info,
|
|
11
|
+
warn: bud.context.logger.warn,
|
|
12
|
+
error: bud.context.logger.error,
|
|
13
|
+
debug: bud.context.logger.debug,
|
|
14
|
+
time: bud.context.logger.time,
|
|
15
|
+
timeEnd: bud.context.logger.timeEnd,
|
|
16
|
+
}),
|
|
17
|
+
level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
|
|
18
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
|
|
3
|
+
import type {Factory} from './index.js'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
filter: Bud[`hooks`][`filter`]
|
|
7
|
+
rules: Bud[`build`][`rules`]
|
|
8
|
+
path: Bud[`path`]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const module: Factory<`module`> = async ({
|
|
12
|
+
build: {rules},
|
|
13
|
+
hooks: {filter},
|
|
14
|
+
path,
|
|
15
|
+
}) =>
|
|
16
|
+
filter(`build.module`, {
|
|
17
|
+
noParse: getNoParse(filter),
|
|
18
|
+
rules: getRules({filter, path, rules}),
|
|
19
|
+
unsafeCache: getUnsafeCache(filter),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const getRules = ({filter, path, rules}: Props) => [
|
|
23
|
+
...filter(`build.module.rules.before`, [
|
|
24
|
+
{
|
|
25
|
+
test: filter(`pattern.js`),
|
|
26
|
+
include: [path(`@src`)],
|
|
27
|
+
parser: {requireEnsure: false},
|
|
28
|
+
},
|
|
29
|
+
]),
|
|
30
|
+
{
|
|
31
|
+
oneOf: filter(
|
|
32
|
+
`build.module.rules.oneOf`,
|
|
33
|
+
Object.values(rules)
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.map(rule => (`toWebpack` in rule ? rule.toWebpack() : rule)),
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
...filter(`build.module.rules.after`, []),
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
const getNoParse = (filter: Props[`filter`]) =>
|
|
42
|
+
filter(`build.module.noParse`, undefined)
|
|
43
|
+
|
|
44
|
+
const getUnsafeCache = (filter: Props[`filter`]) =>
|
|
45
|
+
filter(`build.module.unsafeCache`, false)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type {Factory} from './index.js'
|
|
2
|
+
|
|
3
|
+
export const optimization: Factory<`optimization`> = async ({
|
|
4
|
+
hooks: {filter},
|
|
5
|
+
isDevelopment,
|
|
6
|
+
isProduction,
|
|
7
|
+
}) =>
|
|
8
|
+
filter(`build.optimization`, {
|
|
9
|
+
emitOnErrors: filter(`build.optimization.emitOnErrors`, isDevelopment),
|
|
10
|
+
minimize: filter(`build.optimization.minimize`, isProduction),
|
|
11
|
+
minimizer: filter(`build.optimization.minimizer`, []),
|
|
12
|
+
moduleIds: filter(`build.optimization.moduleIds`, `named`),
|
|
13
|
+
removeEmptyChunks: filter(
|
|
14
|
+
`build.optimization.removeEmptyChunks`,
|
|
15
|
+
false,
|
|
16
|
+
),
|
|
17
|
+
runtimeChunk: filter(`build.optimization.runtimeChunk`, false),
|
|
18
|
+
splitChunks: filter(`build.optimization.splitChunks`, false),
|
|
19
|
+
usedExports: filter(`build.optimization.usedExports`, isProduction),
|
|
20
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {join} from 'node:path'
|
|
2
|
+
|
|
3
|
+
import type {Bud} from '@roots/bud-framework'
|
|
4
|
+
|
|
5
|
+
import {scriptExtension} from '../../helpers/scriptExtension.js'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
filter: Bud[`hooks`][`filter`]
|
|
9
|
+
relPath: Bud[`relPath`]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const chunkFilename = ({filter, relPath}: Props) =>
|
|
13
|
+
filter(
|
|
14
|
+
`build.output.chunkFilename`,
|
|
15
|
+
join(`js`, `dynamic`, relPath(`@name.chunk`)).concat(
|
|
16
|
+
scriptExtension(filter, `.mjs`, `.js`),
|
|
17
|
+
),
|
|
18
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
|
|
3
|
+
import {scriptExtension} from '../../helpers/scriptExtension.js'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
filter: Bud['hooks'][`filter`]
|
|
7
|
+
relPath: Bud['relPath']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const filename = ({filter, relPath}: Props) =>
|
|
11
|
+
filter(
|
|
12
|
+
`build.output.filename`,
|
|
13
|
+
relPath(`js`, `@name${scriptExtension(filter, `.mjs`, `.js`)}`),
|
|
14
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {isMjs} from '../../helpers/isMjs.js'
|
|
2
|
+
import type {Factory} from '../index.js'
|
|
3
|
+
import {assetModuleFilename} from './assetModuleFilename.js'
|
|
4
|
+
import {chunkFilename} from './chunkFilename.js'
|
|
5
|
+
import {filename} from './filename.js'
|
|
6
|
+
|
|
7
|
+
export const output: Factory<`output`> = async ({
|
|
8
|
+
hooks: {filter},
|
|
9
|
+
isProduction,
|
|
10
|
+
path,
|
|
11
|
+
relPath,
|
|
12
|
+
}) =>
|
|
13
|
+
filter(`build.output`, {
|
|
14
|
+
assetModuleFilename: assetModuleFilename({filter, relPath}),
|
|
15
|
+
chunkFilename: chunkFilename({filter, relPath}),
|
|
16
|
+
clean: filter(`build.output.clean`, isProduction),
|
|
17
|
+
environment: filter(`build.output.environment`, undefined),
|
|
18
|
+
filename: filename({filter, relPath}),
|
|
19
|
+
module: filter(`build.output.module`, false),
|
|
20
|
+
path: filter(`build.output.path`, path(`@dist`)),
|
|
21
|
+
pathinfo: filter(`build.output.pathinfo`),
|
|
22
|
+
publicPath: filter(`build.output.publicPath`, `auto`),
|
|
23
|
+
scriptType: filter(
|
|
24
|
+
`build.output.scriptType`,
|
|
25
|
+
isMjs(filter) ? `module` : false,
|
|
26
|
+
),
|
|
27
|
+
uniqueName: filter(`build.output.uniqueName`, `@roots/bud`),
|
|
28
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
|
|
3
|
+
import type {Factory} from './index.js'
|
|
4
|
+
|
|
5
|
+
export const resolve: Factory<`resolve`> = async bud => {
|
|
6
|
+
const modules = await getModules(bud)
|
|
7
|
+
const value = {
|
|
8
|
+
alias: await getAlias(bud),
|
|
9
|
+
extensions: getExtensions(bud),
|
|
10
|
+
modules,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return await bud.hooks.filterAsync(`build.resolve`, value)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const getAlias = async (bud: Bud) =>
|
|
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
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const getModules = async (bud: Bud) =>
|
|
42
|
+
await bud.hooks.filterAsync(`build.resolve.modules`, [
|
|
43
|
+
bud.hooks.filter(`location.@src`),
|
|
44
|
+
bud.hooks.filter(`location.@modules`),
|
|
45
|
+
])
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {Factory} from './index.js'
|
|
2
|
+
|
|
3
|
+
export const stats: Factory<`stats`> = async app =>
|
|
4
|
+
app.hooks.filter(
|
|
5
|
+
`build.stats`,
|
|
6
|
+
app.isProduction
|
|
7
|
+
? {
|
|
8
|
+
all: false,
|
|
9
|
+
assets: true,
|
|
10
|
+
children: false,
|
|
11
|
+
entrypoints: true,
|
|
12
|
+
errors: true,
|
|
13
|
+
errorsCount: true,
|
|
14
|
+
hash: true,
|
|
15
|
+
outputPath: true,
|
|
16
|
+
modules: true,
|
|
17
|
+
timings: true,
|
|
18
|
+
warnings: true,
|
|
19
|
+
warningsCount: true,
|
|
20
|
+
}
|
|
21
|
+
: {preset: `none`},
|
|
22
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
|
|
3
|
+
import type {Rule} from '../rule/index.js'
|
|
4
|
+
import * as items from './items/items.js'
|
|
5
|
+
import * as loaders from './loaders/loaders.js'
|
|
6
|
+
import {register} from './register.js'
|
|
7
|
+
import {rules} from './rules/index.js'
|
|
8
|
+
|
|
9
|
+
export interface Props {
|
|
10
|
+
filter: Bud[`hooks`][`filter`]
|
|
11
|
+
makeItem: Bud[`build`][`makeItem`]
|
|
12
|
+
makeLoader: Bud[`build`][`makeLoader`]
|
|
13
|
+
makeRule: Bud[`build`][`makeRule`]
|
|
14
|
+
isProduction: Bud[`isProduction`]
|
|
15
|
+
path: Bud[`path`]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Factory<T = Rule> {
|
|
19
|
+
(props: Props): T
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {items, loaders, register, rules}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type {Item} from '@roots/bud-framework/services/build'
|
|
2
|
+
import isBoolean from '@roots/bud-support/lodash/isBoolean'
|
|
3
|
+
|
|
4
|
+
import type {Factory} from '../index.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CSS loader
|
|
8
|
+
*/
|
|
9
|
+
export const css: Factory<Item> = ({makeItem}) =>
|
|
10
|
+
makeItem()
|
|
11
|
+
.setIdent(`css`)
|
|
12
|
+
.setLoader(`css`)
|
|
13
|
+
.setOptions(({build: {rules}, hooks: {filter}}) => ({
|
|
14
|
+
importLoaders: rules.css.getUse().length - 2,
|
|
15
|
+
modules: false,
|
|
16
|
+
sourceMap: isBoolean(filter(`build.devtool`, false))
|
|
17
|
+
? filter(`build.devtool`, false)
|
|
18
|
+
: true,
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* CSS module loader
|
|
23
|
+
*/
|
|
24
|
+
export const cssModule: Factory<Item> = ({makeItem}) =>
|
|
25
|
+
makeItem()
|
|
26
|
+
.setIdent(`cssModule`)
|
|
27
|
+
.setLoader(`css`)
|
|
28
|
+
.setOptions(({build: {rules}, hooks: {filter}}) => ({
|
|
29
|
+
importLoaders: rules.cssModule.getUse().length - 2,
|
|
30
|
+
modules: true,
|
|
31
|
+
sourceMap: isBoolean(filter(`build.devtool`, false))
|
|
32
|
+
? filter(`build.devtool`, false)
|
|
33
|
+
: true,
|
|
34
|
+
}))
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* CSV loader
|
|
38
|
+
*/
|
|
39
|
+
export const csv: Factory<Item> = ({makeItem}) =>
|
|
40
|
+
makeItem().setLoader(`csv`).setIdent(`csv`)
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* HTML loader
|
|
44
|
+
*/
|
|
45
|
+
export const html: Factory<Item> = ({makeItem}) =>
|
|
46
|
+
makeItem().setLoader(`html`).setIdent(`html`)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Style loader
|
|
50
|
+
*/
|
|
51
|
+
export const style: Factory<Item> = ({makeItem}) =>
|
|
52
|
+
makeItem().setLoader(`style`).setIdent(`style`)
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Markdown loader
|
|
56
|
+
*/
|
|
57
|
+
export const md: Factory<Item> = ({makeItem}) =>
|
|
58
|
+
makeItem().setIdent(`md`).setLoader(`md`)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* MiniCss loader
|
|
62
|
+
*/
|
|
63
|
+
export const minicss: Factory<Item> = ({makeItem}) =>
|
|
64
|
+
makeItem()
|
|
65
|
+
.setLoader(`minicss`)
|
|
66
|
+
.setIdent(`minicss`)
|
|
67
|
+
.setOptions(app => ({
|
|
68
|
+
publicPath: app.hooks.filter(`build.output.publicPath`),
|
|
69
|
+
}))
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Raw loader
|
|
73
|
+
*/
|
|
74
|
+
export const raw: Factory<Item> = ({makeItem}) =>
|
|
75
|
+
makeItem().setLoader(`raw`).setIdent(`raw`)
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* File loader
|
|
79
|
+
*/
|
|
80
|
+
export const file: Factory<Item> = ({makeItem}) =>
|
|
81
|
+
makeItem().setLoader(`file`).setIdent(`file`)
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Xml loader
|
|
85
|
+
*/
|
|
86
|
+
export const xml: Factory<Item> = ({makeItem}) =>
|
|
87
|
+
makeItem().setLoader(`xml`).setIdent(`xml`)
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Yml loader
|
|
91
|
+
*/
|
|
92
|
+
export const yml: Factory<Item> = ({makeItem}) =>
|
|
93
|
+
makeItem().setLoader(`yml`).setIdent(`yml`)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {Loader} from '@roots/bud-framework/services/build'
|
|
2
|
+
import * as MiniCss from '@roots/bud-support/mini-css-extract-plugin'
|
|
3
|
+
|
|
4
|
+
import type {Factory} from '../index.js'
|
|
5
|
+
|
|
6
|
+
export const css: Factory<Loader> = ({makeLoader}) =>
|
|
7
|
+
makeLoader(`@roots/bud-support/css-loader`)
|
|
8
|
+
|
|
9
|
+
export const csv: Factory<Loader> = ({makeLoader}) =>
|
|
10
|
+
makeLoader(`@roots/bud-support/csv-loader`)
|
|
11
|
+
|
|
12
|
+
export const file: Factory<Loader> = ({makeLoader}) =>
|
|
13
|
+
makeLoader(`@roots/bud-support/file-loader`)
|
|
14
|
+
|
|
15
|
+
export const html: Factory<Loader> = ({makeLoader}) =>
|
|
16
|
+
makeLoader(`@roots/bud-support/html-loader`)
|
|
17
|
+
|
|
18
|
+
export const remark: Factory<Loader> = ({makeLoader}) =>
|
|
19
|
+
makeLoader(`@roots/bud-support/remark-loader`)
|
|
20
|
+
|
|
21
|
+
export const minicss: Factory<Loader> = ({makeLoader}) =>
|
|
22
|
+
makeLoader(MiniCss.loader)
|
|
23
|
+
|
|
24
|
+
export const style: Factory<Loader> = ({makeLoader}) =>
|
|
25
|
+
makeLoader(`@roots/bud-support/style-loader`)
|
|
26
|
+
|
|
27
|
+
export const xml: Factory<Loader> = ({makeLoader}) =>
|
|
28
|
+
makeLoader(`@roots/bud-support/xml-loader`)
|
|
29
|
+
|
|
30
|
+
export const yml: Factory<Loader> = ({makeLoader}) =>
|
|
31
|
+
makeLoader(`@roots/bud-support/yml-loader`)
|