@roots/bud-build 6.14.3 → 6.15.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/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 +122 -38
- 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/lib/types.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Item } from '@roots/bud-build/item';
|
|
2
|
-
import type { Loader } from '@roots/bud-build/loader';
|
|
3
|
-
import type { Rule } from '@roots/bud-build/rule';
|
|
4
|
-
import type { Build } from './service.js';
|
|
5
|
-
declare module '@roots/bud-framework' {
|
|
6
|
-
interface Services {
|
|
7
|
-
build: Build;
|
|
8
|
-
}
|
|
9
|
-
interface Loaders {
|
|
10
|
-
css: Loader;
|
|
11
|
-
csv: Loader;
|
|
12
|
-
file: Loader;
|
|
13
|
-
html: Loader;
|
|
14
|
-
md: Loader;
|
|
15
|
-
minicss: Loader;
|
|
16
|
-
raw: Loader;
|
|
17
|
-
style: Loader;
|
|
18
|
-
url: Loader;
|
|
19
|
-
yml: Loader;
|
|
20
|
-
}
|
|
21
|
-
interface Items {
|
|
22
|
-
css: Item;
|
|
23
|
-
cssModule: Item;
|
|
24
|
-
csv: Item;
|
|
25
|
-
file: Item;
|
|
26
|
-
font: Item;
|
|
27
|
-
html: Item;
|
|
28
|
-
image: Item;
|
|
29
|
-
md: Item;
|
|
30
|
-
minicss: Item;
|
|
31
|
-
precss: Item;
|
|
32
|
-
raw: Item;
|
|
33
|
-
style: Item;
|
|
34
|
-
yml: Item;
|
|
35
|
-
}
|
|
36
|
-
interface Rules {
|
|
37
|
-
css: Rule;
|
|
38
|
-
cssModule: Rule;
|
|
39
|
-
csv: Rule;
|
|
40
|
-
font: Rule;
|
|
41
|
-
html: Rule;
|
|
42
|
-
image: Rule;
|
|
43
|
-
inlineFont: Rule;
|
|
44
|
-
inlineImage: Rule;
|
|
45
|
-
inlineSvg: Rule;
|
|
46
|
-
js: Rule;
|
|
47
|
-
json: Rule;
|
|
48
|
-
svg: Rule;
|
|
49
|
-
toml: Rule;
|
|
50
|
-
yml: Rule;
|
|
51
|
-
}
|
|
52
|
-
}
|
package/lib/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/config/index.test.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {Bud, factory} from '@repo/test-kit'
|
|
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({cache: `filesystem`})
|
|
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.version).toStrictEqual(undefined)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it(`should have expected context default`, async () => {
|
|
35
|
-
expect(build.config.context).toEqual(bud.path(`@src`))
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it(`should have expected devtool default`, async () => {
|
|
39
|
-
expect(build.config.devtool).toBe(false)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it(`should have expected entry default`, async () => {
|
|
43
|
-
expect(build.config.entry).toEqual({main: {import: [`index`]}})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it(`should have expected mode default`, async () => {
|
|
47
|
-
expect(build.config.mode).toEqual(`production`)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it(`should have expected name default`, async () => {
|
|
51
|
-
expect(build.config.name).toEqual(`@tests/project`)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it(`should have expected node default`, async () => {
|
|
55
|
-
expect(build.config.node).toEqual(false)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it(`should have expected optimization.minimize default`, async () => {
|
|
59
|
-
expect(build.config.optimization?.minimize).toEqual(true)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it(`should have expected optimization.emitOnErrors default`, async () => {
|
|
63
|
-
expect((build.config.optimization as any).emitOnErrors).toEqual(false)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it(`should have expected optimization.runtimeChunk default`, async () => {
|
|
67
|
-
expect(build.config.optimization?.runtimeChunk).toBe(`single`)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it(`should have expected profile default`, async () => {
|
|
71
|
-
expect(build.config.profile).toBeUndefined()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it(`should have expected resolve.alias default`, async () => {
|
|
75
|
-
expect(build.config.resolve?.alias).toEqual({
|
|
76
|
-
'@src': bud.path(`@src`),
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it(`should have expected resolve.extensions default`, async () => {
|
|
81
|
-
expect(build.config.resolve?.extensions?.sort()).toEqual(
|
|
82
|
-
expect.arrayContaining([
|
|
83
|
-
`.css`,
|
|
84
|
-
`.js`,
|
|
85
|
-
`.jsx`,
|
|
86
|
-
`.mjs`,
|
|
87
|
-
`.mts`,
|
|
88
|
-
`.ts`,
|
|
89
|
-
`.tsx`,
|
|
90
|
-
]),
|
|
91
|
-
)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it(`should have expected target default`, async () => {
|
|
95
|
-
expect(build.config.target).toMatch(/browserslist.*/)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it(`should have expected watch default`, async () => {
|
|
99
|
-
expect(build.config.watch).toBeUndefined()
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it(`should have expected watchOptions default`, async () => {
|
|
103
|
-
expect(build.config.watchOptions).toBeUndefined()
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it(`should have expected plugins`, async () => {
|
|
107
|
-
const plugins = build.config.plugins
|
|
108
|
-
?.map(plugin => plugin.constructor.name)
|
|
109
|
-
.sort()
|
|
110
|
-
|
|
111
|
-
expect(plugins).toContain(`CleanWebpackPlugin`)
|
|
112
|
-
expect(plugins).toContain(`FixStyleOnlyEntrypoints`)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
it(`should have expected default requireEnsure rule`, async () => {
|
|
116
|
-
if (!build.config.module?.rules?.length) throw new Error()
|
|
117
|
-
expect(build.config.module.rules[0]).toEqual(
|
|
118
|
-
expect.objectContaining({
|
|
119
|
-
parser: {
|
|
120
|
-
requireEnsure: false,
|
|
121
|
-
},
|
|
122
|
-
}),
|
|
123
|
-
)
|
|
124
|
-
})
|
|
125
|
-
})
|
package/src/handlers/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type {Bud} from '@roots/bud-framework'
|
|
2
|
-
|
|
3
|
-
import type {Rule} from '../rule/index.js'
|
|
4
|
-
|
|
5
|
-
import * as items from './items/items.js'
|
|
6
|
-
import * as loaders from './loaders/loaders.js'
|
|
7
|
-
import {register} from './register.js'
|
|
8
|
-
import {rules} from './rules/index.js'
|
|
9
|
-
|
|
10
|
-
export interface Props {
|
|
11
|
-
filter: Bud[`hooks`][`filter`]
|
|
12
|
-
isProduction: Bud[`isProduction`]
|
|
13
|
-
makeItem: Bud[`build`][`makeItem`]
|
|
14
|
-
makeLoader: Bud[`build`][`makeLoader`]
|
|
15
|
-
makeRule: Bud[`build`][`makeRule`]
|
|
16
|
-
path: Bud[`path`]
|
|
17
|
-
resolve: Bud[`module`][`resolve`]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface Factory<T = Rule> {
|
|
21
|
-
(props: Props): Promise<T>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export {items, loaders, register, rules}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {factory} from '@repo/test-kit'
|
|
2
|
-
import {describe, expect, it} from 'vitest'
|
|
3
|
-
|
|
4
|
-
import {csv} from './csv.js'
|
|
5
|
-
|
|
6
|
-
describe(`csv loader`, () => {
|
|
7
|
-
it(`should return a rule`, async () => {
|
|
8
|
-
const bud = await factory()
|
|
9
|
-
|
|
10
|
-
const result = await csv({
|
|
11
|
-
filter: bud.hooks.filter,
|
|
12
|
-
makeItem: bud.build.makeItem,
|
|
13
|
-
makeLoader: bud.build.makeLoader,
|
|
14
|
-
makeRule: bud.build.makeRule,
|
|
15
|
-
isProduction: bud.isProduction,
|
|
16
|
-
path: bud.path,
|
|
17
|
-
resolve: bud.module.resolve,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const webpackOutput = result.toWebpack()
|
|
21
|
-
|
|
22
|
-
expect(webpackOutput.use?.[0]).toEqual(
|
|
23
|
-
expect.objectContaining({
|
|
24
|
-
ident: `csv`,
|
|
25
|
-
loader: expect.stringContaining(
|
|
26
|
-
`@roots/bud-support/lib/csv-loader`,
|
|
27
|
-
),
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {css} from './css.js'
|
|
2
|
-
import {cssModule} from './css.module.js'
|
|
3
|
-
import {csv} from './csv.js'
|
|
4
|
-
import {inlineFont} from './font.inline.js'
|
|
5
|
-
import {font} from './font.js'
|
|
6
|
-
import {html} from './html.js'
|
|
7
|
-
import {inlineImage} from './image.inline.js'
|
|
8
|
-
import {image} from './image.js'
|
|
9
|
-
import {js} from './js.js'
|
|
10
|
-
import {json} from './json.js'
|
|
11
|
-
import {inlineSvg} from './svg.inline.js'
|
|
12
|
-
import {svg} from './svg.js'
|
|
13
|
-
import {toml} from './toml.js'
|
|
14
|
-
import {webp} from './webp.js'
|
|
15
|
-
import {yml} from './yml.js'
|
|
16
|
-
|
|
17
|
-
export const rules = {
|
|
18
|
-
css,
|
|
19
|
-
cssModule,
|
|
20
|
-
csv,
|
|
21
|
-
font,
|
|
22
|
-
html,
|
|
23
|
-
image,
|
|
24
|
-
inlineFont,
|
|
25
|
-
inlineImage,
|
|
26
|
-
inlineSvg,
|
|
27
|
-
js,
|
|
28
|
-
json,
|
|
29
|
-
svg,
|
|
30
|
-
toml,
|
|
31
|
-
webp,
|
|
32
|
-
yml,
|
|
33
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it} from 'vitest'
|
|
2
|
-
|
|
3
|
-
import {inlineSvg, dataUrl} from './svg.inline.js'
|
|
4
|
-
|
|
5
|
-
describe(`svg-inline`, () => {
|
|
6
|
-
it(`should return a rule`, async () => {
|
|
7
|
-
const bud = await import(`@repo/test-kit`).then(
|
|
8
|
-
async ({factory}) => await factory(),
|
|
9
|
-
)
|
|
10
|
-
const result = await inlineSvg({
|
|
11
|
-
filter: bud.hooks.filter,
|
|
12
|
-
makeItem: bud.build.makeItem,
|
|
13
|
-
makeLoader: bud.build.makeLoader,
|
|
14
|
-
makeRule: bud.build.makeRule,
|
|
15
|
-
isProduction: bud.isProduction,
|
|
16
|
-
path: bud.path,
|
|
17
|
-
resolve: bud.module.resolve,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const webpackOutput = result.toWebpack()
|
|
21
|
-
expect(webpackOutput.test).toEqual(bud.hooks.filter(`pattern.svg`))
|
|
22
|
-
expect(webpackOutput.include).toEqual([bud.path(`@src`)])
|
|
23
|
-
expect(webpackOutput.resourceQuery).toEqual(/inline/)
|
|
24
|
-
expect(webpackOutput.type).toEqual(`asset/inline`)
|
|
25
|
-
expect(webpackOutput.generator).toEqual(
|
|
26
|
-
expect.objectContaining({
|
|
27
|
-
dataUrl,
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {factory} from '@repo/test-kit'
|
|
2
|
-
import {describe, expect, it} from 'vitest'
|
|
3
|
-
|
|
4
|
-
import {toml} from './toml'
|
|
5
|
-
|
|
6
|
-
describe(`toml loader`, () => {
|
|
7
|
-
let bud
|
|
8
|
-
|
|
9
|
-
it(`should return a rule`, async () => {
|
|
10
|
-
bud = await factory()
|
|
11
|
-
const result = await toml({
|
|
12
|
-
filter: bud.hooks.filter,
|
|
13
|
-
makeItem: bud.build.makeItem,
|
|
14
|
-
makeLoader: bud.build.makeLoader,
|
|
15
|
-
makeRule: bud.build.makeRule,
|
|
16
|
-
isProduction: bud.isProduction,
|
|
17
|
-
path: bud.path,
|
|
18
|
-
resolve: bud.module.resolve,
|
|
19
|
-
})
|
|
20
|
-
const webpackOutput = result.toWebpack()
|
|
21
|
-
expect(webpackOutput.type).toEqual(`json`)
|
|
22
|
-
})
|
|
23
|
-
})
|
package/src/rule/index.test.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import {factory} from '@repo/test-kit'
|
|
2
|
-
import {beforeAll, describe, expect, it} from 'vitest'
|
|
3
|
-
|
|
4
|
-
import {Rule} from './index.js'
|
|
5
|
-
|
|
6
|
-
describe(`Build Rule`, function () {
|
|
7
|
-
let bud
|
|
8
|
-
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
bud = await factory()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it(`is constructable`, () => {
|
|
14
|
-
const rule = {test: /.foo$/}
|
|
15
|
-
expect(new Rule(() => bud, rule)).toBeInstanceOf(Rule)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it(`make`, () => {
|
|
19
|
-
const rule = {test: /.foo$/}
|
|
20
|
-
expect(new Rule(() => bud, rule).toWebpack()).toEqual({
|
|
21
|
-
test: /.foo$/,
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it(`getUse`, () => {
|
|
26
|
-
const input = [`md`]
|
|
27
|
-
const rule = new Rule(() => bud, {
|
|
28
|
-
test: /.foo$/,
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
use: input,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
expect(rule.getUse()).toEqual(input)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it(`setUse`, () => {
|
|
37
|
-
const input = [`raw`, `md`]
|
|
38
|
-
const rule = new Rule(() => bud, {test: /.foo$/})
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
rule.setUse(input)
|
|
41
|
-
|
|
42
|
-
expect(rule.use).toEqual(input)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it(`getTest`, () => {
|
|
46
|
-
const input = /.foo$/
|
|
47
|
-
const rule = new Rule(() => bud, {test: input})
|
|
48
|
-
|
|
49
|
-
expect(rule.getTest()).toEqual(input)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it(`setTest`, () => {
|
|
53
|
-
const input = () => /.js$/
|
|
54
|
-
const rule = new Rule(() => bud, {test: /.foo$/})
|
|
55
|
-
rule.setTest(input)
|
|
56
|
-
|
|
57
|
-
expect(rule.test).toEqual(input)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it(`getExclude`, () => {
|
|
61
|
-
const definition = {
|
|
62
|
-
test: /.foo$/,
|
|
63
|
-
exclude: [/.bar$/],
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const rule = new Rule(() => bud, definition)
|
|
67
|
-
|
|
68
|
-
expect(rule.exclude).toEqual(definition.exclude)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it(`setExclude from fn`, () => {
|
|
72
|
-
const rule = new Rule(() => bud, {test: /.foo$/})
|
|
73
|
-
|
|
74
|
-
const mutationFn = () => [/.js$/]
|
|
75
|
-
rule.setExclude(mutationFn)
|
|
76
|
-
|
|
77
|
-
expect(rule.getExclude()).toEqual([/.js$/])
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it(`setExclude from obj`, () => {
|
|
81
|
-
const rule = new Rule(() => bud, {test: /.foo$/})
|
|
82
|
-
|
|
83
|
-
const mutation = [/.js$/]
|
|
84
|
-
rule.setExclude(mutation)
|
|
85
|
-
|
|
86
|
-
expect(rule.getExclude()).toStrictEqual(mutation)
|
|
87
|
-
})
|
|
88
|
-
})
|
package/src/types.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type {Item} from '@roots/bud-build/item'
|
|
2
|
-
import type {Loader} from '@roots/bud-build/loader'
|
|
3
|
-
import type {Rule} from '@roots/bud-build/rule'
|
|
4
|
-
|
|
5
|
-
import type {Build} from './service.js'
|
|
6
|
-
|
|
7
|
-
declare module '@roots/bud-framework' {
|
|
8
|
-
interface Services {
|
|
9
|
-
build: Build
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Loaders {
|
|
13
|
-
css: Loader
|
|
14
|
-
csv: Loader
|
|
15
|
-
file: Loader
|
|
16
|
-
html: Loader
|
|
17
|
-
md: Loader
|
|
18
|
-
minicss: Loader
|
|
19
|
-
raw: Loader
|
|
20
|
-
style: Loader
|
|
21
|
-
url: Loader
|
|
22
|
-
yml: Loader
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface Items {
|
|
26
|
-
css: Item
|
|
27
|
-
cssModule: Item
|
|
28
|
-
csv: Item
|
|
29
|
-
file: Item
|
|
30
|
-
font: Item
|
|
31
|
-
html: Item
|
|
32
|
-
image: Item
|
|
33
|
-
md: Item
|
|
34
|
-
minicss: Item
|
|
35
|
-
precss: Item
|
|
36
|
-
raw: Item
|
|
37
|
-
style: Item
|
|
38
|
-
yml: Item
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface Rules {
|
|
42
|
-
css: Rule
|
|
43
|
-
cssModule: Rule
|
|
44
|
-
csv: Rule
|
|
45
|
-
font: Rule
|
|
46
|
-
html: Rule
|
|
47
|
-
image: Rule
|
|
48
|
-
inlineFont: Rule
|
|
49
|
-
inlineImage: Rule
|
|
50
|
-
inlineSvg: Rule
|
|
51
|
-
js: Rule
|
|
52
|
-
json: Rule
|
|
53
|
-
svg: Rule
|
|
54
|
-
toml: Rule
|
|
55
|
-
yml: Rule
|
|
56
|
-
}
|
|
57
|
-
}
|
|
File without changes
|
|
File without changes
|