@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.
Files changed (196) hide show
  1. package/lib/config/bail.d.ts +1 -1
  2. package/lib/config/cache.d.ts +1 -1
  3. package/lib/config/context.d.ts +1 -1
  4. package/lib/config/dependencies.d.ts +1 -1
  5. package/lib/config/devtool.d.ts +1 -1
  6. package/lib/config/entry.d.ts +1 -1
  7. package/lib/config/experiments.d.ts +1 -1
  8. package/lib/config/experiments.js +1 -0
  9. package/lib/config/externals.d.ts +1 -1
  10. package/lib/config/externalsType.d.ts +1 -1
  11. package/lib/config/index.d.ts +28 -29
  12. package/lib/config/index.js +27 -28
  13. package/lib/config/infrastructureLogging.d.ts +1 -1
  14. package/lib/config/infrastructureLogging.js +4 -4
  15. package/lib/config/loader.d.ts +1 -1
  16. package/lib/config/mode.d.ts +1 -1
  17. package/lib/config/module.d.ts +1 -1
  18. package/lib/config/name.d.ts +1 -1
  19. package/lib/config/node.d.ts +1 -1
  20. package/lib/config/optimization.d.ts +1 -1
  21. package/lib/config/optimization.js +1 -1
  22. package/lib/config/output/assetModuleFilename.js +1 -1
  23. package/lib/config/output/filename.js +1 -1
  24. package/lib/config/output/index.d.ts +1 -1
  25. package/lib/config/output/index.js +7 -2
  26. package/lib/config/parallelism.d.ts +1 -1
  27. package/lib/config/parallelism.js +8 -7
  28. package/lib/config/performance.d.ts +1 -1
  29. package/lib/config/plugins.d.ts +1 -1
  30. package/lib/config/plugins.js +4 -1
  31. package/lib/config/profile.d.ts +1 -1
  32. package/lib/config/recordsPath.d.ts +1 -1
  33. package/lib/config/resolve.d.ts +1 -1
  34. package/lib/config/resolve.js +1 -1
  35. package/lib/config/resolveLoader.d.ts +1 -1
  36. package/lib/config/resolveLoader.js +0 -3
  37. package/lib/config/snapshot.d.ts +1 -1
  38. package/lib/config/stats.d.ts +1 -1
  39. package/lib/config/stats.js +1 -19
  40. package/lib/config/target.d.ts +1 -1
  41. package/lib/helpers/isMjs.d.ts +2 -1
  42. package/lib/helpers/isMjs.js +2 -1
  43. package/lib/{shared/base.d.ts → helpers/registrable.d.ts} +2 -1
  44. package/lib/{shared/base.js → helpers/registrable.js} +7 -13
  45. package/lib/helpers/script-extension.d.ts +3 -0
  46. package/lib/helpers/script-extension.js +5 -0
  47. package/lib/index.d.ts +53 -7
  48. package/lib/index.js +5 -7
  49. package/lib/item/index.d.ts +4 -4
  50. package/lib/item/index.js +14 -38
  51. package/lib/{handlers/items/items.d.ts → items/index.d.ts} +1 -1
  52. package/lib/loader/index.d.ts +4 -4
  53. package/lib/loader/index.js +4 -4
  54. package/lib/{handlers/loaders/loaders.d.ts → loaders/index.d.ts} +1 -1
  55. package/lib/registry/index.d.ts +36 -0
  56. package/lib/{handlers/register.js → registry/index.js} +9 -5
  57. package/lib/rule/index.d.ts +3 -3
  58. package/lib/rule/index.js +22 -76
  59. package/lib/rules/css.d.ts +3 -0
  60. package/lib/{handlers/rules → rules}/css.js +2 -1
  61. package/lib/rules/css.module.d.ts +3 -0
  62. package/lib/{handlers/rules → rules}/css.module.js +2 -1
  63. package/lib/rules/csv.d.ts +3 -0
  64. package/lib/{handlers/rules → rules}/csv.js +2 -1
  65. package/lib/rules/font.d.ts +3 -0
  66. package/lib/rules/font.inline.d.ts +3 -0
  67. package/lib/{handlers/rules → rules}/font.inline.js +2 -1
  68. package/lib/{handlers/rules → rules}/font.js +2 -1
  69. package/lib/rules/html.d.ts +3 -0
  70. package/lib/{handlers/rules → rules}/html.js +2 -1
  71. package/lib/rules/image.d.ts +3 -0
  72. package/lib/rules/image.inline.d.ts +3 -0
  73. package/lib/{handlers/rules → rules}/image.inline.js +2 -1
  74. package/lib/rules/image.js +8 -0
  75. package/lib/rules/index.d.ts +15 -0
  76. package/lib/rules/index.js +15 -0
  77. package/lib/rules/js.d.ts +3 -0
  78. package/lib/{handlers/rules → rules}/js.js +2 -1
  79. package/lib/rules/json.d.ts +3 -0
  80. package/lib/{handlers/rules → rules}/json.js +2 -1
  81. package/lib/rules/svg.d.ts +3 -0
  82. package/lib/rules/svg.inline.d.ts +5 -0
  83. package/lib/{handlers/rules → rules}/svg.inline.js +3 -2
  84. package/lib/{handlers/rules → rules}/svg.js +2 -1
  85. package/lib/rules/toml.d.ts +3 -0
  86. package/lib/{handlers/rules → rules}/toml.js +2 -1
  87. package/lib/rules/webp.d.ts +3 -0
  88. package/lib/{handlers/rules → rules}/webp.js +2 -1
  89. package/lib/rules/yml.d.ts +3 -0
  90. package/lib/{handlers/rules → rules}/yml.js +2 -1
  91. package/lib/{service.d.ts → service/index.d.ts} +27 -24
  92. package/lib/{service.js → service/index.js} +45 -70
  93. package/package.json +122 -38
  94. package/src/config/bail.ts +1 -1
  95. package/src/config/cache.ts +1 -1
  96. package/src/config/context.ts +1 -1
  97. package/src/config/dependencies.ts +2 -2
  98. package/src/config/devtool.ts +1 -1
  99. package/src/config/entry.ts +1 -1
  100. package/src/config/experiments.ts +2 -1
  101. package/src/config/externals.ts +1 -1
  102. package/src/config/externalsType.ts +1 -1
  103. package/src/config/index.ts +28 -58
  104. package/src/config/infrastructureLogging.ts +6 -6
  105. package/src/config/loader.ts +1 -1
  106. package/src/config/mode.ts +1 -1
  107. package/src/config/module.ts +1 -2
  108. package/src/config/name.ts +1 -1
  109. package/src/config/node.ts +1 -1
  110. package/src/config/optimization.ts +2 -2
  111. package/src/config/output/assetModuleFilename.ts +1 -1
  112. package/src/config/output/filename.ts +1 -1
  113. package/src/config/output/index.ts +8 -6
  114. package/src/config/parallelism.ts +11 -8
  115. package/src/config/performance.ts +1 -1
  116. package/src/config/plugins.ts +5 -3
  117. package/src/config/profile.ts +1 -1
  118. package/src/config/recordsPath.ts +1 -1
  119. package/src/config/resolve.ts +3 -3
  120. package/src/config/resolveLoader.ts +1 -4
  121. package/src/config/snapshot.ts +1 -1
  122. package/src/config/stats.ts +2 -23
  123. package/src/config/target.ts +1 -1
  124. package/src/helpers/isMjs.ts +3 -1
  125. package/src/{shared/base.ts → helpers/registrable.ts} +3 -1
  126. package/src/helpers/{scriptExtension.ts → script-extension.ts} +4 -2
  127. package/src/index.ts +56 -7
  128. package/src/item/index.ts +5 -6
  129. package/src/{handlers/items/items.ts → items/index.ts} +1 -2
  130. package/src/loader/index.ts +6 -5
  131. package/src/{handlers/loaders/loaders.ts → loaders/index.ts} +1 -2
  132. package/src/{handlers/register.ts → registry/index.ts} +36 -13
  133. package/src/rule/index.ts +3 -4
  134. package/src/rules/css.module.ts +9 -0
  135. package/src/rules/css.ts +9 -0
  136. package/src/rules/csv.ts +9 -0
  137. package/src/rules/font.inline.ts +10 -0
  138. package/src/rules/font.ts +9 -0
  139. package/src/rules/html.ts +9 -0
  140. package/src/rules/image.inline.ts +10 -0
  141. package/src/rules/image.ts +12 -0
  142. package/src/rules/index.ts +15 -0
  143. package/src/{handlers/rules → rules}/js.ts +4 -2
  144. package/src/{handlers/rules → rules}/json.ts +5 -3
  145. package/src/{handlers/rules → rules}/svg.inline.ts +6 -4
  146. package/src/rules/svg.ts +9 -0
  147. package/src/{handlers/rules → rules}/toml.ts +5 -3
  148. package/src/rules/webp.ts +9 -0
  149. package/src/rules/yml.ts +9 -0
  150. package/src/{service.ts → service/index.ts} +43 -36
  151. package/lib/handlers/index.d.ts +0 -19
  152. package/lib/handlers/index.js +0 -5
  153. package/lib/handlers/register.d.ts +0 -13
  154. package/lib/handlers/rules/css.d.ts +0 -2
  155. package/lib/handlers/rules/css.module.d.ts +0 -2
  156. package/lib/handlers/rules/csv.d.ts +0 -2
  157. package/lib/handlers/rules/font.d.ts +0 -2
  158. package/lib/handlers/rules/font.inline.d.ts +0 -2
  159. package/lib/handlers/rules/html.d.ts +0 -2
  160. package/lib/handlers/rules/image.d.ts +0 -2
  161. package/lib/handlers/rules/image.inline.d.ts +0 -2
  162. package/lib/handlers/rules/image.js +0 -4
  163. package/lib/handlers/rules/index.d.ts +0 -17
  164. package/lib/handlers/rules/index.js +0 -32
  165. package/lib/handlers/rules/js.d.ts +0 -2
  166. package/lib/handlers/rules/json.d.ts +0 -2
  167. package/lib/handlers/rules/svg.d.ts +0 -2
  168. package/lib/handlers/rules/svg.inline.d.ts +0 -4
  169. package/lib/handlers/rules/toml.d.ts +0 -2
  170. package/lib/handlers/rules/webp.d.ts +0 -2
  171. package/lib/handlers/rules/yml.d.ts +0 -2
  172. package/lib/helpers/scriptExtension.d.ts +0 -2
  173. package/lib/helpers/scriptExtension.js +0 -4
  174. package/lib/types.d.ts +0 -52
  175. package/lib/types.js +0 -1
  176. package/src/config/index.test.ts +0 -125
  177. package/src/handlers/index.ts +0 -24
  178. package/src/handlers/rules/css.module.ts +0 -7
  179. package/src/handlers/rules/css.ts +0 -7
  180. package/src/handlers/rules/csv.test.ts +0 -31
  181. package/src/handlers/rules/csv.ts +0 -7
  182. package/src/handlers/rules/font.inline.ts +0 -8
  183. package/src/handlers/rules/font.ts +0 -7
  184. package/src/handlers/rules/html.ts +0 -7
  185. package/src/handlers/rules/image.inline.ts +0 -8
  186. package/src/handlers/rules/image.ts +0 -7
  187. package/src/handlers/rules/index.ts +0 -33
  188. package/src/handlers/rules/svg.inline.test.ts +0 -31
  189. package/src/handlers/rules/svg.ts +0 -7
  190. package/src/handlers/rules/toml.test.ts +0 -23
  191. package/src/handlers/rules/webp.ts +0 -7
  192. package/src/handlers/rules/yml.ts +0 -7
  193. package/src/rule/index.test.ts +0 -88
  194. package/src/types.ts +0 -57
  195. /package/lib/{handlers/items/items.js → items/index.js} +0 -0
  196. /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 {};
