@roots/bud-build 6.14.3 → 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.
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 +121 -37
  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
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const bail: Factory<'bail'>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const cache: Factory<`cache`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const context: Factory<`context`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const dependencies: Factory<`dependencies`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const devtool: Factory<`devtool`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const entry: Factory<`entry`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const experiments: Factory<`experiments`>;
@@ -1,5 +1,6 @@
1
1
  export const experiments = async ({ hooks, isDevelopment, }) => hooks.filter(`build.experiments`, {
2
2
  backCompat: false,
3
+ cacheUnaffected: true,
3
4
  lazyCompilation: isDevelopment
4
5
  ? { entries: false, imports: true }
5
6
  : false,
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const externals: Factory<`externals`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const externalsType: Factory<`externalsType`>;
@@ -1,35 +1,34 @@
1
1
  import type { Bud } from '@roots/bud-framework';
2
2
  import type { Configuration } from '@roots/bud-framework/config';
3
- import { bail } from './bail.js';
4
- import { cache } from './cache.js';
5
- import { context } from './context.js';
6
- import { dependencies } from './dependencies.js';
7
- import { devtool } from './devtool.js';
8
- import { entry } from './entry.js';
9
- import { experiments } from './experiments.js';
10
- import { externals } from './externals.js';
11
- import { externalsType } from './externalsType.js';
12
- import { infrastructureLogging } from './infrastructureLogging.js';
13
- import { loader } from './loader.js';
14
- import { mode } from './mode.js';
15
- import { module } from './module.js';
16
- import { name } from './name.js';
17
- import { node } from './node.js';
18
- import { optimization } from './optimization.js';
19
- import { output } from './output/index.js';
20
- import { parallelism } from './parallelism.js';
21
- import { performance } from './performance.js';
22
- import { plugins } from './plugins.js';
23
- import { profile } from './profile.js';
24
- import { recordsPath } from './recordsPath.js';
25
- import { resolve } from './resolve.js';
26
- import { resolveLoader } from './resolveLoader.js';
27
- import { snapshot } from './snapshot.js';
28
- import { stats } from './stats.js';
29
- import { target } from './target.js';
30
- export { bail, cache, context, dependencies, devtool, entry, experiments, externals, externalsType, infrastructureLogging, loader, mode, module, name, node, optimization, output, parallelism, performance, plugins, profile, recordsPath, resolve, resolveLoader, snapshot, stats, target, };
3
+ export { bail } from './bail.js';
4
+ export { cache } from './cache.js';
5
+ export { context } from './context.js';
6
+ export { dependencies } from './dependencies.js';
7
+ export { devtool } from './devtool.js';
8
+ export { entry } from './entry.js';
9
+ export { experiments } from './experiments.js';
10
+ export { externals } from './externals.js';
11
+ export { externalsType } from './externalsType.js';
12
+ export { infrastructureLogging } from './infrastructureLogging.js';
13
+ export { loader } from './loader.js';
14
+ export { mode } from './mode.js';
15
+ export { module } from './module.js';
16
+ export { name } from './name.js';
17
+ export { node } from './node.js';
18
+ export { optimization } from './optimization.js';
19
+ export { output } from './output/index.js';
20
+ export { parallelism } from './parallelism.js';
21
+ export { performance } from './performance.js';
22
+ export { plugins } from './plugins.js';
23
+ export { profile } from './profile.js';
24
+ export { recordsPath } from './recordsPath.js';
25
+ export { resolve } from './resolve.js';
26
+ export { resolveLoader } from './resolveLoader.js';
27
+ export { snapshot } from './snapshot.js';
28
+ export { stats } from './stats.js';
29
+ export { target } from './target.js';
31
30
  export interface Factory<Key extends keyof Config, Config = Configuration> {
32
- (app: Bud): Promise<Config[Key]>;
31
+ (app: Bud): Promise<Config[Key] | undefined>;
33
32
  }
34
33
  export type Records<Config = Configuration> = {
35
34
  [Key in keyof Config as `${Key & string}`]: Factory<Key, Config>;
@@ -1,28 +1,27 @@
1
- import { bail } from './bail.js';
2
- import { cache } from './cache.js';
3
- import { context } from './context.js';
4
- import { dependencies } from './dependencies.js';
5
- import { devtool } from './devtool.js';
6
- import { entry } from './entry.js';
7
- import { experiments } from './experiments.js';
8
- import { externals } from './externals.js';
9
- import { externalsType } from './externalsType.js';
10
- import { infrastructureLogging } from './infrastructureLogging.js';
11
- import { loader } from './loader.js';
12
- import { mode } from './mode.js';
13
- import { module } from './module.js';
14
- import { name } from './name.js';
15
- import { node } from './node.js';
16
- import { optimization } from './optimization.js';
17
- import { output } from './output/index.js';
18
- import { parallelism } from './parallelism.js';
19
- import { performance } from './performance.js';
20
- import { plugins } from './plugins.js';
21
- import { profile } from './profile.js';
22
- import { recordsPath } from './recordsPath.js';
23
- import { resolve } from './resolve.js';
24
- import { resolveLoader } from './resolveLoader.js';
25
- import { snapshot } from './snapshot.js';
26
- import { stats } from './stats.js';
27
- import { target } from './target.js';
28
- export { bail, cache, context, dependencies, devtool, entry, experiments, externals, externalsType, infrastructureLogging, loader, mode, module, name, node, optimization, output, parallelism, performance, plugins, profile, recordsPath, resolve, resolveLoader, snapshot, stats, target, };
1
+ export { bail } from './bail.js';
2
+ export { cache } from './cache.js';
3
+ export { context } from './context.js';
4
+ export { dependencies } from './dependencies.js';
5
+ export { devtool } from './devtool.js';
6
+ export { entry } from './entry.js';
7
+ export { experiments } from './experiments.js';
8
+ export { externals } from './externals.js';
9
+ export { externalsType } from './externalsType.js';
10
+ export { infrastructureLogging } from './infrastructureLogging.js';
11
+ export { loader } from './loader.js';
12
+ export { mode } from './mode.js';
13
+ export { module } from './module.js';
14
+ export { name } from './name.js';
15
+ export { node } from './node.js';
16
+ export { optimization } from './optimization.js';
17
+ export { output } from './output/index.js';
18
+ export { parallelism } from './parallelism.js';
19
+ export { performance } from './performance.js';
20
+ export { plugins } from './plugins.js';
21
+ export { profile } from './profile.js';
22
+ export { recordsPath } from './recordsPath.js';
23
+ export { resolve } from './resolve.js';
24
+ export { resolveLoader } from './resolveLoader.js';
25
+ export { snapshot } from './snapshot.js';
26
+ export { stats } from './stats.js';
27
+ export { target } from './target.js';
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const infrastructureLogging: Factory<`infrastructureLogging`>;
@@ -3,16 +3,16 @@ export const infrastructureLogging = async (bud) => bud.hooks.filter(`build.infr
3
3
  console: bud.hooks.filter(`build.infrastructureLogging.console`, {
4
4
  ...console,
5
5
  error: (...args) => {
6
- logger.scope(`webpack`).error(...args);
6
+ logger.scope(bud.label, `webpack`).error(...args);
7
7
  },
8
8
  info: (...args) => {
9
- logger.scope(`webpack`).info(...args);
9
+ logger.scope(bud.label, `webpack`).info(...args);
10
10
  },
11
11
  log: (...args) => {
12
- logger.scope(`webpack`).log(...args);
12
+ logger.scope(bud.label, `webpack`).log(...args);
13
13
  },
14
14
  warn: (...args) => {
15
- logger.scope(`webpack`).info(...args);
15
+ logger.scope(bud.label, `webpack`).info(...args);
16
16
  },
17
17
  }),
18
18
  level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const loader: Factory<`loader`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const mode: Factory<`mode`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const module: Factory<`module`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const name: Factory<`name`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const node: Factory<`node`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const optimization: Factory<`optimization`>;
@@ -12,7 +12,7 @@ export const optimization = async ({ hooks: { filter }, isDevelopment, isProduct
12
12
  * @see {@link https://webpack.js.org/configuration/optimization/#optimizationremoveavailablemodules}
13
13
  */
14
14
  removeAvailableModules: filter(`build.optimization.removeAvailableModules`, false),
15
- removeEmptyChunks: filter(`build.optimization.removeEmptyChunks`, isProduction),
15
+ removeEmptyChunks: filter(`build.optimization.removeEmptyChunks`, false),
16
16
  runtimeChunk: filter(`build.optimization.runtimeChunk`, `single`),
17
17
  sideEffects: filter(`build.optimization.sideEffects`, isProduction),
18
18
  splitChunks: filter(`build.optimization.splitChunks`, false),
@@ -1 +1 @@
1
- export const assetModuleFilename = ({ filter, relPath }) => filter(`build.output.assetModuleFilename`, relPath(`@file`));
1
+ export const assetModuleFilename = ({ filter, relPath }) => filter(`build.output.assetModuleFilename`, relPath(`@file[query]`));
@@ -1,2 +1,2 @@
1
- import { scriptExtension } from '../../helpers/scriptExtension.js';
1
+ import scriptExtension from '@roots/bud-build/helpers/script-extension';
2
2
  export const filename = ({ filter, relPath }) => filter(`build.output.filename`, relPath(`js`, `@name${scriptExtension(filter, `.mjs`, `.js`)}`));
@@ -1,2 +1,2 @@
1
- import type { Factory } from '../index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const output: Factory<`output`>;
@@ -1,4 +1,3 @@
1
- import { isMjs } from '../../helpers/isMjs.js';
2
1
  import { assetModuleFilename } from './assetModuleFilename.js';
3
2
  import { filename } from './filename.js';
4
3
  export const output = async ({ hooks: { filter }, isProduction, path, relPath, }) => filter(`build.output`, {
@@ -15,8 +14,14 @@ export const output = async ({ hooks: { filter }, isProduction, path, relPath, }
15
14
  iife: filter(`build.output.iife`, undefined),
16
15
  module: filter(`build.output.module`, false),
17
16
  path: filter(`build.output.path`, path(`@dist`)),
17
+ /**
18
+ * Path info is not necessary unless the user
19
+ * really knows what's going on.
20
+ *
21
+ * @see {@link https://medium.com/@kenneth_chau/speeding-up-webpack-typescript-incremental-builds-by-7x-3912ba4c1d15}
22
+ */
18
23
  pathinfo: filter(`build.output.pathinfo`, false),
19
24
  publicPath: filter(`build.output.publicPath`, `auto`),
20
- scriptType: filter(`build.output.scriptType`, isMjs(filter) ? `module` : `text/javascript`),
25
+ scriptType: filter(`build.output.scriptType`, undefined),
21
26
  uniqueName: filter(`build.output.uniqueName`, `@roots/bud`),
22
27
  });
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const parallelism: Factory<`parallelism`>;
@@ -1,9 +1,10 @@
1
1
  import { cpus } from 'node:os';
2
- export const parallelism = async ({ hooks, root, }) => {
3
- const factor = 10;
4
- const procs = Math.min(cpus().length - 1, 1);
5
- const comps = root.hasChildren
6
- ? Math.min(Object.keys(root.children).length)
7
- : 1;
8
- return hooks.filter(`build.parallelism`, (procs * factor) / comps);
2
+ export const parallelism = async ({ build, hooks, root, }) => {
3
+ const concurrency = 100;
4
+ const cores = Math.max(cpus().length, 1);
5
+ const available = cores * concurrency;
6
+ const compilations = Math.max(Object.keys(root.children ?? []).length, 1);
7
+ const parallelism = Math.max(Math.floor(available / compilations), 1);
8
+ build.logger.info(`parallelism set to`, parallelism);
9
+ return hooks.filter(`build.parallelism`, parallelism);
9
10
  };
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const performance: Factory<`performance`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const plugins: Factory<`plugins`>;
@@ -1 +1,4 @@
1
- export const plugins = async (app) => await app.hooks.filterAsync(`build.plugins`, await app.extensions.make());
1
+ export const plugins = async (app) => {
2
+ const plugins = await app.extensions.make();
3
+ return await app.hooks.filterAsync(`build.plugins`, plugins);
4
+ };
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const profile: Factory<`profile`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const recordsPath: Factory<`recordsPath`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const resolve: Factory<`resolve`>;
@@ -9,7 +9,7 @@ export const resolve = async (bud) => {
9
9
  [`.js`]: [`.ts`, `.tsx`, `.js`],
10
10
  [`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
11
11
  }),
12
- extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.jsx`, `.css`]))),
12
+ extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.css`]))),
13
13
  modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
