@roots/bud-build 2023.6.5 → 2023.6.7

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.
@@ -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
- runtimeChunk: filter(`build.optimization.runtimeChunk`, false),
15
+ runtimeChunk: filter(`build.optimization.runtimeChunk`, `single`),
16
16
  sideEffects: filter(`build.optimization.sideEffects`, isProduction),
17
17
  splitChunks: filter(`build.optimization.splitChunks`, false),
18
18
  providedExports: filter(`build.optimization.providedExports`, isProduction),
@@ -8,7 +8,7 @@ export const resolve = async (bud) => {
8
8
  [`.js`]: [`.ts`, `.tsx`, `.js`],
9
9
  [`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
10
10
  }),
11
- extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.jsx`, `.cjs`, `.css`]))),
11
+ extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.jsx`, `.css`]))),
12
12
  modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
13
13
  bud.hooks.filter(`location.@src`),
14
14
  bud.hooks.filter(`location.@modules`),
@@ -1,7 +1,6 @@
1
1
  export const js = async ({ filter, makeRule, path }) => makeRule()
2
2
  .setTest(filter(`pattern.js`))
3
3
  .setInclude([() => path(`@src`)])
4
- .setType(`javascript/auto`)
5
4
  .setResolve({
6
5
  fullySpecified: false,
7
6
  });
package/lib/item/index.js CHANGED
@@ -8,6 +8,19 @@ import Base from '../shared/base.js';
8
8
  * Item class
9
9
  */
10
10
  class Item extends Base {
11
+ _app;
12
+ /**
13
+ * Identifier
14
+ */
15
+ ident;
16
+ /**
17
+ * Loader
18
+ */
19
+ loader;
20
+ /**
21
+ * Loader options
22
+ */
23
+ options;
11
24
  /**
12
25
  * Class constructor
13
26
  */
@@ -3,6 +3,11 @@ import Base from '../shared/base.js';
3
3
  * Bud Loader
4
4
  */
5
5
  class Loader extends Base {
6
+ _app;
7
+ /**
8
+ * Factory returning the loader path
9
+ */
10
+ src;
6
11
  /**
7
12
  * Class constructor
8
13
  *
package/lib/rule/index.js CHANGED
@@ -7,6 +7,42 @@ import Base from '../shared/base.js';
7
7
  * RuleSetRule
8
8
  */
9
9
  class Rule extends Base {
10
+ /**
11
+ * RuleSetRule resolve
12
+ */
13
+ resolve;
14
+ /**
15
+ * RuleSetRule test
16
+ */
17
+ test;
18
+ /**
19
+ * RuleSetRule use
20
+ */
21
+ use;
22
+ /**
23
+ * RuleSetRule include
24
+ */
25
+ include;
26
+ /**
27
+ * RuleSetRule exclude
28
+ */
29
+ exclude;
30
+ /**
31
+ * RuleSetRule type
32
+ */
33
+ type;
34
+ /**
35
+ * RuleSetRule resourceQuery
36
+ */
37
+ resourceQuery;
38
+ /**
39
+ * RuleSetRule parser
40
+ */
41
+ parser;
42
+ /**
43
+ * RuleSetRule generator
44
+ */
45
+ generator;
10
46
  /**
11
47
  * Class constructor
12
48
  */
package/lib/service.d.ts CHANGED
@@ -43,14 +43,6 @@ export declare class Build extends Service implements Base.Service {
43
43
  * Get rule
44
44
  */
45
45
  getRule<K extends `${keyof Rules & string}`>(ident: K): Rules[K];
46
- /**
47
- * Set Rule
48
- */
49
- setRule<K extends `${keyof Rules & string}`>(name: K, input?: RuleOptions | Rule): this;
50
- /**
51
- * Make Rule
52
- */
53
- makeRule(options?: RuleOptions): Rule;
54
46
  /**
55
47
  * Get loader
56
48
  */
@@ -75,4 +67,12 @@ export declare class Build extends Service implements Base.Service {
75
67
  * Make item
76
68
  */
77
69
  makeItem(options?: Partial<Item['options']>): Item;
70
+ /**
71
+ * Set Rule
72
+ */
73
+ setRule<K extends `${keyof Rules & string}`>(name: K, input?: RuleOptions | Rule): this;
74
+ /**
75
+ * Make Rule
76
+ */
77
+ makeRule(options?: RuleOptions): Rule;
78
78
  }
package/lib/service.js CHANGED
@@ -12,33 +12,30 @@ import { Rule } from './rule/index.js';
12
12
  * Webpack configuration builder class
13
13
  */
14
14
  export class Build extends Service {
15
- constructor() {
16
- super(...arguments);
17
- /**
18
- * Built config object
19
- */
20
- this.config = {};
21
- /**
22
- * Registered loaders
23
- */
24
- this.loaders = {};
25
- /**
26
- * Registered rules
27
- */
28
- this.rules = {};
29
- /**
30
- * Registered items
31
- */
32
- this.items = {};
33
- /**
34
- * Service register event
35
- *
36
- * @remarks
37
- * `loaders`, `items`, and `rules` are instantiated dumbly
38
- * because it is painful to think about how to map the typings..
39
- */
40
- this.register = register.bind(this);
41
- }
15
+ /**
16
+ * Built config object
17
+ */
18
+ config = {};
19
+ /**
20
+ * Registered loaders
21
+ */
22
+ loaders = {};
23
+ /**
24
+ * Registered rules
25
+ */
26
+ rules = {};
27
+ /**
28
+ * Registered items
29
+ */
30
+ items = {};
31
+ /**
32
+ * Service register event
33
+ *
34
+ * @remarks
35
+ * `loaders`, `items`, and `rules` are instantiated dumbly
36
+ * because it is painful to think about how to map the typings..
37
+ */
38
+ register = register.bind(this);
42
39
  /**
43
40
  * Make webpack configuration
44
41
  */
@@ -67,24 +64,6 @@ export class Build extends Service {
67
64
  getRule(ident) {
68
65
  return this.rules[ident];
69
66
  }
70
- /**
71
- * Set Rule
72
- */
73
- setRule(name, input) {
74
- this.rules[name] =
75
- input instanceof Rule
76
- ? input
77
- : isFunction(input)
78
- ? input(this.makeRule())
79
- : this.makeRule(input);
80
- return this;
81
- }
82
- /**
83
- * Make Rule
84
- */
85
- makeRule(options) {
86
- return new Rule(() => this.app, options);
87
- }
88
67
  /**
89
68
  * Get loader
90
69
  */
@@ -110,7 +89,7 @@ export class Build extends Service {
110
89
  * Make loader
111
90
  */
112
91
  makeLoader(src, definition) {
113
- return new Loader(() => this.app, src);
92
+ return new Loader(() => this.app, src, definition);
114
93
  }
115
94
  /**
116
95
  * Get item
@@ -140,6 +119,24 @@ export class Build extends Service {
140
119
  makeItem(options) {
141
120
  return new Item(() => this.app, options);
142
121
  }
122
+ /**
123
+ * Set Rule
124
+ */
125
+ setRule(name, input) {
126
+ this.rules[name] =
127
+ input instanceof Rule
128
+ ? input
129
+ : isFunction(input)
130
+ ? input(this.makeRule())
131
+ : this.makeRule(input);
132
+ return this;
133
+ }
134
+ /**
135
+ * Make Rule
136
+ */
137
+ makeRule(options) {
138
+ return new Rule(() => this.app, options);
139
+ }
143
140
  }
144
141
  __decorate([
145
142
  bind,
@@ -153,18 +150,6 @@ __decorate([
153
150
  __metadata("design:paramtypes", [typeof (_a = typeof K !== "undefined" && K) === "function" ? _a : Object]),
154
151
  __metadata("design:returntype", Object)
155
152
  ], Build.prototype, "getRule", null);
156
- __decorate([
157
- bind,
158
- __metadata("design:type", Function),
159
- __metadata("design:paramtypes", [typeof (_b = typeof K !== "undefined" && K) === "function" ? _b : Object, Object]),
160
- __metadata("design:returntype", Object)
161
- ], Build.prototype, "setRule", null);
162
- __decorate([
163
- bind,
164
- __metadata("design:type", Function),
165
- __metadata("design:paramtypes", [Object]),
166
- __metadata("design:returntype", Rule)
167
- ], Build.prototype, "makeRule", null);
168
153
  __decorate([
169
154
  bind,
170
155
  __metadata("design:type", Function),
@@ -174,7 +159,7 @@ __decorate([
174
159
  __decorate([
175
160
  bind,
176
161
  __metadata("design:type", Function),
177
- __metadata("design:paramtypes", [typeof (_c = typeof K !== "undefined" && K) === "function" ? _c : Object, Object]),
162
+ __metadata("design:paramtypes", [typeof (_b = typeof K !== "undefined" && K) === "function" ? _b : Object, Object]),
178
163
  __metadata("design:returntype", Object)
179
164
  ], Build.prototype, "setLoader", null);
180
165
  __decorate([
@@ -192,7 +177,7 @@ __decorate([
192
177
  __decorate([
193
178
  bind,
194
179
  __metadata("design:type", Function),
195
- __metadata("design:paramtypes", [typeof (_d = typeof K !== "undefined" && K) === "function" ? _d : Object, Object]),
180
+ __metadata("design:paramtypes", [typeof (_c = typeof K !== "undefined" && K) === "function" ? _c : Object, Object]),
196
181
  __metadata("design:returntype", Object)
197
182
  ], Build.prototype, "setItem", null);
198
183
  __decorate([
@@ -201,3 +186,15 @@ __decorate([
201
186
  __metadata("design:paramtypes", [Object]),
202
187
  __metadata("design:returntype", Item)
203
188
  ], Build.prototype, "makeItem", null);
189
+ __decorate([
190
+ bind,
191
+ __metadata("design:type", Function),
192
+ __metadata("design:paramtypes", [typeof (_d = typeof K !== "undefined" && K) === "function" ? _d : Object, Object]),
193
+ __metadata("design:returntype", Object)
194
+ ], Build.prototype, "setRule", null);
195
+ __decorate([
196
+ bind,
197
+ __metadata("design:type", Function),
198
+ __metadata("design:paramtypes", [Object]),
199
+ __metadata("design:returntype", Rule)
200
+ ], Build.prototype, "makeRule", null);
@@ -3,6 +3,7 @@ import { __decorate, __metadata } from "tslib";
3
3
  import { bind } from '@roots/bud-support/decorators/bind';
4
4
  import isFunction from '@roots/bud-support/lodash/isFunction';
5
5
  export default class Base {
6
+ _app;
6
7
  /**
7
8
  * Application getter
8
9
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roots/bud-build",
3
- "version": "2023.6.5",
3
+ "version": "2023.6.7",
4
4
  "description": "bud.js core module",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -85,14 +85,14 @@
85
85
  "types": "./lib/index.d.ts",
86
86
  "module": "./lib/index.js",
87
87
  "devDependencies": {
88
- "@roots/bud-api": "2023.6.5",
89
- "@roots/bud-hooks": "2023.6.5",
88
+ "@roots/bud-api": "2023.6.7",
89
+ "@roots/bud-hooks": "2023.6.7",
90
90
  "@skypack/package-check": "0.2.2",
91
91
  "@types/node": "18.16.12"
92
92
  },
93
93
  "dependencies": {
94
- "@roots/bud-framework": "2023.6.5",
95
- "@roots/bud-support": "2023.6.5",
94
+ "@roots/bud-framework": "2023.6.7",
95
+ "@roots/bud-support": "2023.6.7",
96
96
  "tslib": "2.5.0"
97
97
  },
98
98
  "volta": {
@@ -1,4 +1,4 @@
1
- import {Bud, factory} from '@repo/test-kit/bud'
1
+ import {Bud, factory} from '@repo/test-kit'
2
2
  import {beforeEach, describe, expect, it} from 'vitest'
3
3
 
4
4
  import {Build} from '../service.js'
@@ -64,7 +64,7 @@ describe(`bud.build.config`, function () {
64
64
  })
65
65
 
66
66
  it(`should have expected optimization.runtimeChunk default`, async () => {
67
- expect(build.config.optimization?.runtimeChunk).toBe(false)
67
+ expect(build.config.optimization?.runtimeChunk).toBe(`single`)
68
68
  })
69
69
 
70
70
  it(`should have expected profile default`, async () => {
@@ -80,9 +80,7 @@ describe(`bud.build.config`, function () {
80
80
  it(`should have expected resolve.extensions default`, async () => {
81
81
  expect(build.config.resolve?.extensions?.sort()).toEqual(
82
82
  expect.arrayContaining([
83
- `.cjs`,
84
83
  `.css`,
85
- `.cts`,
86
84
  `.js`,
87
85
  `.jsx`,
88
86
  `.mjs`,
@@ -29,7 +29,7 @@ export const optimization: Factory<`optimization`> = async ({
29
29
  `build.optimization.removeAvailableModules`,
30
30
  false,
31
31
  ),
32
- runtimeChunk: filter(`build.optimization.runtimeChunk`, false),
32
+ runtimeChunk: filter(`build.optimization.runtimeChunk`, `single`),
33
33
  sideEffects: filter(`build.optimization.sideEffects`, isProduction),
34
34
  splitChunks: filter(`build.optimization.splitChunks`, false),
35
35
  providedExports: filter(
@@ -16,7 +16,7 @@ export const resolve: Factory<`resolve`> = async bud => {
16
16
  extensions: Array.from(
17
17
  bud.hooks.filter(
18
18
  `build.resolve.extensions`,
19
- new Set([`.js`, `.mjs`, `.jsx`, `.cjs`, `.css`]),
19
+ new Set([`.js`, `.mjs`, `.jsx`, `.css`]),
20
20
  ),
21
21
  ),
22
22
  modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
@@ -1,4 +1,4 @@
1
- import {factory} from '@repo/test-kit/bud'
1
+ import {factory} from '@repo/test-kit'
2
2
  import {describe, expect, it} from 'vitest'
3
3
 
4
4
  import {csv} from './csv.js'
@@ -4,7 +4,6 @@ export const js: Factory = async ({filter, makeRule, path}) =>
4
4
  makeRule()
5
5
  .setTest(filter(`pattern.js`))
6
6
  .setInclude([() => path(`@src`)])
7
- .setType(`javascript/auto`)
8
7
  .setResolve({
9
8
  fullySpecified: false,
10
9
  })
@@ -4,7 +4,7 @@ import {inlineSvg, dataUrl} from './svg.inline.js'
4
4
 
5
5
  describe(`svg-inline`, () => {
6
6
  it(`should return a rule`, async () => {
7
- const bud = await import(`@repo/test-kit/bud`).then(
7
+ const bud = await import(`@repo/test-kit`).then(
8
8
  async ({factory}) => await factory(),
9
9
  )
10
10
  const result = await inlineSvg({
@@ -1,4 +1,4 @@
1
- import {factory} from '@repo/test-kit/bud'
1
+ import {factory} from '@repo/test-kit'
2
2
  import {describe, expect, it} from 'vitest'
3
3
 
4
4
  import {toml} from './toml'
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, it} from 'vitest'
2
- import {factory} from '@repo/test-kit/bud'
2
+ import {factory} from '@repo/test-kit'
3
3
 
4
4
  import {xml} from './xml'
5
5
 
@@ -1,4 +1,4 @@
1
- import {factory} from '@repo/test-kit/bud'
1
+ import {factory} from '@repo/test-kit'
2
2
  import {beforeAll, describe, expect, it} from 'vitest'
3
3
 
4
4
  import {Rule} from './index.js'
package/src/service.ts CHANGED
@@ -85,32 +85,6 @@ export class Build extends Service implements Base.Service {
85
85
  return this.rules[ident]
86
86
  }
87
87
 
88
- /**
89
- * Set Rule
90
- */
91
- @bind
92
- public setRule<K extends `${keyof Rules & string}`>(
93
- name: K,
94
- input?: RuleOptions | Rule,
95
- ): this {
96
- this.rules[name] =
97
- input instanceof Rule
98
- ? input
99
- : isFunction(input)
100
- ? input(this.makeRule())
101
- : this.makeRule(input as any)
102
-
103
- return this
104
- }
105
-
106
- /**
107
- * Make Rule
108
- */
109
- @bind
110
- public makeRule(options?: RuleOptions): Rule {
111
- return new Rule(() => this.app, options)
112
- }
113
-
114
88
  /**
115
89
  * Get loader
116
90
  */
@@ -148,7 +122,7 @@ export class Build extends Service implements Base.Service {
148
122
  */
149
123
  @bind
150
124
  public makeLoader(src?: string, definition?: string): Loader {
151
- return new Loader(() => this.app, src)
125
+ return new Loader(() => this.app, src, definition)
152
126
  }
153
127
 
154
128
  /**
@@ -193,4 +167,30 @@ export class Build extends Service implements Base.Service {
193
167
  public makeItem(options?: Partial<Item['options']>): Item {
194
168
  return new Item(() => this.app, options)
195
169
  }
170
+
171
+ /**
172
+ * Set Rule
173
+ */
174
+ @bind
175
+ public setRule<K extends `${keyof Rules & string}`>(
176
+ name: K,
177
+ input?: RuleOptions | Rule,
178
+ ): this {
179
+ this.rules[name] =
180
+ input instanceof Rule
181
+ ? input
182
+ : isFunction(input)
183
+ ? input(this.makeRule())
184
+ : this.makeRule(input as any)
185
+
186
+ return this
187
+ }
188
+
189
+ /**
190
+ * Make Rule
191
+ */
192
+ @bind
193
+ public makeRule(options?: RuleOptions): Rule {
194
+ return new Rule(() => this.app, options)
195
+ }
196
196
  }