@roots/bud-build 6.14.2 → 6.15.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/config/bail.d.ts +1 -1
- package/lib/config/cache.d.ts +1 -1
- package/lib/config/context.d.ts +1 -1
- package/lib/config/dependencies.d.ts +1 -1
- package/lib/config/devtool.d.ts +1 -1
- package/lib/config/entry.d.ts +1 -1
- package/lib/config/experiments.d.ts +1 -1
- package/lib/config/experiments.js +1 -0
- package/lib/config/externals.d.ts +1 -1
- package/lib/config/externalsType.d.ts +1 -1
- package/lib/config/index.d.ts +28 -29
- package/lib/config/index.js +27 -28
- package/lib/config/infrastructureLogging.d.ts +1 -1
- package/lib/config/infrastructureLogging.js +4 -4
- package/lib/config/loader.d.ts +1 -1
- package/lib/config/mode.d.ts +1 -1
- package/lib/config/module.d.ts +1 -1
- package/lib/config/name.d.ts +1 -1
- package/lib/config/node.d.ts +1 -1
- package/lib/config/optimization.d.ts +1 -1
- package/lib/config/optimization.js +1 -1
- package/lib/config/output/assetModuleFilename.js +1 -1
- package/lib/config/output/filename.js +1 -1
- package/lib/config/output/index.d.ts +1 -1
- package/lib/config/output/index.js +7 -2
- package/lib/config/parallelism.d.ts +1 -1
- package/lib/config/parallelism.js +8 -7
- package/lib/config/performance.d.ts +1 -1
- package/lib/config/plugins.d.ts +1 -1
- package/lib/config/plugins.js +4 -1
- package/lib/config/profile.d.ts +1 -1
- package/lib/config/recordsPath.d.ts +1 -1
- package/lib/config/resolve.d.ts +1 -1
- package/lib/config/resolve.js +1 -1
- package/lib/config/resolveLoader.d.ts +1 -1
- package/lib/config/resolveLoader.js +0 -3
- package/lib/config/snapshot.d.ts +1 -1
- package/lib/config/stats.d.ts +1 -1
- package/lib/config/stats.js +1 -19
- package/lib/config/target.d.ts +1 -1
- package/lib/helpers/isMjs.d.ts +2 -1
- package/lib/helpers/isMjs.js +2 -1
- package/lib/{shared/base.d.ts → helpers/registrable.d.ts} +2 -1
- package/lib/{shared/base.js → helpers/registrable.js} +7 -13
- package/lib/helpers/script-extension.d.ts +3 -0
- package/lib/helpers/script-extension.js +5 -0
- package/lib/index.d.ts +53 -7
- package/lib/index.js +5 -7
- package/lib/item/index.d.ts +4 -4
- package/lib/item/index.js +14 -38
- package/lib/{handlers/items/items.d.ts → items/index.d.ts} +1 -1
- package/lib/loader/index.d.ts +4 -4
- package/lib/loader/index.js +4 -4
- package/lib/{handlers/loaders/loaders.d.ts → loaders/index.d.ts} +1 -1
- package/lib/registry/index.d.ts +36 -0
- package/lib/{handlers/register.js → registry/index.js} +9 -5
- package/lib/rule/index.d.ts +3 -3
- package/lib/rule/index.js +22 -76
- package/lib/rules/css.d.ts +3 -0
- package/lib/{handlers/rules → rules}/css.js +2 -1
- package/lib/rules/css.module.d.ts +3 -0
- package/lib/{handlers/rules → rules}/css.module.js +2 -1
- package/lib/rules/csv.d.ts +3 -0
- package/lib/{handlers/rules → rules}/csv.js +2 -1
- package/lib/rules/font.d.ts +3 -0
- package/lib/rules/font.inline.d.ts +3 -0
- package/lib/{handlers/rules → rules}/font.inline.js +2 -1
- package/lib/{handlers/rules → rules}/font.js +2 -1
- package/lib/rules/html.d.ts +3 -0
- package/lib/{handlers/rules → rules}/html.js +2 -1
- package/lib/rules/image.d.ts +3 -0
- package/lib/rules/image.inline.d.ts +3 -0
- package/lib/{handlers/rules → rules}/image.inline.js +2 -1
- package/lib/rules/image.js +8 -0
- package/lib/rules/index.d.ts +15 -0
- package/lib/rules/index.js +15 -0
- package/lib/rules/js.d.ts +3 -0
- package/lib/{handlers/rules → rules}/js.js +2 -1
- package/lib/rules/json.d.ts +3 -0
- package/lib/{handlers/rules → rules}/json.js +2 -1
- package/lib/rules/svg.d.ts +3 -0
- package/lib/rules/svg.inline.d.ts +5 -0
- package/lib/{handlers/rules → rules}/svg.inline.js +3 -2
- package/lib/{handlers/rules → rules}/svg.js +2 -1
- package/lib/rules/toml.d.ts +3 -0
- package/lib/{handlers/rules → rules}/toml.js +2 -1
- package/lib/rules/webp.d.ts +3 -0
- package/lib/{handlers/rules → rules}/webp.js +2 -1
- package/lib/rules/yml.d.ts +3 -0
- package/lib/{handlers/rules → rules}/yml.js +2 -1
- package/lib/{service.d.ts → service/index.d.ts} +27 -24
- package/lib/{service.js → service/index.js} +45 -70
- package/package.json +121 -37
- package/src/config/bail.ts +1 -1
- package/src/config/cache.ts +1 -1
- package/src/config/context.ts +1 -1
- package/src/config/dependencies.ts +2 -2
- package/src/config/devtool.ts +1 -1
- package/src/config/entry.ts +1 -1
- package/src/config/experiments.ts +2 -1
- package/src/config/externals.ts +1 -1
- package/src/config/externalsType.ts +1 -1
- package/src/config/index.ts +28 -58
- package/src/config/infrastructureLogging.ts +6 -6
- package/src/config/loader.ts +1 -1
- package/src/config/mode.ts +1 -1
- package/src/config/module.ts +1 -2
- package/src/config/name.ts +1 -1
- package/src/config/node.ts +1 -1
- package/src/config/optimization.ts +2 -2
- package/src/config/output/assetModuleFilename.ts +1 -1
- package/src/config/output/filename.ts +1 -1
- package/src/config/output/index.ts +8 -6
- package/src/config/parallelism.ts +11 -8
- package/src/config/performance.ts +1 -1
- package/src/config/plugins.ts +5 -3
- package/src/config/profile.ts +1 -1
- package/src/config/recordsPath.ts +1 -1
- package/src/config/resolve.ts +3 -3
- package/src/config/resolveLoader.ts +1 -4
- package/src/config/snapshot.ts +1 -1
- package/src/config/stats.ts +2 -23
- package/src/config/target.ts +1 -1
- package/src/helpers/isMjs.ts +3 -1
- package/src/{shared/base.ts → helpers/registrable.ts} +3 -1
- package/src/helpers/{scriptExtension.ts → script-extension.ts} +4 -2
- package/src/index.ts +56 -7
- package/src/item/index.ts +5 -6
- package/src/{handlers/items/items.ts → items/index.ts} +1 -2
- package/src/loader/index.ts +6 -5
- package/src/{handlers/loaders/loaders.ts → loaders/index.ts} +1 -2
- package/src/{handlers/register.ts → registry/index.ts} +36 -13
- package/src/rule/index.ts +3 -4
- package/src/rules/css.module.ts +9 -0
- package/src/rules/css.ts +9 -0
- package/src/rules/csv.ts +9 -0
- package/src/rules/font.inline.ts +10 -0
- package/src/rules/font.ts +9 -0
- package/src/rules/html.ts +9 -0
- package/src/rules/image.inline.ts +10 -0
- package/src/rules/image.ts +12 -0
- package/src/rules/index.ts +15 -0
- package/src/{handlers/rules → rules}/js.ts +4 -2
- package/src/{handlers/rules → rules}/json.ts +5 -3
- package/src/{handlers/rules → rules}/svg.inline.ts +6 -4
- package/src/rules/svg.ts +9 -0
- package/src/{handlers/rules → rules}/toml.ts +5 -3
- package/src/rules/webp.ts +9 -0
- package/src/rules/yml.ts +9 -0
- package/src/{service.ts → service/index.ts} +43 -36
- package/lib/handlers/index.d.ts +0 -19
- package/lib/handlers/index.js +0 -5
- package/lib/handlers/register.d.ts +0 -13
- package/lib/handlers/rules/css.d.ts +0 -2
- package/lib/handlers/rules/css.module.d.ts +0 -2
- package/lib/handlers/rules/csv.d.ts +0 -2
- package/lib/handlers/rules/font.d.ts +0 -2
- package/lib/handlers/rules/font.inline.d.ts +0 -2
- package/lib/handlers/rules/html.d.ts +0 -2
- package/lib/handlers/rules/image.d.ts +0 -2
- package/lib/handlers/rules/image.inline.d.ts +0 -2
- package/lib/handlers/rules/image.js +0 -4
- package/lib/handlers/rules/index.d.ts +0 -17
- package/lib/handlers/rules/index.js +0 -32
- package/lib/handlers/rules/js.d.ts +0 -2
- package/lib/handlers/rules/json.d.ts +0 -2
- package/lib/handlers/rules/svg.d.ts +0 -2
- package/lib/handlers/rules/svg.inline.d.ts +0 -4
- package/lib/handlers/rules/toml.d.ts +0 -2
- package/lib/handlers/rules/webp.d.ts +0 -2
- package/lib/handlers/rules/yml.d.ts +0 -2
- package/lib/helpers/scriptExtension.d.ts +0 -2
- package/lib/helpers/scriptExtension.js +0 -4
- package/lib/types.d.ts +0 -52
- package/lib/types.js +0 -1
- package/src/config/index.test.ts +0 -125
- package/src/handlers/index.ts +0 -24
- package/src/handlers/rules/css.module.ts +0 -7
- package/src/handlers/rules/css.ts +0 -7
- package/src/handlers/rules/csv.test.ts +0 -31
- package/src/handlers/rules/csv.ts +0 -7
- package/src/handlers/rules/font.inline.ts +0 -8
- package/src/handlers/rules/font.ts +0 -7
- package/src/handlers/rules/html.ts +0 -7
- package/src/handlers/rules/image.inline.ts +0 -8
- package/src/handlers/rules/image.ts +0 -7
- package/src/handlers/rules/index.ts +0 -33
- package/src/handlers/rules/svg.inline.test.ts +0 -31
- package/src/handlers/rules/svg.ts +0 -7
- package/src/handlers/rules/toml.test.ts +0 -23
- package/src/handlers/rules/webp.ts +0 -7
- package/src/handlers/rules/yml.ts +0 -7
- package/src/rule/index.test.ts +0 -88
- package/src/types.ts +0 -57
- /package/lib/{handlers/items/items.js → items/index.js} +0 -0
- /package/lib/{handlers/loaders/loaders.js → loaders/index.js} +0 -0
package/src/config/index.ts
CHANGED
|
@@ -1,69 +1,39 @@
|
|
|
1
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
2
|
import type {Configuration} from '@roots/bud-framework/config'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
bail,
|
|
34
|
-
cache,
|
|
35
|
-
context,
|
|
36
|
-
dependencies,
|
|
37
|
-
devtool,
|
|
38
|
-
entry,
|
|
39
|
-
experiments,
|
|
40
|
-
externals,
|
|
41
|
-
externalsType,
|
|
42
|
-
infrastructureLogging,
|
|
43
|
-
loader,
|
|
44
|
-
mode,
|
|
45
|
-
module,
|
|
46
|
-
name,
|
|
47
|
-
node,
|
|
48
|
-
optimization,
|
|
49
|
-
output,
|
|
50
|
-
parallelism,
|
|
51
|
-
performance,
|
|
52
|
-
plugins,
|
|
53
|
-
profile,
|
|
54
|
-
recordsPath,
|
|
55
|
-
resolve,
|
|
56
|
-
resolveLoader,
|
|
57
|
-
snapshot,
|
|
58
|
-
stats,
|
|
59
|
-
target,
|
|
60
|
-
}
|
|
4
|
+
export {bail} from './bail.js'
|
|
5
|
+
export {cache} from './cache.js'
|
|
6
|
+
export {context} from './context.js'
|
|
7
|
+
export {dependencies} from './dependencies.js'
|
|
8
|
+
export {devtool} from './devtool.js'
|
|
9
|
+
export {entry} from './entry.js'
|
|
10
|
+
export {experiments} from './experiments.js'
|
|
11
|
+
export {externals} from './externals.js'
|
|
12
|
+
export {externalsType} from './externalsType.js'
|
|
13
|
+
export {infrastructureLogging} from './infrastructureLogging.js'
|
|
14
|
+
export {loader} from './loader.js'
|
|
15
|
+
export {mode} from './mode.js'
|
|
16
|
+
export {module} from './module.js'
|
|
17
|
+
export {name} from './name.js'
|
|
18
|
+
export {node} from './node.js'
|
|
19
|
+
export {optimization} from './optimization.js'
|
|
20
|
+
export {output} from './output/index.js'
|
|
21
|
+
export {parallelism} from './parallelism.js'
|
|
22
|
+
export {performance} from './performance.js'
|
|
23
|
+
export {plugins} from './plugins.js'
|
|
24
|
+
export {profile} from './profile.js'
|
|
25
|
+
export {recordsPath} from './recordsPath.js'
|
|
26
|
+
export {resolve} from './resolve.js'
|
|
27
|
+
export {resolveLoader} from './resolveLoader.js'
|
|
28
|
+
export {snapshot} from './snapshot.js'
|
|
29
|
+
export {stats} from './stats.js'
|
|
30
|
+
export {target} from './target.js'
|
|
61
31
|
|
|
62
32
|
export interface Factory<
|
|
63
33
|
Key extends keyof Config,
|
|
64
34
|
Config = Configuration,
|
|
65
35
|
> {
|
|
66
|
-
(app: Bud): Promise<Config[Key]>
|
|
36
|
+
(app: Bud): Promise<Config[Key] | undefined>
|
|
67
37
|
}
|
|
68
38
|
|
|
69
39
|
export type Records<Config = Configuration> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import logger from '@roots/bud-support/logger'
|
|
4
4
|
|
|
5
5
|
export const infrastructureLogging: Factory<
|
|
6
6
|
`infrastructureLogging`
|
|
@@ -9,16 +9,16 @@ export const infrastructureLogging: Factory<
|
|
|
9
9
|
console: bud.hooks.filter(`build.infrastructureLogging.console`, {
|
|
10
10
|
...console,
|
|
11
11
|
error: (...args: any[]) => {
|
|
12
|
-
logger.scope(`webpack`).error(...args)
|
|
12
|
+
logger.scope(bud.label, `webpack`).error(...args)
|
|
13
13
|
},
|
|
14
14
|
info: (...args: any[]) => {
|
|
15
|
-
logger.scope(`webpack`).info(...args)
|
|
15
|
+
logger.scope(bud.label, `webpack`).info(...args)
|
|
16
16
|
},
|
|
17
17
|
log: (...args: any[]) => {
|
|
18
|
-
logger.scope(`webpack`).log(...args)
|
|
18
|
+
logger.scope(bud.label, `webpack`).log(...args)
|
|
19
19
|
},
|
|
20
20
|
warn: (...args: any[]) => {
|
|
21
|
-
logger.scope(`webpack`).info(...args)
|
|
21
|
+
logger.scope(bud.label, `webpack`).info(...args)
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
24
24
|
level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
|
package/src/config/loader.ts
CHANGED
package/src/config/mode.ts
CHANGED
package/src/config/module.ts
CHANGED
package/src/config/name.ts
CHANGED
package/src/config/node.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Factory} from '
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
3
|
export const optimization: Factory<`optimization`> = async ({
|
|
4
4
|
hooks: {filter},
|
|
@@ -31,7 +31,7 @@ export const optimization: Factory<`optimization`> = async ({
|
|
|
31
31
|
),
|
|
32
32
|
removeEmptyChunks: filter(
|
|
33
33
|
`build.optimization.removeEmptyChunks`,
|
|
34
|
-
|
|
34
|
+
false,
|
|
35
35
|
),
|
|
36
36
|
runtimeChunk: filter(`build.optimization.runtimeChunk`, `single`),
|
|
37
37
|
sideEffects: filter(`build.optimization.sideEffects`, isProduction),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {Factory} from '
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
import {isMjs} from '../../helpers/isMjs.js'
|
|
4
3
|
import {assetModuleFilename} from './assetModuleFilename.js'
|
|
5
4
|
import {filename} from './filename.js'
|
|
6
5
|
|
|
@@ -24,11 +23,14 @@ export const output: Factory<`output`> = async ({
|
|
|
24
23
|
iife: filter(`build.output.iife`, undefined),
|
|
25
24
|
module: filter(`build.output.module`, false),
|
|
26
25
|
path: filter(`build.output.path`, path(`@dist`)),
|
|
26
|
+
/**
|
|
27
|
+
* Path info is not necessary unless the user
|
|
28
|
+
* really knows what's going on.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://medium.com/@kenneth_chau/speeding-up-webpack-typescript-incremental-builds-by-7x-3912ba4c1d15}
|
|
31
|
+
*/
|
|
27
32
|
pathinfo: filter(`build.output.pathinfo`, false),
|
|
28
33
|
publicPath: filter(`build.output.publicPath`, `auto`),
|
|
29
|
-
scriptType: filter(
|
|
30
|
-
`build.output.scriptType`,
|
|
31
|
-
isMjs(filter) ? `module` : `text/javascript`,
|
|
32
|
-
),
|
|
34
|
+
scriptType: filter(`build.output.scriptType`, undefined),
|
|
33
35
|
uniqueName: filter(`build.output.uniqueName`, `@roots/bud`),
|
|
34
36
|
})
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {cpus} from 'node:os'
|
|
4
4
|
|
|
5
5
|
export const parallelism: Factory<`parallelism`> = async ({
|
|
6
|
+
build,
|
|
6
7
|
hooks,
|
|
7
8
|
root,
|
|
8
9
|
}) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const concurrency = 100
|
|
11
|
+
const cores = Math.max(cpus().length, 1)
|
|
12
|
+
|
|
13
|
+
const available = cores * concurrency
|
|
14
|
+
const compilations = Math.max(Object.keys(root.children ?? []).length, 1)
|
|
15
|
+
const parallelism = Math.max(Math.floor(available / compilations), 1)
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
build.logger.info(`parallelism set to`, parallelism)
|
|
18
|
+
return hooks.filter(`build.parallelism`, parallelism)
|
|
16
19
|
}
|
package/src/config/plugins.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {Factory} from '
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
export const plugins: Factory<`plugins`> = async app =>
|
|
4
|
-
|
|
3
|
+
export const plugins: Factory<`plugins`> = async app => {
|
|
4
|
+
const plugins = await app.extensions.make()
|
|
5
|
+
return await app.hooks.filterAsync(`build.plugins`, plugins)
|
|
6
|
+
}
|
package/src/config/profile.ts
CHANGED
package/src/config/resolve.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import isString from '@roots/bud-support/lodash/isString'
|
|
4
4
|
|
|
5
5
|
export const resolve: Factory<`resolve`> = async bud => {
|
|
6
6
|
return await bud.hooks.filterAsync(`build.resolve`, {
|
|
@@ -20,7 +20,7 @@ export const resolve: Factory<`resolve`> = async bud => {
|
|
|
20
20
|
extensions: Array.from(
|
|
21
21
|
bud.hooks.filter(
|
|
22
22
|
`build.resolve.extensions`,
|
|
23
|
-
new Set([`.js`, `.mjs`, `.
|
|
23
|
+
new Set([`.js`, `.mjs`, `.css`]),
|
|
24
24
|
),
|
|
25
25
|
),
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Factory} from '
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
3
|
export const resolveLoader: Factory<`resolveLoader`> = async ({
|
|
4
4
|
hooks,
|
|
@@ -13,11 +13,8 @@ export const resolveLoader: Factory<`resolveLoader`> = async ({
|
|
|
13
13
|
'html-loader': await module.resolve(
|
|
14
14
|
`@roots/bud-support/html-loader`,
|
|
15
15
|
),
|
|
16
|
-
json5: await module.resolve(`@roots/bud-support/json5`),
|
|
17
|
-
'mini-svg-data-uri': await module.resolve(`mini-svg-data-uri`),
|
|
18
16
|
'style-loader': await module.resolve(
|
|
19
17
|
`@roots/bud-support/style-loader`,
|
|
20
18
|
),
|
|
21
|
-
toml: await module.resolve(`@roots/bud-support/toml`),
|
|
22
19
|
}),
|
|
23
20
|
})
|
package/src/config/snapshot.ts
CHANGED
package/src/config/stats.ts
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import type {Factory} from '
|
|
1
|
+
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
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
|
-
assetsSort: `size`,
|
|
11
|
-
builtAt: false,
|
|
12
|
-
children: false,
|
|
13
|
-
chunks: false,
|
|
14
|
-
entrypoints: true,
|
|
15
|
-
errors: true,
|
|
16
|
-
errorsCount: true,
|
|
17
|
-
hash: true,
|
|
18
|
-
modules: true,
|
|
19
|
-
outputPath: true,
|
|
20
|
-
timings: true,
|
|
21
|
-
warnings: true,
|
|
22
|
-
warningsCount: true,
|
|
23
|
-
}
|
|
24
|
-
: {preset: `none`},
|
|
25
|
-
)
|
|
4
|
+
app.hooks.filter(`build.stats`, {preset: `none`})
|
package/src/config/target.ts
CHANGED
package/src/helpers/isMjs.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {Base as BuildBase} from '@roots/bud-framework/services/build'
|
|
|
4
4
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
5
5
|
import isFunction from '@roots/bud-support/lodash/isFunction'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class Registrable implements BuildBase {
|
|
8
8
|
/**
|
|
9
9
|
* Constructor
|
|
10
10
|
*/
|
|
@@ -34,3 +34,5 @@ export default class Base implements BuildBase {
|
|
|
34
34
|
return isFunction(input) ? input : () => input
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
export {Registrable as default}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import isMjs from '@roots/bud-build/helpers/isMjs'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const scriptExtension = (
|
|
6
6
|
filter: Bud[`hooks`][`filter`],
|
|
7
7
|
mjs: `.${string}` = `.mjs`,
|
|
8
8
|
js: `.${string}` = `.js`,
|
|
9
9
|
): `.${string}` => {
|
|
10
10
|
return isMjs(filter) ? mjs : js
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
export {scriptExtension as default}
|
package/src/index.ts
CHANGED
|
@@ -8,12 +8,61 @@
|
|
|
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 './types.js'
|
|
11
|
+
import {default as Item} from '@roots/bud-build/item'
|
|
12
|
+
import {default as Loader} from '@roots/bud-build/loader'
|
|
13
|
+
import {default as Rule} from '@roots/bud-build/rule'
|
|
14
|
+
import {default as Build} from '@roots/bud-build/service'
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
declare module '@roots/bud-framework' {
|
|
17
|
+
interface Services {
|
|
18
|
+
build: Build
|
|
19
|
+
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
interface Loaders {
|
|
22
|
+
css: Loader
|
|
23
|
+
csv: Loader
|
|
24
|
+
file: Loader
|
|
25
|
+
html: Loader
|
|
26
|
+
md: Loader
|
|
27
|
+
minicss: Loader
|
|
28
|
+
raw: Loader
|
|
29
|
+
style: Loader
|
|
30
|
+
url: Loader
|
|
31
|
+
yml: Loader
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Items {
|
|
35
|
+
css: Item
|
|
36
|
+
cssModule: Item
|
|
37
|
+
csv: Item
|
|
38
|
+
file: Item
|
|
39
|
+
font: Item
|
|
40
|
+
html: Item
|
|
41
|
+
image: Item
|
|
42
|
+
md: Item
|
|
43
|
+
minicss: Item
|
|
44
|
+
precss: Item
|
|
45
|
+
raw: Item
|
|
46
|
+
style: Item
|
|
47
|
+
yml: Item
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface Rules {
|
|
51
|
+
css: Rule
|
|
52
|
+
cssModule: Rule
|
|
53
|
+
csv: Rule
|
|
54
|
+
font: Rule
|
|
55
|
+
html: Rule
|
|
56
|
+
image: Rule
|
|
57
|
+
inlineFont: Rule
|
|
58
|
+
inlineImage: Rule
|
|
59
|
+
inlineSvg: Rule
|
|
60
|
+
js: Rule
|
|
61
|
+
json: Rule
|
|
62
|
+
svg: Rule
|
|
63
|
+
toml: Rule
|
|
64
|
+
yml: Rule
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {Build as default, Item, Loader, Rule}
|
package/src/item/index.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
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 {basename} from 'path'
|
|
4
|
+
import {basename} from 'node:path'
|
|
5
5
|
|
|
6
|
+
import Registrable from '@roots/bud-build/helpers/registrable'
|
|
7
|
+
import Loader from '@roots/bud-build/loader'
|
|
6
8
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
7
9
|
import isString from '@roots/bud-support/lodash/isString'
|
|
8
10
|
|
|
9
|
-
import {Loader} from '../loader/index.js'
|
|
10
|
-
import Base from '../shared/base.js'
|
|
11
|
-
|
|
12
11
|
export type ConstructorOptions = Build.Item.ConstructorOptions
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Item class
|
|
16
15
|
*/
|
|
17
|
-
class Item extends
|
|
16
|
+
class Item extends Registrable implements Build.Item {
|
|
18
17
|
/**
|
|
19
18
|
* Identifier
|
|
20
19
|
*/
|
|
@@ -153,4 +152,4 @@ class Item extends Base implements Build.Item {
|
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
export {Item}
|
|
155
|
+
export {Item as default}
|
package/src/loader/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Registrable from '@roots/bud-build/helpers/registrable'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Bud Loader
|
|
7
7
|
*/
|
|
8
|
-
class Loader extends
|
|
8
|
+
class Loader extends Registrable {
|
|
9
9
|
/**
|
|
10
10
|
* Factory returning the loader path
|
|
11
11
|
*/
|
|
12
12
|
public src: string
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* Class constructor
|
|
15
16
|
*
|
|
@@ -17,12 +18,12 @@ class Loader extends Base {
|
|
|
17
18
|
*/
|
|
18
19
|
public constructor(
|
|
19
20
|
public override _app: () => Bud,
|
|
20
|
-
src
|
|
21
|
+
src?: string,
|
|
21
22
|
definition?: string,
|
|
22
23
|
) {
|
|
23
24
|
super(_app)
|
|
24
25
|
this._app = _app
|
|
25
|
-
this.src = definition ?? src
|
|
26
|
+
this.src = definition ?? src ?? ``
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
public getSrc(): string {
|
|
@@ -35,4 +36,4 @@ class Loader extends Base {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export {Loader}
|
|
39
|
+
export {Loader as default}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type {Factory} from '@roots/bud-build/registry'
|
|
1
2
|
import type {Loader} from '@roots/bud-framework/services/build'
|
|
2
3
|
|
|
3
4
|
import * as MiniCss from '@roots/bud-support/mini-css-extract-plugin'
|
|
4
5
|
|
|
5
|
-
import type {Factory} from '../index.js'
|
|
6
|
-
|
|
7
6
|
export const css: Factory<Loader> = async ({makeLoader, resolve}) =>
|
|
8
7
|
makeLoader(
|
|
9
8
|
await resolve(`@roots/bud-support/css-loader`, import.meta.url),
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
import type Rule from '@roots/bud-build/rule'
|
|
1
2
|
import type {Bud} from '@roots/bud-framework'
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
+
import * as items from '@roots/bud-build/items'
|
|
5
|
+
import * as loaders from '@roots/bud-build/loaders'
|
|
6
|
+
import * as rules from '@roots/bud-build/rules'
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
interface Props {
|
|
9
|
+
filter: Bud[`hooks`][`filter`]
|
|
10
|
+
isProduction: Bud[`isProduction`]
|
|
11
|
+
makeItem: Bud[`build`][`makeItem`]
|
|
12
|
+
makeLoader: Bud[`build`][`makeLoader`]
|
|
13
|
+
makeRule: Bud[`build`][`makeRule`]
|
|
14
|
+
path: Bud[`path`]
|
|
15
|
+
resolve: Bud[`module`][`resolve`]
|
|
16
|
+
}
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export interface makeRegister {
|
|
13
|
-
<T, F extends CallableFunction>(props: Partial<Bud>, setRule: F): <
|
|
14
|
-
K extends keyof T & string,
|
|
15
|
-
>([key, factory]: [K, Factory<T[K]>]) => void
|
|
18
|
+
interface Factory<T = Rule> {
|
|
19
|
+
(props: Props): Promise<T>
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Register built-in {@link loaders}, {@link items} and {@link rules}
|
|
20
24
|
*/
|
|
21
|
-
|
|
25
|
+
async function register(bud: Bud) {
|
|
22
26
|
await Promise.all([
|
|
23
27
|
...Object.entries(loaders).map(makeRegister(bud, bud.build.setLoader)),
|
|
24
28
|
...Object.entries(items).map(makeRegister(bud, bud.build.setItem)),
|
|
@@ -34,7 +38,23 @@ export async function register(bud: Bud) {
|
|
|
34
38
|
Object.entries(rules).map(makeRegister(bud, bud.build.setRule))
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Registry factory curry function
|
|
43
|
+
*/
|
|
44
|
+
interface makeRegister {
|
|
45
|
+
<T, F extends CallableFunction>(
|
|
46
|
+
props: Partial<Bud>,
|
|
47
|
+
setRule: F,
|
|
48
|
+
): <K extends keyof T & string>([key, factory]: [
|
|
49
|
+
K,
|
|
50
|
+
Factory<T[K]>,
|
|
51
|
+
]) => void
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Registry factory
|
|
56
|
+
*/
|
|
57
|
+
const makeRegister: makeRegister =
|
|
38
58
|
({build, hooks, isProduction, module: {resolve}, path}, setRule) =>
|
|
39
59
|
async ([key, factory]) =>
|
|
40
60
|
setRule(
|
|
@@ -49,3 +69,6 @@ export const makeRegister: makeRegister =
|
|
|
49
69
|
resolve,
|
|
50
70
|
}),
|
|
51
71
|
)
|
|
72
|
+
|
|
73
|
+
export {items, loaders, makeRegister, register, rules}
|
|
74
|
+
export type {Factory, Props}
|