@roots/bud-build 6.12.3 → 6.13.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 (77) hide show
  1. package/lib/config/experiments.js +3 -1
  2. package/lib/config/externalsType.js +1 -1
  3. package/lib/config/index.d.ts +1 -1
  4. package/lib/config/infrastructureLogging.js +6 -6
  5. package/lib/config/module.js +6 -2
  6. package/lib/config/optimization.js +13 -3
  7. package/lib/config/output/index.js +1 -1
  8. package/lib/config/performance.js +1 -1
  9. package/lib/config/profile.js +1 -1
  10. package/lib/config/resolve.js +19 -27
  11. package/lib/config/resolveLoader.js +2 -2
  12. package/lib/config/snapshot.js +8 -3
  13. package/lib/config/stats.js +1 -1
  14. package/lib/handlers/index.d.ts +1 -1
  15. package/lib/handlers/items/items.d.ts +1 -5
  16. package/lib/handlers/items/items.js +2 -6
  17. package/lib/handlers/loaders/loaders.d.ts +0 -1
  18. package/lib/handlers/loaders/loaders.js +0 -1
  19. package/lib/handlers/register.js +2 -2
  20. package/lib/handlers/rules/csv.js +1 -1
  21. package/lib/handlers/rules/index.d.ts +9 -10
  22. package/lib/handlers/rules/index.js +9 -11
  23. package/lib/handlers/rules/js.js +3 -1
  24. package/lib/handlers/rules/json.js +3 -1
  25. package/lib/handlers/rules/toml.js +3 -1
  26. package/lib/index.d.ts +1 -1
  27. package/lib/index.js +1 -1
  28. package/lib/item/index.d.ts +11 -11
  29. package/lib/item/index.js +45 -32
  30. package/lib/loader/index.js +5 -0
  31. package/lib/rule/index.d.ts +62 -50
  32. package/lib/rule/index.js +143 -81
  33. package/lib/service.d.ts +30 -29
  34. package/lib/service.js +96 -99
  35. package/lib/shared/base.d.ts +6 -6
  36. package/lib/shared/base.js +16 -15
  37. package/lib/types.d.ts +12 -15
  38. package/lib/types.js +0 -2
  39. package/package.json +7 -7
  40. package/src/config/experiments.ts +3 -1
  41. package/src/config/externalsType.ts +2 -1
  42. package/src/config/index.test.ts +5 -5
  43. package/src/config/index.ts +1 -1
  44. package/src/config/infrastructureLogging.ts +6 -6
  45. package/src/config/module.ts +7 -3
  46. package/src/config/optimization.ts +22 -2
  47. package/src/config/output/chunkFilename.ts +2 -2
  48. package/src/config/output/index.ts +3 -2
  49. package/src/config/performance.ts +1 -1
  50. package/src/config/profile.ts +2 -2
  51. package/src/config/resolve.ts +27 -41
  52. package/src/config/resolveLoader.ts +3 -3
  53. package/src/config/snapshot.ts +21 -4
  54. package/src/config/stats.ts +1 -1
  55. package/src/handlers/index.ts +2 -1
  56. package/src/handlers/items/items.ts +3 -8
  57. package/src/handlers/loaders/loaders.ts +1 -5
  58. package/src/handlers/register.ts +3 -2
  59. package/src/handlers/rules/csv.test.ts +1 -1
  60. package/src/handlers/rules/csv.ts +1 -1
  61. package/src/handlers/rules/index.ts +9 -11
  62. package/src/handlers/rules/js.ts +3 -1
  63. package/src/handlers/rules/json.ts +3 -1
  64. package/src/handlers/rules/svg.inline.test.ts +1 -1
  65. package/src/handlers/rules/toml.test.ts +1 -1
  66. package/src/handlers/rules/toml.ts +3 -1
  67. package/src/index.ts +1 -2
  68. package/src/item/index.ts +29 -28
  69. package/src/rule/index.test.ts +1 -1
  70. package/src/rule/index.ts +108 -79
  71. package/src/service.ts +80 -77
  72. package/src/shared/base.ts +12 -11
  73. package/src/types.ts +12 -18
  74. package/lib/handlers/rules/xml.d.ts +0 -2
  75. package/lib/handlers/rules/xml.js +0 -4
  76. package/src/handlers/rules/xml.test.ts +0 -30
  77. package/src/handlers/rules/xml.ts +0 -7