14
14
  bud.hooks.filter(`location.@src`),
15
15
  bud.hooks.filter(`location.@modules`),
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const resolveLoader: Factory<`resolveLoader`>;
@@ -3,9 +3,6 @@ export const resolveLoader = async ({ hooks, module, }) => hooks.filter(`build.r
3
3
  'css-loader': await module.resolve(`@roots/bud-support/css-loader`),
4
4
  'file-loader': await module.resolve(`@roots/bud-support/file-loader`),
5
5
  'html-loader': await module.resolve(`@roots/bud-support/html-loader`),
6
- json5: await module.resolve(`@roots/bud-support/json5`),
7
- 'mini-svg-data-uri': await module.resolve(`mini-svg-data-uri`),
8
6
  'style-loader': await module.resolve(`@roots/bud-support/style-loader`),
9
- toml: await module.resolve(`@roots/bud-support/toml`),
10
7
  }),
11
8
  });
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const snapshot: Factory<`snapshot`>;
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const stats: Factory<`stats`>;
@@ -1,19 +1 @@
1
- export const stats = async (app) => app.hooks.filter(`build.stats`, app.isProduction
2
- ? {
3
- all: false,
4
- assets: true,
5
- assetsSort: `size`,
6
- builtAt: false,
7
- children: false,
8
- chunks: false,
9
- entrypoints: true,
10
- errors: true,
11
- errorsCount: true,
12
- hash: true,
13
- modules: true,
14
- outputPath: true,
15
- timings: true,
16
- warnings: true,
17
- warningsCount: true,
18
- }
19
- : { preset: `none` });
1
+ export const stats = async (app) => app.hooks.filter(`build.stats`, { preset: `none` });
@@ -1,2 +1,2 @@
1
- import type { Factory } from './index.js';
1
+ import type { Factory } from '@roots/bud-build/config';
2
2
  export declare const target: Factory<`target`>;
@@ -1,2 +1,3 @@
1
1
  import type { Bud } from '@roots/bud-framework';
2
- export declare const isMjs: (filter: Bud[`hooks`][`filter`]) => boolean;
2
+ declare const isMjs: (filter: Bud[`hooks`][`filter`]) => boolean;
3
+ export { isMjs as default };
@@ -1 +1,2 @@
1
- export const isMjs = (filter) => filter(`build.experiments`)?.outputModule === true;
1
+ const isMjs = (filter) => filter(`build.experiments`)?.outputModule === true;
2
+ export { isMjs as default };
@@ -1,6 +1,6 @@
1
1
  import type { Bud } from '@roots/bud-framework';
2
2
  import type { Base as BuildBase } from '@roots/bud-framework/services/build';
3
- export default class Base implements BuildBase {
3
+ declare class Registrable implements BuildBase {
4
4
  _app: () => Bud;
5
5
  /**
6
6
  * Constructor
@@ -15,3 +15,4 @@ export default class Base implements BuildBase {
15
15
  unwrap<T = any>(maybeFunction: ((app: Bud, ...options: Array<any>) => T) | T, ...options: Array<any>): T;
16
16
  wrap<T = any>(input: ((app: Bud) => T) | T): (app: Bud) => T;
17
17
  }
18
+ export { Registrable as default };
@@ -1,8 +1,7 @@
1
- var _a, _b, _c;
2
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
3
2
  import { bind } from '@roots/bud-support/decorators/bind';
4
3
  import isFunction from '@roots/bud-support/lodash/isFunction';
5
- export default class Base {
4
+ class Registrable {
6
5
  _app;
7
6
  /**
8
7
  * Constructor
@@ -28,14 +27,9 @@ export default class Base {
28
27
  }
29
28
  }
30
29
  __decorate([
31
- bind,
32
- __metadata("design:type", Function),
33
- __metadata("design:paramtypes", [Object, Object]),
34
- __metadata("design:returntype", typeof (_b = typeof T !== "undefined" && T) === "function" ? _b : Object)
35
- ], Base.prototype, "unwrap", null);
30
+ bind
31
+ ], Registrable.prototype, "unwrap", null);
36
32
  __decorate([
37
- bind,
38
- __metadata("design:type", Function),
39
- __metadata("design:paramtypes", [Object]),
40
- __metadata("design:returntype", Function)
41
- ], Base.prototype, "wrap", null);
33
+ bind
34
+ ], Registrable.prototype, "wrap", null);
35
+ export { Registrable as default };
@@ -0,0 +1,3 @@
1
+ import type { Bud } from '@roots/bud-framework';
2
+ declare const scriptExtension: (filter: Bud[`hooks`][`filter`], mjs?: `.${string}`, js?: `.${string}`) => `.${string}`;
3
+ export { scriptExtension as default };
@@ -0,0 +1,5 @@
1
+ import isMjs from '@roots/bud-build/helpers/isMjs';
2
+ const scriptExtension = (filter, mjs = `.mjs`, js = `.js`) => {
3
+ return isMjs(filter) ? mjs : js;
4
+ };
5
+ export { scriptExtension as default };
package/lib/index.d.ts CHANGED
@@ -4,10 +4,56 @@
4
4
  * @see https://bud.js.org
5
5
  * @see https://github.com/roots/bud
6
6
  */
7
- import { Item } from './item/index.js';
8
- import { Loader } from './loader/index.js';
9
- import { Rule } from './rule/index.js';
10
- import { Build } from './service.js';
11
- import './types.js';
12
- export default Build;
13
- export { Item, Loader, Rule };
7
+ import { default as Item } from '@roots/bud-build/item';
8
+ import { default as Loader } from '@roots/bud-build/loader';
9
+ import { default as Rule } from '@roots/bud-build/rule';
10
+ import { default as Build } from '@roots/bud-build/service';
11
+ declare module '@roots/bud-framework' {
12
+ interface Services {
13
+ build: Build;
14
+ }
15
+ interface Loaders {
16
+ css: Loader;
17
+ csv: Loader;
18
+ file: Loader;
19
+ html: Loader;
20
+ md: Loader;
21
+ minicss: Loader;
22
+ raw: Loader;
23
+ style: Loader;
24
+ url: Loader;
25
+ yml: Loader;
26
+ }
27
+ interface Items {
28
+ css: Item;
29
+ cssModule: Item;
30
+ csv: Item;
31
+ file: Item;
32
+ font: Item;
33
+ html: Item;
34
+ image: Item;
35
+ md: Item;
36
+ minicss: Item;
37
+ precss: Item;
38
+ raw: Item;
39
+ style: Item;
40
+ yml: Item;
41
+ }
42
+ interface Rules {
43
+ css: Rule;
44
+ cssModule: Rule;
45
+ csv: Rule;
46
+ font: Rule;
47
+ html: Rule;
48
+ image: Rule;
49
+ inlineFont: Rule;
50
+ inlineImage: Rule;
51
+ inlineSvg: Rule;
52
+ js: Rule;
53
+ json: Rule;
54
+ svg: Rule;
55
+ toml: Rule;
56
+ yml: Rule;
57
+ }
58
+ }
59
+ export { Build as default, Item, Loader, Rule };
package/lib/index.js CHANGED
@@ -6,10 +6,8 @@
6
6
  * @see https://bud.js.org
7
7
  * @see https://github.com/roots/bud
8
8
  */
9
- import { Item } from './item/index.js';
10
- import { Loader } from './loader/index.js';
11
- import { Rule } from './rule/index.js';
12
- import { Build } from './service.js';
13
- import './types.js';
14
- export default Build;
15
- export { Item, Loader, Rule };
9
+ import { default as Item } from '@roots/bud-build/item';
10
+ import { default as Loader } from '@roots/bud-build/loader';
11
+ import { default as Rule } from '@roots/bud-build/rule';
12
+ import { default as Build } from '@roots/bud-build/service';
13
+ export { Build as default, Item, Loader, Rule };
@@ -1,12 +1,12 @@
1
1
  import type { Bud, Loaders } from '@roots/bud-framework';
2
2
  import type * as Build from '@roots/bud-framework/services/build';
3
- import { Loader } from '../loader/index.js';
4
- import Base from '../shared/base.js';
3
+ import Registrable from '@roots/bud-build/helpers/registrable';
4
+ import Loader from '@roots/bud-build/loader';
5
5
  export type ConstructorOptions = Build.Item.ConstructorOptions;
6
6
  /**
7
7
  * Item class
8
8
  */
9
- declare class Item extends Base implements Build.Item {
9
+ declare class Item extends Registrable implements Build.Item {
10
10
  _app: () => Bud;
11
11
  /**
12
12
  * Identifier
@@ -55,4 +55,4 @@ declare class Item extends Base implements Build.Item {
55
55
  */
56
56
  toWebpack(): Build.Item.Output;
57
57
  }
58
- export { Item };
58
+ export { Item as default };