@@ -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
- })
@@ -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,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const cssModule: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.cssModule`))
6
- .setInclude([() => path(`@src`)])
7
- .setUse([`precss`, `cssModule`])
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const css: Factory = async ({filter, makeRule}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.css`))
6
- .setInclude([({path}) => path(`@src`)])
7
- .setUse([`precss`, `css`])
@@ -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,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const csv: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setInclude([path()])
6
- .setTest(() => filter(`pattern.csv`))
7
- .setUse([`csv`])
@@ -1,8 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const inlineFont: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.font`))
6
- .setInclude([() => path(`@src`)])
7
- .setResourceQuery(/inline/)
8
- .setType(`asset/inline`)
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const font: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setType(`asset`)
6
- .setTest(filter(`pattern.font`))
7
- .setInclude([() => path(`@src`)])
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const html: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setInclude([() => path()])
6
- .setTest(filter(`pattern.html`))
7
- .setUse([`html`])
@@ -1,8 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const inlineImage: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.image`))
6
- .setInclude([() => path(`@src`)])
7
- .setType(`asset/inline`)
8
- .setResourceQuery(/inline/)
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const image: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.image`))
6
- .setInclude([() => path(`@src`)])
7
- .setType(`asset/resource`)
@@ -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,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const svg: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.svg`))
6
- .setInclude([() => path(`@src`)])
7
- .setType(`asset/resource`)
@@ -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
- })
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const webp: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(filter(`pattern.webp`))
6
- .setInclude([() => path(`@src`)])
7
- .setType(`asset/resource`)
@@ -1,7 +0,0 @@
1
- import type {Factory} from '../index.js'
2
-
3
- export const yml: Factory = async ({filter, makeRule, path}) =>
4
- makeRule()
5
- .setTest(() => filter(`pattern.yml`))
6
- .setInclude([() => path()])
7
- .setUse([`yml`])
@@ -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