@@ -1 +1,3 @@
1
- export const experiments = async ({ hooks }) => hooks.filter(`build.experiments`, undefined);
1
+ export const experiments = async ({ hooks }) => hooks.filter(`build.experiments`, {
2
+ backCompat: false,
3
+ });
@@ -1 +1 @@
1
- export const externalsType = async (app) => `var`;
1
+ export const externalsType = async (app) => undefined;
@@ -1,5 +1,5 @@
1
1
  import type { Bud } from '@roots/bud-framework';
2
- import type { Configuration } from '@roots/bud-support/webpack';
2
+ import type { Configuration } from '@roots/bud-framework/config';
3
3
  import { bail } from './bail.js';
4
4
  import { cache } from './cache.js';
5
5
  import { context } from './context.js';
@@ -2,18 +2,18 @@ import logger from '@roots/bud-support/utilities/logger';
2
2
  export const infrastructureLogging = async (bud) => bud.hooks.filter(`build.infrastructureLogging`, {
3
3
  console: bud.hooks.filter(`build.infrastructureLogging.console`, {
4
4
  ...console,
5
- log: (...args) => {
6
- logger.scope(`webpack`).log(...args);
7
- },
8
- warn: (...args) => {
9
- logger.scope(`webpack`).info(...args);
10
- },
11
5
  error: (...args) => {
12
6
  logger.scope(`webpack`).error(...args);
13
7
  },
14
8
  info: (...args) => {
15
9
  logger.scope(`webpack`).info(...args);
16
10
  },
11
+ log: (...args) => {
12
+ logger.scope(`webpack`).log(...args);
13
+ },
14
+ warn: (...args) => {
15
+ logger.scope(`webpack`).info(...args);
16
+ },
17
17
  }),
18
18
  level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
19
19
  });
