@roots/bud-build 2024.6.4-7 → 2024.6.5-7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,7 @@
1
- import logger from '@roots/bud-support/logger';
2
1
  export const infrastructureLogging = async (bud) => bud.hooks.filter(`build.infrastructureLogging`, {
3
- console: bud.hooks.filter(`build.infrastructureLogging.console`, {
4
- ...console,
5
- error: (...args) => {
6
- logger.unscope().error(...args);
7
- },
8
- info: (...args) => {
9
- logger.unscope().info(...args);
10
- },
11
- log: (...args) => {
12
- logger.unscope().log(...args);
13
- },
14
- warn: (...args) => {
15
- logger.unscope().info(...args);
16
- },
17
- }),
18
- level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
2
+ ...(bud.context?.verbose
3
+ ? { console, level: `verbose` }
4
+ : bud.context?.log
5
+ ? { console, level: `log` }
6
+ : { level: `none` }),
19
7
  });
@@ -1,6 +1,7 @@
1
1
  export const optimization = async ({ hooks: { filter }, isDevelopment, isProduction, mode, }) => filter(`build.optimization`, {
2
2
  emitOnErrors: filter(`build.optimization.emitOnErrors`, isDevelopment),
3
3
  innerGraph: filter(`build.optimization.innerGraph`, isProduction),
4
+ mangleExports: filter(`build.optimization.mangleExports`, isProduction),
4
5
  mergeDuplicateChunks: filter(`build.optimization.mergeDuplicateChunks`, isProduction),
5
6
  minimize: filter(`build.optimization.minimize`, isProduction),
6
7
  minimizer: filter(`build.optimization.minimizer`, []),
@@ -1,9 +1,53 @@
1
1
  import * as MiniCss from '@roots/bud-support/mini-css-extract-plugin';
2
- export const css = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/css-loader`, import.meta.url));
3
- export const csv = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/csv-loader`, import.meta.url));
4
- export const file = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/file-loader`, import.meta.url));
5
- export const html = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/html-loader`, import.meta.url));
6
- export const remark = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/remark-loader`, import.meta.url));
7
- export const minicss = async ({ makeLoader, resolve }) => makeLoader(MiniCss.loader);
8
- export const style = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/style-loader`, import.meta.url));
9
- export const yml = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/yml-loader`, import.meta.url));
2
+ export const css = async ({ makeLoader, resolve }) => {
3
+ const path = await resolve(`@roots/bud-support/css-loader`, import.meta.url);
4
+ if (!path) {
5
+ throw new Error(`@roots/bud-support/css-loader not found`);
6
+ }
7
+ return makeLoader(path);
8
+ };
9
+ export const csv = async ({ makeLoader, resolve }) => {
10
+ const path = await resolve(`@roots/bud-support/csv-loader`, import.meta.url);
11
+ if (!path) {
12
+ throw new Error(`@roots/bud-support/csv-loader not found`);
13
+ }
14
+ return makeLoader(path);
15
+ };
16
+ export const file = async ({ makeLoader, resolve }) => {
17
+ const path = await resolve(`@roots/bud-support/file-loader`, import.meta.url);
18
+ if (!path) {
19
+ throw new Error(`@roots/bud-support/csv-loader not found`);
20
+ }
21
+ return makeLoader(path);
22
+ };
23
+ export const html = async ({ makeLoader, resolve }) => {
24
+ const path = await resolve(`@roots/bud-support/html-loader`, import.meta.url);
25
+ if (!path) {
26
+ throw new Error(`@roots/bud-support/html-loader not found`);
27
+ }
28
+ return makeLoader(path);
29
+ };
30
+ export const remark = async ({ makeLoader, resolve }) => {
31
+ const path = await resolve(`@roots/bud-support/remark-loader`, import.meta.url);
32
+ if (!path) {
33
+ throw new Error(`@roots/bud-support/remark-loader not found`);
34
+ }
35
+ return makeLoader(path);
36
+ };
37
+ export const minicss = async ({ makeLoader, resolve }) => {
38
+ return makeLoader(MiniCss.loader);
39
+ };
40
+ export const style = async ({ makeLoader, resolve }) => {
41
+ const path = await resolve(`@roots/bud-support/style-loader`, import.meta.url);
42
+ if (!path) {
43
+ throw new Error(`@roots/bud-support/style-loader not found`);
44
+ }
45
+ return makeLoader(path);
46
+ };
47
+ export const yml = async ({ makeLoader, resolve }) => {
48
+ const path = await resolve(`@roots/bud-support/yml-loader`, import.meta.url);
49
+ if (!path) {
50
+ throw new Error(`@roots/bud-support/yml-loader not found`);
51
+ }
52
+ return makeLoader(path);
53
+ };
@@ -59,7 +59,6 @@ class Build extends Service {
59
59
  .then(async (records) => await Promise.all(Object.entries(records).map(async ([prop, factory]) => {
60
60
  const value = await factory(this.app).catch(this.catch);
61
61
  if (isUndefined(value)) {
62
- this.logger.success(`omitting:`, prop, `(undefined)`);
63
62
  return;
64
63
  }
65
64
  Object.defineProperty(this.config, prop, {
@@ -69,12 +68,11 @@ class Build extends Service {
69
68
  writable: true,
70
69
  });
71
70
  this.logger
72
- .success(`defined:`, prop, `(${typeof this.config[prop]})`)
71
+ .log(`Defined:`, prop, `(${typeof this.config[prop]})`)
73
72
  .info(prop, `info:`, this.config[prop]);
74
73
  })))
75
74
  .catch(this.catch);
76
- this.logger.success(`configuration built`);
77
- this.logger.info(this.config);
75
+ this.logger.scope(this.app.label, `build`).info(`built`, this.config);
78
76
  await this.app.hooks.fire(`build.after`, this.app).catch(this.catch);
79
77
  return Object.entries(this.config).reduce((a, [k, v]) => {
80
78
  if (isUndefined(v))
@@ -104,7 +102,7 @@ class Build extends Service {
104
102
  * {@link BudBuild.setItem}
105
103
  */
106
104
  setItem(ident, definition) {
107
- this.logger.log(`build.setItem`, ident);
105
+ this.logger.log(`Registered item:`, ident);
108
106
  const maybeOptionsCallback = isUndefined(definition)
109
107
  ? { ident, loader: ident }
110
108
  : definition;
@@ -119,7 +117,7 @@ class Build extends Service {
119
117
  * {@link BudBuild.setLoader}
120
118
  */
121
119
  setLoader(name, definition) {
122
- this.logger.log(`build.setLoader`, name);
120
+ this.logger.log(`Registered loader:`, name);
123
121
  const loader = isUndefined(definition)
124
122
  ? this.makeLoader(name)
125
123
  : definition instanceof Loader
@@ -133,7 +131,7 @@ class Build extends Service {
133
131
  * {@link BudBuild.setRule}
134
132
  */
135
133
  setRule(name, definition) {
136
- this.logger.log(`build.setRule`, name);
134
+ this.logger.log(`Registered rule:`, name);
137
135
  const rule = definition instanceof Rule
138
136
  ? definition
139
137
  : isFunction(definition)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roots/bud-build",
3
- "version": "2024.6.4-7",
3
+ "version": "2024.6.5-7",
4
4
  "description": "bud.js core module",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -169,14 +169,14 @@
169
169
  "types": "./lib/index.d.ts",
170
170
  "module": "./lib/index.js",
171
171
  "devDependencies": {
172
- "@roots/bud-api": "2024.6.4-7",
173
- "@roots/bud-hooks": "2024.6.4-7",
172
+ "@roots/bud-api": "2024.6.5-7",
173
+ "@roots/bud-hooks": "2024.6.5-7",
174
174
  "@skypack/package-check": "0.2.2",
175
175
  "@types/node": "20.12.8"
176
176
  },
177
177
  "dependencies": {
178
- "@roots/bud-framework": "2024.6.4-7",
179
- "@roots/bud-support": "2024.6.4-7",
178
+ "@roots/bud-framework": "2024.6.5-7",
179
+ "@roots/bud-support": "2024.6.5-7",
180
180
  "tslib": "2.6.2"
181
181
  },
182
182
  "volta": {
@@ -1,25 +1,12 @@
1
1
  import type {Factory} from '@roots/bud-build/config'
2
2
 
3
- import logger from '@roots/bud-support/logger'
4
-
5
3
  export const infrastructureLogging: Factory<
6
4
  `infrastructureLogging`
7
5
  > = async bud =>
8
6
  bud.hooks.filter(`build.infrastructureLogging`, {
9
- console: bud.hooks.filter(`build.infrastructureLogging.console`, {
10
- ...console,
11
- error: (...args: any[]) => {
12
- logger.unscope().error(...args)
13
- },
14
- info: (...args: any[]) => {
15
- logger.unscope().info(...args)
16
- },
17
- log: (...args: any[]) => {
18
- logger.unscope().log(...args)
19
- },
20
- warn: (...args: any[]) => {
21
- logger.unscope().info(...args)
22
- },
23
- }),
24
- level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
7
+ ...(bud.context?.verbose
8
+ ? {console, level: `verbose`}
9
+ : bud.context?.log
10
+ ? {console, level: `log`}
11
+ : {level: `none`}),
25
12
  })
@@ -9,6 +9,10 @@ export const optimization: Factory<`optimization`> = async ({
9
9
  filter(`build.optimization`, {
10
10
  emitOnErrors: filter(`build.optimization.emitOnErrors`, isDevelopment),
11
11
  innerGraph: filter(`build.optimization.innerGraph`, isProduction),
12
+ mangleExports: filter(
13
+ `build.optimization.mangleExports`,
14
+ isProduction,
15
+ ),
12
16
  mergeDuplicateChunks: filter(
13
17
  `build.optimization.mergeDuplicateChunks`,
14
18
  isProduction,
@@ -3,40 +3,83 @@ import type {Loader} from '@roots/bud-framework/services/build'
3
3
 
4
4
  import * as MiniCss from '@roots/bud-support/mini-css-extract-plugin'
5
5
 
6
- export const css: Factory<Loader> = async ({makeLoader, resolve}) =>
7
- makeLoader(
8
- await resolve(`@roots/bud-support/css-loader`, import.meta.url),
6
+ export const css: Factory<Loader> = async ({makeLoader, resolve}) => {
7
+ const path = await resolve(
8
+ `@roots/bud-support/css-loader`,
9
+ import.meta.url,
9
10
  )
11
+ if (!path) {
12
+ throw new Error(`@roots/bud-support/css-loader not found`)
13
+ }
14
+ return makeLoader(path)
15
+ }
10
16
 
11
- export const csv: Factory<Loader> = async ({makeLoader, resolve}) =>
12
- makeLoader(
13
- await resolve(`@roots/bud-support/csv-loader`, import.meta.url),
17
+ export const csv: Factory<Loader> = async ({makeLoader, resolve}) => {
18
+ const path = await resolve(
19
+ `@roots/bud-support/csv-loader`,
20
+ import.meta.url,
14
21
  )
22
+ if (!path) {
23
+ throw new Error(`@roots/bud-support/csv-loader not found`)
24
+ }
25
+ return makeLoader(path)
26
+ }
15
27
 
16
- export const file: Factory<Loader> = async ({makeLoader, resolve}) =>
17
- makeLoader(
18
- await resolve(`@roots/bud-support/file-loader`, import.meta.url),
28
+ export const file: Factory<Loader> = async ({makeLoader, resolve}) => {
29
+ const path = await resolve(
30
+ `@roots/bud-support/file-loader`,
31
+ import.meta.url,
19
32
  )
33
+ if (!path) {
34
+ throw new Error(`@roots/bud-support/csv-loader not found`)
35
+ }
36
+ return makeLoader(path)
37
+ }
20
38
 
21
- export const html: Factory<Loader> = async ({makeLoader, resolve}) =>
22
- makeLoader(
23
- await resolve(`@roots/bud-support/html-loader`, import.meta.url),
39
+ export const html: Factory<Loader> = async ({makeLoader, resolve}) => {
40
+ const path = await resolve(
41
+ `@roots/bud-support/html-loader`,
42
+ import.meta.url,
24
43
  )
44
+ if (!path) {
45
+ throw new Error(`@roots/bud-support/html-loader not found`)
46
+ }
47
+ return makeLoader(path)
48
+ }
25
49
 
26
- export const remark: Factory<Loader> = async ({makeLoader, resolve}) =>
27
- makeLoader(
28
- await resolve(`@roots/bud-support/remark-loader`, import.meta.url),
50
+ export const remark: Factory<Loader> = async ({makeLoader, resolve}) => {
51
+ const path = await resolve(
52
+ `@roots/bud-support/remark-loader`,
53
+ import.meta.url,
29
54
  )
55
+ if (!path) {
56
+ throw new Error(`@roots/bud-support/remark-loader not found`)
57
+ }
58
+ return makeLoader(path)
59
+ }
30
60
 
31
- export const minicss: Factory<Loader> = async ({makeLoader, resolve}) =>
32
- makeLoader(MiniCss.loader)
61
+ export const minicss: Factory<Loader> = async ({makeLoader, resolve}) => {
62
+ return makeLoader(MiniCss.loader)
63
+ }
33
64
 
34
- export const style: Factory<Loader> = async ({makeLoader, resolve}) =>
35
- makeLoader(
36
- await resolve(`@roots/bud-support/style-loader`, import.meta.url),
65
+ export const style: Factory<Loader> = async ({makeLoader, resolve}) => {
66
+ const path = await resolve(
67
+ `@roots/bud-support/style-loader`,
68
+ import.meta.url,
37
69
  )
70
+ if (!path) {
71
+ throw new Error(`@roots/bud-support/style-loader not found`)
72
+ }
73
+ return makeLoader(path)
74
+ }
38
75
 
39
- export const yml: Factory<Loader> = async ({makeLoader, resolve}) =>
40
- makeLoader(
41
- await resolve(`@roots/bud-support/yml-loader`, import.meta.url),
76
+ export const yml: Factory<Loader> = async ({makeLoader, resolve}) => {
77
+ const path = await resolve(
78
+ `@roots/bud-support/yml-loader`,
79
+ import.meta.url,
42
80
  )
81
+ if (!path) {
82
+ throw new Error(`@roots/bud-support/yml-loader not found`)
83
+ }
84
+ return makeLoader(path)
85
+ }
@@ -98,8 +98,8 @@ class Build extends Service implements BudBuild {
98
98
  await Promise.all(
99
99
  Object.entries(records).map(async ([prop, factory]) => {
100
100
  const value = await factory(this.app).catch(this.catch)
101
+
101
102
  if (isUndefined(value)) {
102
- this.logger.success(`omitting:`, prop, `(undefined)`)
103
103
  return
104
104
  }
105
105
 
@@ -111,16 +111,14 @@ class Build extends Service implements BudBuild {
111
111
  })
112
112
 
113
113
  this.logger
114
- .success(`defined:`, prop, `(${typeof this.config[prop]})`)
114
+ .log(`Defined:`, prop, `(${typeof this.config[prop]})`)
115
115
  .info(prop, `info:`, this.config[prop])
116
116
  }),
117
117
  ),
118
118
  )
119
119
  .catch(this.catch)
120
120
 
121
- this.logger.success(`configuration built`)
122
- this.logger.info(this.config)
123
-
121
+ this.logger.scope(this.app.label, `build`).info(`built`, this.config)
124
122
  await this.app.hooks.fire(`build.after`, this.app).catch(this.catch)
125
123
 
126
124
  return Object.entries(this.config).reduce((a, [k, v]) => {
@@ -161,7 +159,8 @@ class Build extends Service implements BudBuild {
161
159
  ident: K,
162
160
  definition?: ((item: Items[K]) => Items[K]) | Items[K],
163
161
  ): this {
164
- this.logger.log(`build.setItem`, ident)
162
+ this.logger.log(`Registered item:`, ident)
163
+
165
164
  const maybeOptionsCallback = isUndefined(definition)
166
165
  ? {ident, loader: ident}
167
166
  : definition
@@ -184,7 +183,8 @@ class Build extends Service implements BudBuild {
184
183
  name: K,
185
184
  definition?: any,
186
185
  ): this {
187
- this.logger.log(`build.setLoader`, name)
186
+ this.logger.log(`Registered loader:`, name)
187
+
188
188
  const loader = isUndefined(definition)
189
189
  ? this.makeLoader(name)
190
190
  : definition instanceof Loader
@@ -205,7 +205,7 @@ class Build extends Service implements BudBuild {
205
205
  name: K,
206
206
  definition?: Rule | RuleOptions,
207
207
  ): this {
208
- this.logger.log(`build.setRule`, name)
208
+ this.logger.log(`Registered rule:`, name)
209
209
  const rule =
210
210
  definition instanceof Rule
211
211
  ? definition