@@ -6,9 +6,9 @@ export const module = async ({ build: { rules }, hooks: { filter }, path, }) =>
6
6
  const getRules = ({ filter, path, rules }) => [
7
7
  ...filter(`build.module.rules.before`, [
8
8
  {
9
- test: filter(`pattern.js`),
10
9
  include: [path(`@src`)],
11
10
  parser: { requireEnsure: false },
11
+ test: filter(`pattern.js`),
12
12
  },
13
13
  ]),
14
14
  {
@@ -19,4 +19,8 @@ const getRules = ({ filter, path, rules }) => [
19
19
  ...filter(`build.module.rules.after`, []),
20
20
  ];
21
21
  const getNoParse = (filter) => filter(`build.module.noParse`, undefined);
22
- const getUnsafeCache = (filter) => filter(`build.module.unsafeCache`, false);
22
+ /**
23
+ * By leaving undefined, webpack will strongly cache parsed modules from node_modules
24
+ * but leave the rest. This is the default behavior.
25
+ */
26
+ const getUnsafeCache = (filter) => filter(`build.module.unsafeCache`, undefined);
@@ -1,10 +1,20 @@
1
- export const optimization = async ({ hooks: { filter }, isDevelopment, isProduction, }) => filter(`build.optimization`, {
1
+ export const optimization = async ({ hooks: { filter }, isDevelopment, isProduction, mode, }) => filter(`build.optimization`, {
2
2
  emitOnErrors: filter(`build.optimization.emitOnErrors`, isDevelopment),
3
+ innerGraph: filter(`build.optimization.innerGraph`, isProduction),
4
+ mergeDuplicateChunks: filter(`build.optimization.mergeDuplicateChunks`, isProduction),
3
5
  minimize: filter(`build.optimization.minimize`, isProduction),
4
6
  minimizer: filter(`build.optimization.minimizer`, []),
5
7
  moduleIds: filter(`build.optimization.moduleIds`, `named`),
6
- removeEmptyChunks: filter(`build.optimization.removeEmptyChunks`, false),
7
- runtimeChunk: filter(`build.optimization.runtimeChunk`, false),
8
+ nodeEnv: filter(`build.optimization.nodeEnv`, mode),
9
+ providedExports: filter(`build.optimization.providedExports`, isProduction),
10
+ /**
11
+ * Will be new default in webpack 6
12
+ * @see {@link https://webpack.js.org/configuration/optimization/#optimizationremoveavailablemodules}
13
+ */
14
+ removeAvailableModules: filter(`build.optimization.removeAvailableModules`, false),
15
+ removeEmptyChunks: filter(`build.optimization.removeEmptyChunks`, isProduction),
16
+ runtimeChunk: filter(`build.optimization.runtimeChunk`, `single`),
17
+ sideEffects: filter(`build.optimization.sideEffects`, isProduction),
8
18
  splitChunks: filter(`build.optimization.splitChunks`, false),
9
19
  usedExports: filter(`build.optimization.usedExports`, isProduction),
10
20
  });
@@ -10,7 +10,7 @@ export const output = async ({ hooks: { filter }, isProduction, path, relPath, }
10
10
  filename: filename({ filter, relPath }),
11
11
  module: filter(`build.output.module`, false),
12
12
  path: filter(`build.output.path`, path(`@dist`)),
13
- pathinfo: filter(`build.output.pathinfo`),
13
+ pathinfo: filter(`build.output.pathinfo`, false),
14
14
  publicPath: filter(`build.output.publicPath`, `auto`),
15
15
  scriptType: filter(`build.output.scriptType`, isMjs(filter) ? `module` : false),
16
16
  uniqueName: filter(`build.output.uniqueName`, `@roots/bud`),
@@ -1 +1 @@
1
- export const performance = async ({ hooks }) => hooks.filter(`build.performance`, { hints: false });
1
+ export const performance = async ({ hooks }) => hooks.filter(`build.performance`, false);
@@ -1 +1 @@
1
- export const profile = async (app) => app.hooks.filter(`build.profile`, undefined);
1
+ export const profile = async (bud) => bud.hooks.filter(`build.profile`, bud.context.debug);
@@ -1,29 +1,21 @@
1
1
  export const resolve = async (bud) => {
2
- const modules = await getModules(bud);
3
- const value = {
4
- alias: await getAlias(bud),
5
- extensions: getExtensions(bud),
6
- modules,
7
- };
8
- return await bud.hooks.filterAsync(`build.resolve`, value);
2
+ return await bud.hooks.filterAsync(`build.resolve`, {
3
+ alias: {
4
+ [`@src`]: bud.path(`@src`),
5
+ ...(await bud.hooks.filterAsync(`build.resolve.alias`, {})),
6
+ },
7
+ extensionAlias: await bud.hooks.filterAsync(`build.resolve.extensionAlias`, {
8
+ [`.js`]: [`.ts`, `.tsx`, `.js`],
9
+ [`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
10
+ }),
11
+ extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.jsx`, `.css`]))),
12
+ modules: await bud.hooks.filterAsync(`build.resolve.modules`, [
13
+ bud.hooks.filter(`location.@src`),
14
+ bud.hooks.filter(`location.@modules`),
15
+ ]),
16
+ /**
17
+ * Leave `undefined` to use webpack default (true in dev, false in production)
18
+ */
19
+ unsafeCache: bud.hooks.filter(`build.module.unsafeCache`, undefined),
20
+ });
9
21
  };
10
- const getAlias = async (bud) => await bud.hooks.filterAsync(`build.resolve.alias`, {
11
- '@src': bud.path(`@src`),
12
- });
13
- const getExtensions = (bud) => Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([
14
- `.mjs`,
15
- `.js`,
16
- `.jsx`,
17
- `.css`,
18
- `.json`,
19
- `.wasm`,
20
- `.yml`,
21
- `.yaml`,
22
- `.xml`,
23
- `.toml`,
24
- `.csv`,
25
- ])));
26
- const getModules = async (bud) => await bud.hooks.filterAsync(`build.resolve.modules`, [
27
- bud.hooks.filter(`location.@src`),
28
- bud.hooks.filter(`location.@modules`),
29
- ]);
@@ -1,3 +1,3 @@
1
- export const resolveLoader = async (bud) => bud.hooks.filter(`build.resolveLoader`, {
2
- alias: {},
1
+ export const resolveLoader = async ({ hooks }) => hooks.filter(`build.resolveLoader`, {
2
+ alias: hooks.filter(`build.resolveLoader.alias`, {}),
3
3
  });
@@ -1,5 +1,10 @@
1
- export const snapshot = async (app) => app.hooks.filter(`build.snapshot`, {
2
- managedPaths: app.hooks.filter(`build.snapshot.managedPaths`, [
3
- ...new Set([app.path(`@modules`)]),
1
+ export const snapshot = async ({ env, hooks, path }) => hooks.filter(`build.snapshot`, {
2
+ buildDependencies: hooks.filter(`build.snapshot.buildDependencies`, env.isTrue(`CI`) ? { hash: true } : { timestamp: true }),
3
+ immutablePaths: hooks.filter(`build.snapshot.immutablePaths`, []),
4
+ managedPaths: hooks.filter(`build.snapshot.managedPaths`, [
5
+ ...new Set([path(`@modules`)]),
4
6
  ]),
7
+ module: hooks.filter(`build.snapshot.module`, env.isTrue(`CI`) ? { hash: true } : { timestamp: true }),
8
+ resolve: hooks.filter(`build.snapshot.resolve`, env.isTrue(`CI`) ? { hash: true } : { timestamp: true }),
9
+ resolveBuildDependencies: hooks.filter(`build.snapshot.resolveBuildDependencies`, env.isTrue(`CI`) ? { hash: true } : { timestamp: true }),
5
10
  });
@@ -7,8 +7,8 @@ export const stats = async (app) => app.hooks.filter(`build.stats`, app.isProduc
7
7
  errors: true,
8
8
  errorsCount: true,
9
9
  hash: true,
10
- outputPath: true,
11
10
  modules: true,
11
+ outputPath: true,
12
12
  timings: true,
13
13
  warnings: true,
14
14
  warningsCount: true,
@@ -6,10 +6,10 @@ import { register } from './register.js';
6
6
  import { rules } from './rules/index.js';
7
7
  export interface Props {
8
8
  filter: Bud[`hooks`][`filter`];
9
+ isProduction: Bud[`isProduction`];
9
10
  makeItem: Bud[`build`][`makeItem`];
10
11
  makeLoader: Bud[`build`][`makeLoader`];
11
12
  makeRule: Bud[`build`][`makeRule`];
12
- isProduction: Bud[`isProduction`];
13
13
  path: Bud[`path`];
14
14
  resolve: Bud[`module`][`resolve`];
15
15
  }
@@ -33,13 +33,9 @@ export declare const minicss: Factory<Item>;
33
33
  */
34
34
  export declare const raw: Factory<Item>;
35
35
  /**
36
- * File loader
36
+ * file-loader
37
37
  */
38
38
  export declare const file: Factory<Item>;
39
- /**
40
- * Xml loader
41
- */
42
- export declare const xml: Factory<Item>;
43
39
  /**
44
40
  * Yml loader
45
41
  */
@@ -48,20 +48,16 @@ export const minicss = async ({ makeItem }) => makeItem()
48
48
  .setLoader(`minicss`)
49
49
  .setIdent(`minicss`)
50
50
  .setOptions(app => ({
51
- publicPath: app.hooks.filter(`build.output.publicPath`),
51
+ publicPath: app.publicPath(),
52
52
  }));
53
53
  /**
54
54
  * Raw loader
55
55
  */
56
56
  export const raw = async ({ makeItem }) => makeItem().setLoader(`raw`).setIdent(`raw`);
57
57
  /**
58
- * File loader
58
+ * file-loader
59
59
  */
60
60
  export const file = async ({ makeItem }) => makeItem().setLoader(`file`).setIdent(`file`);
61
- /**
62
- * Xml loader
63
- */
64
- export const xml = async ({ makeItem }) => makeItem().setLoader(`xml`).setIdent(`xml`);
65
61
  /**
66
62
  * Yml loader
67
63
  */
@@ -7,5 +7,4 @@ export declare const html: Factory<Loader>;
7
7
  export declare const remark: Factory<Loader>;
8
8
  export declare const minicss: Factory<Loader>;
9
9
  export declare const style: Factory<Loader>;
10
- export declare const xml: Factory<Loader>;
11
10
  export declare const yml: Factory<Loader>;
@@ -6,5 +6,4 @@ export const html = async ({ makeLoader, resolve }) => makeLoader(await resolve(
6
6
  export const remark = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/remark-loader`, import.meta.url));
7
7
  export const minicss = async ({ makeLoader, resolve }) => makeLoader(MiniCss.loader);
8
8
  export const style = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/style-loader`, import.meta.url));
9
- export const xml = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/xml-loader`, import.meta.url));
10
9
  export const yml = async ({ makeLoader, resolve }) => makeLoader(await resolve(`@roots/bud-support/yml-loader`, import.meta.url));
@@ -17,12 +17,12 @@ export async function register(bud) {
17
17
  : bud.build.items.style;
18
18
  Object.entries(rules).map(makeRegister(bud, bud.build.setRule));
19
19
  }
20
- export const makeRegister = ({ build, hooks, isProduction, path, module: { resolve } }, setRule) => async ([key, factory]) => setRule(key, await factory({
20
+ export const makeRegister = ({ build, hooks, isProduction, module: { resolve }, path }, setRule) => async ([key, factory]) => setRule(key, await factory({
21
21
  filter: hooks.filter,
22
+ isProduction,
22
23
  makeItem: build.makeItem,
23
24
  makeLoader: build.makeLoader,
24
25
  makeRule: build.makeRule,
25
- isProduction,
26
26
  path,
27
27
  resolve,
28
28
  }));
@@ -1,4 +1,4 @@
1
- export const csv = async ({ makeRule, path, filter }) => makeRule()
1
+ export const csv = async ({ filter, makeRule, path }) => makeRule()
2
2
  .setInclude([path()])
3
3
  .setTest(() => filter(`pattern.csv`))
4
4
  .setUse([`csv`]);
@@ -1,18 +1,17 @@
1
1
  export declare const rules: {
2
- toml: import("../index.js").Factory<import("../../rule/index.js").Rule>;
3
- xml: import("../index.js").Factory<import("../../rule/index.js").Rule>;
2
+ css: import("../index.js").Factory<import("../../rule/index.js").Rule>;
3
+ cssModule: import("../index.js").Factory<import("../../rule/index.js").Rule>;
4
4
  csv: import("../index.js").Factory<import("../../rule/index.js").Rule>;
5
- yml: import("../index.js").Factory<import("../../rule/index.js").Rule>;
6
- html: import("../index.js").Factory<import("../../rule/index.js").Rule>;
7
- json: import("../index.js").Factory<import("../../rule/index.js").Rule>;
8
5
  font: import("../index.js").Factory<import("../../rule/index.js").Rule>;
9
- svg: import("../index.js").Factory<import("../../rule/index.js").Rule>;
10
- webp: import("../index.js").Factory<import("../../rule/index.js").Rule>;
6
+ html: import("../index.js").Factory<import("../../rule/index.js").Rule>;
11
7
  image: import("../index.js").Factory<import("../../rule/index.js").Rule>;
12
8
  inlineFont: import("../index.js").Factory<import("../../rule/index.js").Rule>;
13
- inlineSvg: import("../index.js").Factory<import("../../rule/index.js").Rule>;
14
9
  inlineImage: import("../index.js").Factory<import("../../rule/index.js").Rule>;
15
- cssModule: import("../index.js").Factory<import("../../rule/index.js").Rule>;
16
- css: import("../index.js").Factory<import("../../rule/index.js").Rule>;
10
+ inlineSvg: import("../index.js").Factory<import("../../rule/index.js").Rule>;
17
11
  js: import("../index.js").Factory<import("../../rule/index.js").Rule>;
12
+ json: import("../index.js").Factory<import("../../rule/index.js").Rule>;
13
+ svg: import("../index.js").Factory<import("../../rule/index.js").Rule>;
14
+ toml: import("../index.js").Factory<import("../../rule/index.js").Rule>;
15
+ webp: import("../index.js").Factory<import("../../rule/index.js").Rule>;
16
+ yml: import("../index.js").Factory<import("../../rule/index.js").Rule>;
18
17
  };
@@ -12,23 +12,21 @@ import { inlineSvg } from './svg.inline.js';
12
12
  import { svg } from './svg.js';
13
13
  import { toml } from './toml.js';
14
14
  import { webp } from './webp.js';
15
- import { xml } from './xml.js';
16
15
  import { yml } from './yml.js';
17
16
  export const rules = {
18
- toml,
19
- xml,
17
+ css,
18
+ cssModule,
20
19
  csv,
21
- yml,
22
- html,
23
- json,
24
20
  font,
25
- svg,
26
- webp,
21
+ html,
27
22
  image,
28
23
  inlineFont,
29
- inlineSvg,
30
24
  inlineImage,
31
- cssModule,
32
- css,
25
+ inlineSvg,
33
26
  js,
27
+ json,
28
+ svg,
29
+ toml,
30
+ webp,
31
+ yml,
34
32
  };
@@ -1,4 +1,6 @@
1
1
  export const js = async ({ filter, makeRule, path }) => makeRule()
2
2
  .setTest(filter(`pattern.js`))
3
3
  .setInclude([() => path(`@src`)])
4
- .setUse([]);
4
+ .setResolve({
5
+ fullySpecified: false,
6
+ });
@@ -3,4 +3,6 @@ export const json = async ({ filter, makeRule, path }) => makeRule()
3
3
  .setType(`json`)
4
4
  .setInclude([() => path()])
5
5
  .setTest(filter(`pattern.json`))
6
- .setParser({ parse: json5.parse });
6
+ .setParser({
7
+ parse: json5.parse,
8
+ });
@@ -3,4 +3,6 @@ export const toml = async ({ filter, makeRule, path }) => makeRule()
3
3
  .setType(`json`)
4
4
  .setInclude([() => path()])
5
5
  .setTest(() => filter(`pattern.toml`))
6
- .setParser({ parse: tomlParser.parse });
6
+ .setParser({
7
+ parse: tomlParser.parse,
8
+ });
package/lib/index.d.ts CHANGED
@@ -4,10 +4,10 @@
4
4
  * @see https://bud.js.org
5
5
  * @see https://github.com/roots/bud
6
6
  */
7
- import './types.js';
8
7
  import { Item } from './item/index.js';
9
8
  import { Loader } from './loader/index.js';
10
9
  import { Rule } from './rule/index.js';
11
10
  import { Build } from './service.js';
11
+ import './types.js';
12
12
  export default Build;
13
13
  export { Item, Loader, Rule };
package/lib/index.js CHANGED
@@ -6,10 +6,10 @@
6
6
  * @see https://bud.js.org
7
7
  * @see https://github.com/roots/bud
8
8
  */
9
- import './types.js';
10
9
  import { Item } from './item/index.js';
11
10
  import { Loader } from './loader/index.js';
12
11
  import { Rule } from './rule/index.js';
13
12
  import { Build } from './service.js';
13
+ import './types.js';
14
14
  export default Build;
15
15
  export { Item, Loader, Rule };
@@ -15,7 +15,7 @@ declare class Item extends Base implements Build.Item {
15
15
  /**
16
16
  * Loader
17
17
  */
18
- loader: Loader | `${keyof Loaders & string}`;
18
+ loader: `${keyof Loaders & string}` | Loader;
19
19
  /**
20
20
  * Loader options
21
21
  */
@@ -25,31 +25,31 @@ declare class Item extends Base implements Build.Item {
25
25
  */
26
26
  constructor(_app: () => Bud, constructorParams?: {
27
27
  ident?: string;
28
- loader?: Loader | `${keyof Loaders & string}`;
28
+ loader?: `${keyof Loaders & string}` | Loader;
29
29
  options?: Item['options'];
30
30
  });
31
31
  getIdent(): Build.Item['ident'];
32
- setIdent(ident: Build.Item['ident']): this;
33
32
  /**
34
33
  * Get rule set item loader
35
34
  */
36
35
  getLoader(): Loader;
37
- /**
38
- * Set rule set item loader
39
- */
40
- setLoader(loader: Loader | `${keyof Loaders & string}`): this;
41
36
  /**
42
37
  * Get rule set item options
43
38
  */
44
39
  getOptions(): Item['options'];
45
- /**
46
- * Set rule set item options
47
- */
48
- setOptions(options: Item['options']): this;
49
40
  /**
50
41
  * Merge rule set item options
51
42
  */
52
43
  mergeOptions(options: Build.Item.Options): this;
44
+ setIdent(ident: Build.Item['ident']): this;
45
+ /**
46
+ * Set rule set item loader
47
+ */
48
+ setLoader(loader: `${keyof Loaders & string}` | Loader): this;
49
+ /**
50
+ * Set rule set item options
51
+ */
52
+ setOptions(options: Item['options']): this;
53
53
  /**
54
54
  * Produce rule set item object for Webpack
55
55
  */
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
  */
@@ -27,10 +40,6 @@ class Item extends Base {
27
40
  getIdent() {
28
41
  return this.ident;
29
42
  }
30
- setIdent(ident) {
31
- this.ident = ident;
32
- return this;
33
- }
34
43
  /**
35
44
  * Get rule set item loader
36
45
  */
@@ -39,28 +48,12 @@ class Item extends Base {
39
48
  ? this.loader
40
49
  : this.app.build.loaders[this.loader];
41
50
  }
42
- /**
43
- * Set rule set item loader
44
- */
45
- setLoader(loader) {
46
- this.loader = loader;
47
- if (!this.ident)
48
- this.setIdent(basename(isString(loader) ? loader : loader.getSrc()));
49
- return this;
50
- }
51
51
  /**
52
52
  * Get rule set item options
53
53
  */
54
54
  getOptions() {
55
55
  return this.unwrap(this.options);
56
56
  }
57
- /**
58
- * Set rule set item options
59
- */
60
- setOptions(options) {
61
- this.options = options;
62
- return this;
63
- }
64
57
  /**
65
58
  * Merge rule set item options
66
59
  */
@@ -71,6 +64,26 @@ class Item extends Base {
71
64
  });
72
65
  return this;
73
66
  }
67
+ setIdent(ident) {
68
+ this.ident = ident;
69
+ return this;
70
+ }
71
+ /**
72
+ * Set rule set item loader
73
+ */
74
+ setLoader(loader) {
75
+ this.loader = loader;
76
+ if (!this.ident)
77
+ this.setIdent(basename(isString(loader) ? loader : loader.getSrc()));
78
+ return this;
79
+ }
80
+ /**
81
+ * Set rule set item options
82
+ */
83
+ setOptions(options) {
84
+ this.options = options;
85
+ return this;
86
+ }
74
87
  /**
75
88
  * Produce rule set item object for Webpack
76
89
  */
@@ -102,39 +115,39 @@ __decorate([
102
115
  __decorate([
103
116
  bind,
104
117
  __metadata("design:type", Function),
105
- __metadata("design:paramtypes", [Object]),
106
- __metadata("design:returntype", Object)
107
- ], Item.prototype, "setIdent", null);
118
+ __metadata("design:paramtypes", []),
119
+ __metadata("design:returntype", Loader)
120
+ ], Item.prototype, "getLoader", null);
108
121
  __decorate([
109
122
  bind,
110
123
  __metadata("design:type", Function),
111
124
  __metadata("design:paramtypes", []),
112
- __metadata("design:returntype", Loader)
113
- ], Item.prototype, "getLoader", null);
125
+ __metadata("design:returntype", Object)
126
+ ], Item.prototype, "getOptions", null);
114
127
  __decorate([
115
128
  bind,
116
129
  __metadata("design:type", Function),
117
130
  __metadata("design:paramtypes", [Object]),
118
131
  __metadata("design:returntype", Object)
119
- ], Item.prototype, "setLoader", null);
132
+ ], Item.prototype, "mergeOptions", null);
120
133
  __decorate([
121
134
  bind,
122
135
  __metadata("design:type", Function),
123
- __metadata("design:paramtypes", []),
136
+ __metadata("design:paramtypes", [Object]),
124
137
  __metadata("design:returntype", Object)
125
- ], Item.prototype, "getOptions", null);
138
+ ], Item.prototype, "setIdent", null);
126
139
  __decorate([
127
140
  bind,
128
141
  __metadata("design:type", Function),
129
142
  __metadata("design:paramtypes", [Object]),
130
- __metadata("design:returntype", void 0)
131
- ], Item.prototype, "setOptions", null);
143
+ __metadata("design:returntype", Object)
144
+ ], Item.prototype, "setLoader", null);
132
145
  __decorate([
133
146
  bind,
134
147
  __metadata("design:type", Function),
135
148
  __metadata("design:paramtypes", [Object]),
136
- __metadata("design:returntype", Object)
137
- ], Item.prototype, "mergeOptions", null);
149
+ __metadata("design:returntype", void 0)
150
+ ], Item.prototype, "setOptions", null);
138
151
  __decorate([
139
152
  bind,
140
153
  __metadata("design:type", Function),
@@ -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
  *