@workleap/webpack-configs 1.5.2 → 1.5.3

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 (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/build.d.ts +18 -19
  3. package/dist/build.js +219 -3
  4. package/dist/build.js.map +1 -0
  5. package/dist/dev.d.ts +16 -17
  6. package/dist/dev.js +208 -3
  7. package/dist/dev.js.map +1 -0
  8. package/dist/index.d.ts +6 -12
  9. package/dist/index.js +15 -7
  10. package/dist/index.js.map +1 -0
  11. package/dist/transformers/applyTransformers.d.ts +4 -7
  12. package/dist/transformers/applyTransformers.js +20 -1
  13. package/dist/transformers/applyTransformers.js.map +1 -0
  14. package/dist/transformers/moduleRules.d.ts +15 -17
  15. package/dist/transformers/moduleRules.js +166 -1
  16. package/dist/transformers/moduleRules.js.map +1 -0
  17. package/dist/transformers/plugins.d.ts +11 -14
  18. package/dist/transformers/plugins.js +69 -1
  19. package/dist/transformers/plugins.js.map +1 -0
  20. package/dist/types.d.ts +1 -1
  21. package/dist/types.js +6 -1
  22. package/dist/types.js.map +1 -0
  23. package/dist/utils.d.ts +4 -6
  24. package/dist/utils.js +22 -1
  25. package/dist/utils.js.map +1 -0
  26. package/package.json +24 -22
  27. package/src/build.ts +240 -0
  28. package/src/dev.ts +233 -0
  29. package/src/index.ts +7 -0
  30. package/src/transformers/applyTransformers.ts +28 -0
  31. package/src/transformers/moduleRules.ts +229 -0
  32. package/src/transformers/plugins.ts +102 -0
  33. package/src/types.ts +1 -0
  34. package/src/utils.ts +19 -0
  35. package/dist/chunk-2YARCRX5.js +0 -15
  36. package/dist/chunk-34O5ZLZ6.js +0 -154
  37. package/dist/chunk-5ACA7GOB.js +0 -17
  38. package/dist/chunk-6F4PWJZI.js +0 -1
  39. package/dist/chunk-CW54GSNS.js +0 -197
  40. package/dist/chunk-JPURRV2F.js +0 -71
  41. package/dist/chunk-JU2EHEXW.js +0 -186
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
- export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig, getOptimizationConfig } from './chunk-CW54GSNS.js';
2
- export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-JU2EHEXW.js';
3
- import './chunk-6F4PWJZI.js';
4
- import './chunk-2YARCRX5.js';
5
- import './chunk-5ACA7GOB.js';
6
- export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-34O5ZLZ6.js';
7
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-JPURRV2F.js';
1
+ export * from "./build.js";
2
+ export * from "./dev.js";
3
+ export * from "./transformers/moduleRules.js";
4
+ export * from "./transformers/plugins.js";
5
+ export * from "./types.js";
6
+
7
+ ;// CONCATENATED MODULE: ./src/index.ts?__rslib_entry__
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["webpack://@workleap/webpack-configs/./src/index.ts"],"sourcesContent":["export * from \"./build.ts\";\nexport * from \"./dev.ts\";\nexport type { WebpackConfigTransformer, WebpackConfigTransformerContext } from \"./transformers/applyTransformers.ts\";\nexport * from \"./transformers/moduleRules.ts\";\nexport * from \"./transformers/plugins.ts\";\nexport * from \"./types.ts\";\n\n"],"names":[],"mappings":";;;;;;;AAA2B;AACF;AAEqB;AACJ;AACf"}
@@ -1,10 +1,7 @@
1
- import { Configuration } from 'webpack';
2
-
3
- interface WebpackConfigTransformerContext {
1
+ import type { WebpackConfig } from "../types.ts";
2
+ export interface WebpackConfigTransformerContext {
4
3
  environment: "dev" | "build";
5
4
  verbose: boolean;
6
5
  }
7
- type WebpackConfigTransformer = (config: Configuration, context: WebpackConfigTransformerContext) => Configuration;
8
- declare function applyTransformers(config: Configuration, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext): Configuration;
9
-
10
- export { type WebpackConfigTransformer, type WebpackConfigTransformerContext, applyTransformers };
6
+ export type WebpackConfigTransformer = (config: WebpackConfig, context: WebpackConfigTransformerContext) => WebpackConfig;
7
+ export declare function applyTransformers(config: WebpackConfig, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext): WebpackConfig;
@@ -1 +1,20 @@
1
- export { applyTransformers } from '../chunk-5ACA7GOB.js';
1
+
2
+ ;// CONCATENATED MODULE: ./src/transformers/applyTransformers.ts?__rslib_entry__
3
+ function applyTransformers(config, transformers, context) {
4
+ let count = 0;
5
+ const transformedConfig = transformers.reduce((acc, transformer)=>{
6
+ const newConfig = transformer(acc, context);
7
+ count += 1;
8
+ return newConfig;
9
+ }, config);
10
+ if (context.verbose) {
11
+ if (count > 0) {
12
+ console.log(`[webpack-configs] Applied ${count} configuration transformers.`);
13
+ }
14
+ }
15
+ return transformedConfig;
16
+ }
17
+
18
+ export { applyTransformers };
19
+
20
+ //# sourceMappingURL=applyTransformers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers/applyTransformers.js","sources":["webpack://@workleap/webpack-configs/./src/transformers/applyTransformers.ts"],"sourcesContent":["import type { WebpackConfig } from \"../types.ts\";\n\nexport interface WebpackConfigTransformerContext {\n environment: \"dev\" | \"build\";\n verbose: boolean;\n}\n\nexport type WebpackConfigTransformer = (config: WebpackConfig, context: WebpackConfigTransformerContext) => WebpackConfig;\n\nexport function applyTransformers(config: WebpackConfig, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext) {\n let count = 0;\n\n const transformedConfig = transformers.reduce((acc, transformer) => {\n const newConfig = transformer(acc, context);\n\n count += 1;\n\n return newConfig;\n }, config);\n\n if (context.verbose) {\n if (count > 0) {\n console.log(`[webpack-configs] Applied ${count} configuration transformers.`);\n }\n }\n\n return transformedConfig;\n}\n"],"names":["applyTransformers","config","transformers","context","count","transformedConfig","acc","transformer","newConfig","console"],"mappings":";;AASO,SAASA,kBAAkBC,MAAqB,EAAEC,YAAwC,EAAEC,OAAwC;IACvI,IAAIC,QAAQ;IAEZ,MAAMC,oBAAoBH,aAAa,MAAM,CAAC,CAACI,KAAKC;QAChD,MAAMC,YAAYD,YAAYD,KAAKH;QAEnCC,SAAS;QAET,OAAOI;IACX,GAAGP;IAEH,IAAIE,QAAQ,OAAO,EAAE;QACjB,IAAIC,QAAQ,GAAG;YACXK,QAAQ,GAAG,CAAC,CAAC,0BAA0B,EAAEL,MAAM,4BAA4B,CAAC;QAChF;IACJ;IAEA,OAAOC;AACX"}
@@ -1,26 +1,24 @@
1
- import { RuleSetRule, RuleSetUseItem, Configuration } from 'webpack';
2
-
3
- type ModuleRuleMatcher = (moduleRule: RuleSetRule | RuleSetUseItem, index: number, array: RuleSetRule[] | RuleSetUseItem[]) => boolean;
4
- type WithModuleRuleMatcherInfo = {
1
+ import type { RuleSetRule, RuleSetUseItem } from "webpack";
2
+ import type { WebpackConfig } from "../types.ts";
3
+ export type ModuleRuleMatcher = (moduleRule: RuleSetRule | RuleSetUseItem, index: number, array: RuleSetRule[] | RuleSetUseItem[]) => boolean;
4
+ export type WithModuleRuleMatcherInfo = {
5
5
  info: {
6
6
  type: string;
7
7
  value: string;
8
8
  };
9
9
  } & ModuleRuleMatcher;
10
- declare function matchLoaderName(name: string): ModuleRuleMatcher;
11
- type AssetModuleType = "javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/sync" | "webassembly/async" | "asset" | "asset/source" | "asset/resource" | "asset/inline";
12
- declare function matchAssetModuleType(type: AssetModuleType): ModuleRuleMatcher;
13
- declare function matchTest(test: string | RegExp): ModuleRuleMatcher;
14
- interface ModuleRuleMatch {
10
+ export declare function matchLoaderName(name: string): ModuleRuleMatcher;
11
+ export type AssetModuleType = "javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/sync" | "webassembly/async" | "asset" | "asset/source" | "asset/resource" | "asset/inline";
12
+ export declare function matchAssetModuleType(type: AssetModuleType): ModuleRuleMatcher;
13
+ export declare function matchTest(test: string | RegExp): ModuleRuleMatcher;
14
+ export interface ModuleRuleMatch {
15
15
  moduleRule: RuleSetRule | RuleSetUseItem;
16
16
  index: number;
17
17
  parent: RuleSetRule[] | RuleSetUseItem[];
18
18
  }
19
- declare function findModuleRule(config: Configuration, matcher: ModuleRuleMatcher): ModuleRuleMatch | undefined;
20
- declare function findModuleRules(config: Configuration, matcher: ModuleRuleMatcher): ModuleRuleMatch[] | undefined;
21
- declare function addBeforeModuleRule(config: Configuration, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]): void;
22
- declare function addAfterModuleRule(config: Configuration, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]): void;
23
- declare function replaceModuleRule(config: Configuration, matcher: ModuleRuleMatcher, newModuleRule: RuleSetRule | RuleSetUseItem): void;
24
- declare function removeModuleRules(config: Configuration, matcher: ModuleRuleMatcher): void;
25
-
26
- export { type AssetModuleType, type ModuleRuleMatch, type ModuleRuleMatcher, type WithModuleRuleMatcherInfo, addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule };
19
+ export declare function findModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher): ModuleRuleMatch | undefined;
20
+ export declare function findModuleRules(config: WebpackConfig, matcher: ModuleRuleMatcher): ModuleRuleMatch[] | undefined;
21
+ export declare function addBeforeModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]): void;
22
+ export declare function addAfterModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]): void;
23
+ export declare function replaceModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRule: RuleSetRule | RuleSetUseItem): void;
24
+ export declare function removeModuleRules(config: WebpackConfig, matcher: ModuleRuleMatcher): void;
@@ -1 +1,166 @@
1
- export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from '../chunk-34O5ZLZ6.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
2
+
3
+ ;// CONCATENATED MODULE: external "node:path"
4
+
5
+ ;// CONCATENATED MODULE: ./src/transformers/moduleRules.ts?__rslib_entry__
6
+
7
+ function isNameMatchingLoader(loader, name) {
8
+ return loader === name || loader.indexOf(`${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep}${name}${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep}`) !== -1 || loader.indexOf(`@${name}${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep}`) !== -1;
9
+ }
10
+ function matchLoaderName(name) {
11
+ const matcher = (moduleRule)=>{
12
+ if (typeof moduleRule === "string") {
13
+ return isNameMatchingLoader(moduleRule, name);
14
+ } else {
15
+ if ("loader" in moduleRule && moduleRule.loader) {
16
+ return isNameMatchingLoader(moduleRule.loader, name);
17
+ }
18
+ }
19
+ return false;
20
+ };
21
+ // Add contextual information about the matcher for debugging.
22
+ matcher.info = {
23
+ type: matchLoaderName.name,
24
+ value: name
25
+ };
26
+ return matcher;
27
+ }
28
+ function matchAssetModuleType(type) {
29
+ const matcher = (moduleRule)=>{
30
+ if (typeof moduleRule !== "string" && "type" in moduleRule) {
31
+ return moduleRule.type === type;
32
+ }
33
+ return false;
34
+ };
35
+ // Add contextual information about the matcher for debugging.
36
+ matcher.info = {
37
+ type: matchAssetModuleType.name,
38
+ value: type
39
+ };
40
+ return matcher;
41
+ }
42
+ function matchTest(test) {
43
+ const matcher = (moduleRule)=>{
44
+ if (typeof moduleRule !== "string" && "test" in moduleRule) {
45
+ if (typeof moduleRule.test === "object" && typeof test === "object") {
46
+ // Assuming it's regular expressions.
47
+ return moduleRule.test.toString() === test.toString();
48
+ }
49
+ return moduleRule.test === test;
50
+ }
51
+ return false;
52
+ };
53
+ // Add contextual information about the matcher for debugging.
54
+ matcher.info = {
55
+ type: matchTest.name,
56
+ value: test.toString()
57
+ };
58
+ return matcher;
59
+ }
60
+ function toMatch(moduleRule, index, parent) {
61
+ return {
62
+ moduleRule,
63
+ index,
64
+ parent
65
+ };
66
+ }
67
+ function isRuleSetRule(value) {
68
+ return value.use !== undefined || value.oneOf !== undefined;
69
+ }
70
+ function findModuleRulesRecursively(moduleRules, matcher, parent, matches) {
71
+ moduleRules.forEach((x, index, array)=>{
72
+ if (x) {
73
+ if (matcher(x, index, array)) {
74
+ matches.push(toMatch(x, index, parent));
75
+ } else {
76
+ if (isRuleSetRule(x)) {
77
+ if (x.use) {
78
+ findModuleRulesRecursively(x.use, matcher, x.use, matches);
79
+ } else if (x.oneOf) {
80
+ // This error seems to have been introduced by either TS 5.2. or webpack 5.88.1 (https://github.com/webpack/webpack/releases/tag/v5.88.1),
81
+ // I am not sure what changed thought.
82
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
+ // @ts-ignore
84
+ findModuleRulesRecursively(x.oneOf, matcher, x.oneOf, matches);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ });
90
+ }
91
+ function findModuleRule(config, matcher) {
92
+ const moduleRules = config.module?.rules;
93
+ if (!moduleRules) {
94
+ return;
95
+ }
96
+ const matches = [];
97
+ findModuleRulesRecursively(moduleRules, matcher, moduleRules, matches);
98
+ if (matches.length > 1) {
99
+ const matcherInfo = matcher.info;
100
+ throw new Error(`[webpack-configs] Found more than 1 matching module rule.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"\n[webpack-configs] Matches: "${JSON.stringify(matches.map((x)=>x.moduleRule))}"`);
101
+ }
102
+ return matches[0];
103
+ }
104
+ function findModuleRules(config, matcher) {
105
+ const moduleRules = config.module?.rules;
106
+ if (!moduleRules) {
107
+ return;
108
+ }
109
+ const matches = [];
110
+ findModuleRulesRecursively(moduleRules, matcher, moduleRules, matches);
111
+ return matches;
112
+ }
113
+ function addBeforeModuleRule(config, matcher, newModuleRules) {
114
+ const match = findModuleRule(config, matcher);
115
+ if (match) {
116
+ match.parent.splice(match.index, 0, ...newModuleRules);
117
+ } else {
118
+ const matcherInfo = matcher.info;
119
+ throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
120
+ }
121
+ }
122
+ function addAfterModuleRule(config, matcher, newModuleRules) {
123
+ const match = findModuleRule(config, matcher);
124
+ if (match) {
125
+ match.parent.splice(match.index + 1, 0, ...newModuleRules);
126
+ } else {
127
+ const matcherInfo = matcher.info;
128
+ throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
129
+ }
130
+ }
131
+ function replaceModuleRule(config, matcher, newModuleRule) {
132
+ const match = findModuleRule(config, matcher);
133
+ if (match) {
134
+ match.parent[match.index] = newModuleRule;
135
+ } else {
136
+ const matcherInfo = matcher.info;
137
+ throw new Error(`[webpack-configs] Couldn't replace the module rule because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
138
+ }
139
+ }
140
+ function removeModuleRules(config, matcher) {
141
+ const moduleRules = config.module?.rules;
142
+ if (!moduleRules) {
143
+ return;
144
+ }
145
+ const matches = [];
146
+ findModuleRulesRecursively(moduleRules, matcher, moduleRules, matches);
147
+ if (matches.length > 0) {
148
+ // Must keep the initial parent arrays' length to calculate the adjustment
149
+ // once the first match has been deleted.
150
+ const initialParentLengths = new Map(matches.map((x)=>[
151
+ x.parent,
152
+ x.parent.length
153
+ ]));
154
+ matches.forEach((x)=>{
155
+ const positionAdjustment = initialParentLengths.get(x.parent) - x.parent.length;
156
+ x.parent.splice(x.index - positionAdjustment, 1);
157
+ });
158
+ } else {
159
+ const matcherInfo = matcher.info;
160
+ throw new Error(`[webpack-configs] Didn't remove any module rules because no match has been found.\n[webpack-configs] Matcher: "${matcherInfo}"`);
161
+ }
162
+ }
163
+
164
+ export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule };
165
+
166
+ //# sourceMappingURL=moduleRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers/moduleRules.js","sources":["webpack://@workleap/webpack-configs/./src/transformers/moduleRules.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { RuleSetRule, RuleSetUseItem } from \"webpack\";\nimport type { WebpackConfig } from \"../types.ts\";\n\nexport type ModuleRuleMatcher = (moduleRule: RuleSetRule | RuleSetUseItem, index: number, array: RuleSetRule[] | RuleSetUseItem[]) => boolean;\n\nexport type WithModuleRuleMatcherInfo = {\n info: {\n type: string;\n value: string;\n };\n} & ModuleRuleMatcher;\n\nfunction isNameMatchingLoader(loader: string, name: string) {\n return loader === name || loader.indexOf(`${path.sep}${name}${path.sep}`) !== -1 || loader.indexOf(`@${name}${path.sep}`) !== -1;\n}\n\nexport function matchLoaderName(name: string): ModuleRuleMatcher {\n const matcher: WithModuleRuleMatcherInfo = moduleRule => {\n if (typeof moduleRule === \"string\") {\n return isNameMatchingLoader(moduleRule, name);\n } else {\n if (\"loader\" in moduleRule && moduleRule.loader) {\n return isNameMatchingLoader(moduleRule.loader, name);\n }\n }\n\n return false;\n };\n\n // Add contextual information about the matcher for debugging.\n matcher.info = {\n type: matchLoaderName.name,\n value: name\n };\n\n return matcher;\n}\n\nexport type AssetModuleType =\n | \"javascript/auto\"\n | \"javascript/dynamic\"\n | \"javascript/esm\"\n | \"json\"\n | \"webassembly/sync\"\n | \"webassembly/async\"\n | \"asset\"\n | \"asset/source\"\n | \"asset/resource\"\n | \"asset/inline\";\n\nexport function matchAssetModuleType(type: AssetModuleType): ModuleRuleMatcher {\n const matcher: WithModuleRuleMatcherInfo = moduleRule => {\n if (typeof moduleRule !== \"string\" && \"type\" in moduleRule) {\n return moduleRule.type === type;\n }\n\n return false;\n };\n\n // Add contextual information about the matcher for debugging.\n matcher.info = {\n type: matchAssetModuleType.name,\n value: type\n };\n\n return matcher;\n}\n\nexport function matchTest(test: string | RegExp): ModuleRuleMatcher {\n const matcher: WithModuleRuleMatcherInfo = moduleRule => {\n if (typeof moduleRule !== \"string\" && \"test\" in moduleRule) {\n if (typeof moduleRule.test === \"object\" && typeof test === \"object\") {\n // Assuming it's regular expressions.\n return moduleRule.test.toString() === test.toString();\n }\n\n return moduleRule.test === test;\n }\n\n return false;\n };\n\n // Add contextual information about the matcher for debugging.\n matcher.info = {\n type: matchTest.name,\n value: test.toString()\n };\n\n return matcher;\n}\n\nexport interface ModuleRuleMatch {\n moduleRule: RuleSetRule | RuleSetUseItem;\n index: number;\n parent: RuleSetRule[] | RuleSetUseItem[];\n}\n\nfunction toMatch(moduleRule: RuleSetRule | RuleSetUseItem, index: number, parent: RuleSetRule[] | RuleSetUseItem[]) {\n return {\n moduleRule,\n index,\n parent\n };\n}\n\nfunction isRuleSetRule(value: RuleSetRule | RuleSetUseItem): value is RuleSetRule {\n return (value as RuleSetRule).use !== undefined || (value as RuleSetRule).oneOf !== undefined;\n}\n\nfunction findModuleRulesRecursively(moduleRules: RuleSetRule[] | RuleSetUseItem[], matcher: ModuleRuleMatcher, parent: RuleSetRule[] | RuleSetUseItem[], matches: ModuleRuleMatch[]) {\n moduleRules.forEach((x, index, array) => {\n if (x) {\n if (matcher(x, index, array)) {\n matches.push(toMatch(x, index, parent));\n } else {\n if (isRuleSetRule(x)) {\n if (x.use) {\n findModuleRulesRecursively(x.use as RuleSetUseItem[], matcher, x.use as RuleSetUseItem[], matches);\n } else if (x.oneOf) {\n // This error seems to have been introduced by either TS 5.2. or webpack 5.88.1 (https://github.com/webpack/webpack/releases/tag/v5.88.1),\n // I am not sure what changed thought.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n findModuleRulesRecursively(x.oneOf, matcher, x.oneOf, matches);\n }\n }\n }\n }\n });\n}\n\nexport function findModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher) {\n const moduleRules = config.module?.rules;\n\n if (!moduleRules) {\n return;\n }\n\n const matches: ModuleRuleMatch[] = [];\n\n findModuleRulesRecursively(moduleRules as RuleSetRule[], matcher, moduleRules as RuleSetRule[], matches);\n\n if (matches.length > 1) {\n const matcherInfo = (matcher as WithModuleRuleMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Found more than 1 matching module rule.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"\\n[webpack-configs] Matches: \"${JSON.stringify(matches.map(x => x.moduleRule))}\"`);\n }\n\n return matches[0];\n}\n\nexport function findModuleRules(config: WebpackConfig, matcher: ModuleRuleMatcher) {\n const moduleRules = config.module?.rules;\n\n if (!moduleRules) {\n return;\n }\n\n const matches: ModuleRuleMatch[] = [];\n\n findModuleRulesRecursively(moduleRules as RuleSetRule[], matcher, moduleRules as RuleSetRule[], matches);\n\n return matches;\n}\n\nexport function addBeforeModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]) {\n const match = findModuleRule(config, matcher);\n\n if (match) {\n match.parent.splice(match.index, 0, ...newModuleRules);\n } else {\n const matcherInfo = (matcher as WithModuleRuleMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function addAfterModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRules: RuleSetRule[] | RuleSetUseItem[]) {\n const match = findModuleRule(config, matcher);\n\n if (match) {\n match.parent.splice(match.index + 1, 0, ...newModuleRules);\n } else {\n const matcherInfo = (matcher as WithModuleRuleMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't add the new module rules because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function replaceModuleRule(config: WebpackConfig, matcher: ModuleRuleMatcher, newModuleRule: RuleSetRule | RuleSetUseItem) {\n const match = findModuleRule(config, matcher);\n\n if (match) {\n match.parent[match.index] = newModuleRule;\n } else {\n const matcherInfo = (matcher as WithModuleRuleMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't replace the module rule because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function removeModuleRules(config: WebpackConfig, matcher: ModuleRuleMatcher) {\n const moduleRules = config.module?.rules;\n\n if (!moduleRules) {\n return;\n }\n\n const matches: ModuleRuleMatch[] = [];\n\n findModuleRulesRecursively(moduleRules as RuleSetRule[], matcher, moduleRules as RuleSetRule[], matches);\n\n if (matches.length > 0) {\n // Must keep the initial parent arrays' length to calculate the adjustment\n // once the first match has been deleted.\n const initialParentLengths = new Map<RuleSetRule[] | RuleSetUseItem[], number>(matches.map(x => [x.parent, x.parent.length]));\n\n matches.forEach(x => {\n const positionAdjustment = initialParentLengths.get(x.parent)! - x.parent.length;\n\n x.parent.splice(x.index - positionAdjustment, 1);\n });\n } else {\n const matcherInfo = (matcher as WithModuleRuleMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Didn't remove any module rules because no match has been found.\\n[webpack-configs] Matcher: \"${matcherInfo}\"`);\n }\n}\n"],"names":["path","isNameMatchingLoader","loader","name","matchLoaderName","matcher","moduleRule","matchAssetModuleType","type","matchTest","test","toMatch","index","parent","isRuleSetRule","value","undefined","findModuleRulesRecursively","moduleRules","matches","x","array","findModuleRule","config","matcherInfo","Error","JSON","findModuleRules","addBeforeModuleRule","newModuleRules","match","addAfterModuleRule","replaceModuleRule","newModuleRule","removeModuleRules","initialParentLengths","Map","positionAdjustment"],"mappings":";;;;;AAA6B;AAa7B,SAASC,qBAAqBC,MAAc,EAAEC,IAAY;IACtD,OAAOD,WAAWC,QAAQD,OAAO,OAAO,CAAC,GAA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C,UAA6B,EAAE;IAErCF,2BAA2BC,aAA8Bb,SAASa,aAA8BC;IAEhG,IAAIA,QAAQ,MAAM,GAAG,GAAG;QACpB,0EAA0E;QAC1E,yCAAyC;QACzC,MAAMgB,uBAAuB,IAAIC,IAA8CjB,QAAQ,GAAG,CAACC,CAAAA,IAAK;gBAACA,EAAE,MAAM;gBAAEA,EAAE,MAAM,CAAC,MAAM;aAAC;QAE3HD,QAAQ,OAAO,CAACC,CAAAA;YACZ,MAAMiB,qBAAqBF,qBAAqB,GAAG,CAACf,EAAE,MAAM,IAAKA,EAAE,MAAM,CAAC,MAAM;YAEhFA,EAAE,MAAM,CAAC,MAAM,CAACA,EAAE,KAAK,GAAGiB,oBAAoB;QAClD;IACJ,OAAO;QACH,MAAMb,cAAenB,QAAsC,IAAI;QAE/D,MAAM,IAAIoB,MAAM,CAAC,+GAA+G,EAAED,YAAY,CAAC,CAAC;IACpJ;AACJ"}
@@ -1,22 +1,19 @@
1
- import { Configuration } from 'webpack';
2
-
3
- type WebpackPlugin = NonNullable<Configuration["plugins"]>[number];
4
- type PluginMatcher = (plugin: WebpackPlugin, index: number, array: WebpackPlugin[]) => boolean;
5
- type WithPluginMatcherInfo = {
1
+ import type { WebpackConfig } from "../types.ts";
2
+ export type WebpackPlugin = NonNullable<WebpackConfig["plugins"]>[number];
3
+ export type PluginMatcher = (plugin: WebpackPlugin, index: number, array: WebpackPlugin[]) => boolean;
4
+ export type WithPluginMatcherInfo = {
6
5
  info: {
7
6
  type: string;
8
7
  value: string;
9
8
  };
10
9
  } & PluginMatcher;
11
- declare function matchConstructorName(name: string): PluginMatcher;
12
- interface PluginMatch {
10
+ export declare function matchConstructorName(name: string): PluginMatcher;
11
+ export interface PluginMatch {
13
12
  plugin: WebpackPlugin;
14
13
  index: number;
15
14
  }
16
- declare function findPlugin(config: Configuration, matcher: PluginMatcher): PluginMatch;
17
- declare function replacePlugin(config: Configuration, matcher: PluginMatcher, newPlugin: WebpackPlugin): void;
18
- declare function addBeforePlugin(config: Configuration, matcher: PluginMatcher, newPlugins: WebpackPlugin[]): void;
19
- declare function addAfterPlugin(config: Configuration, matcher: PluginMatcher, newPlugins: WebpackPlugin[]): void;
20
- declare function removePlugin(config: Configuration, matcher: PluginMatcher): void;
21
-
22
- export { type PluginMatch, type PluginMatcher, type WebpackPlugin, type WithPluginMatcherInfo, addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin };
15
+ export declare function findPlugin(config: WebpackConfig, matcher: PluginMatcher): PluginMatch;
16
+ export declare function replacePlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugin: WebpackPlugin): void;
17
+ export declare function addBeforePlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugins: WebpackPlugin[]): void;
18
+ export declare function addAfterPlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugins: WebpackPlugin[]): void;
19
+ export declare function removePlugin(config: WebpackConfig, matcher: PluginMatcher): void;
@@ -1 +1,69 @@
1
- export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from '../chunk-JPURRV2F.js';
1
+
2
+ ;// CONCATENATED MODULE: ./src/transformers/plugins.ts?__rslib_entry__
3
+ function matchConstructorName(name) {
4
+ const matcher = (plugin)=>{
5
+ return plugin?.constructor.name === name;
6
+ };
7
+ // Add contextual information about the matcher for debugging.
8
+ matcher.info = {
9
+ type: matchConstructorName.name,
10
+ value: name
11
+ };
12
+ return matcher;
13
+ }
14
+ function findPlugin(config, matcher) {
15
+ const matches = [];
16
+ config.plugins?.forEach((x, index, array)=>{
17
+ if (matcher(x, index, array)) {
18
+ matches.push({
19
+ plugin: x,
20
+ index
21
+ });
22
+ }
23
+ });
24
+ if (matches.length > 1) {
25
+ const matcherInfo = matcher.info;
26
+ throw new Error(`[webpack-configs] Found more than 1 matching plugin.\n[webp-configs] Matcher: "${JSON.stringify(matcherInfo)}"\n[webpack-configs] Matches: "${JSON.stringify(matches.map((x)=>x.plugin))}"`);
27
+ }
28
+ return matches[0];
29
+ }
30
+ function replacePlugin(config, matcher, newPlugin) {
31
+ const match = findPlugin(config, matcher);
32
+ if (match) {
33
+ config.plugins[match.index] = newPlugin;
34
+ } else {
35
+ const matcherInfo = matcher.info;
36
+ throw new Error(`[webpack-configs] Couldn't replace the plugin because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
37
+ }
38
+ }
39
+ function addBeforePlugin(config, matcher, newPlugins) {
40
+ const match = findPlugin(config, matcher);
41
+ if (match) {
42
+ config.plugins?.splice(match.index, 0, ...newPlugins);
43
+ } else {
44
+ const matcherInfo = matcher.info;
45
+ throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
46
+ }
47
+ }
48
+ function addAfterPlugin(config, matcher, newPlugins) {
49
+ const match = findPlugin(config, matcher);
50
+ if (match) {
51
+ config.plugins?.splice(match.index + 1, 0, ...newPlugins);
52
+ } else {
53
+ const matcherInfo = matcher.info;
54
+ throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
55
+ }
56
+ }
57
+ function removePlugin(config, matcher) {
58
+ const countBefore = config.plugins?.length ?? 0;
59
+ config.plugins = config.plugins?.filter((...args)=>!matcher(...args));
60
+ const countAfter = config.plugins?.length ?? 0;
61
+ if (countBefore === countAfter) {
62
+ const matcherInfo = matcher.info;
63
+ throw new Error(`[webpack-configs] Didn't remove any plugin because no match has been found.\n[webpack-configs] Matcher: "${JSON.stringify(matcherInfo)}"`);
64
+ }
65
+ }
66
+
67
+ export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin };
68
+
69
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers/plugins.js","sources":["webpack://@workleap/webpack-configs/./src/transformers/plugins.ts"],"sourcesContent":["import type { WebpackConfig } from \"../types.ts\";\n\nexport type WebpackPlugin = NonNullable<WebpackConfig[\"plugins\"]>[number];\n\nexport type PluginMatcher = (plugin: WebpackPlugin, index: number, array: WebpackPlugin[]) => boolean;\n\nexport type WithPluginMatcherInfo = {\n info: {\n type: string;\n value: string;\n };\n} & PluginMatcher;\n\nexport function matchConstructorName(name: string): PluginMatcher {\n const matcher: WithPluginMatcherInfo = plugin => {\n return plugin?.constructor.name === name;\n };\n\n // Add contextual information about the matcher for debugging.\n matcher.info = {\n type: matchConstructorName.name,\n value: name\n };\n\n return matcher;\n}\n\nexport interface PluginMatch {\n plugin: WebpackPlugin;\n index: number;\n}\n\nexport function findPlugin(config: WebpackConfig, matcher: PluginMatcher) {\n const matches: PluginMatch[] = [];\n\n config.plugins?.forEach((x, index, array) => {\n if (matcher(x, index, array)) {\n matches.push({\n plugin: x,\n index\n });\n }\n });\n\n if (matches.length > 1) {\n const matcherInfo = (matcher as WithPluginMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Found more than 1 matching plugin.\\n[webp-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"\\n[webpack-configs] Matches: \"${JSON.stringify(matches.map(x => x.plugin))}\"`);\n }\n\n return matches[0];\n}\n\nexport function replacePlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugin: WebpackPlugin) {\n const match = findPlugin(config, matcher);\n\n if (match) {\n config.plugins![match.index] = newPlugin;\n } else {\n const matcherInfo = (matcher as WithPluginMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't replace the plugin because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function addBeforePlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugins: WebpackPlugin[]) {\n const match = findPlugin(config, matcher);\n\n if (match) {\n config.plugins?.splice(match.index, 0, ...newPlugins);\n } else {\n const matcherInfo = (matcher as WithPluginMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function addAfterPlugin(config: WebpackConfig, matcher: PluginMatcher, newPlugins: WebpackPlugin[]) {\n const match = findPlugin(config, matcher);\n\n if (match) {\n config.plugins?.splice(match.index + 1, 0, ...newPlugins);\n } else {\n const matcherInfo = (matcher as WithPluginMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Couldn't add the new plugins because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n\nexport function removePlugin(config: WebpackConfig, matcher: PluginMatcher) {\n const countBefore = config.plugins?.length ?? 0;\n\n config.plugins = config.plugins?.filter((...args) => !matcher(...args));\n\n const countAfter = config.plugins?.length ?? 0;\n\n if (countBefore === countAfter) {\n const matcherInfo = (matcher as WithPluginMatcherInfo).info;\n\n throw new Error(`[webpack-configs] Didn't remove any plugin because no match has been found.\\n[webpack-configs] Matcher: \"${JSON.stringify(matcherInfo)}\"`);\n }\n}\n"],"names":["matchConstructorName","name","matcher","plugin","findPlugin","config","matches","x","index","array","matcherInfo","Error","JSON","replacePlugin","newPlugin","match","addBeforePlugin","newPlugins","addAfterPlugin","removePlugin","countBefore","args","countAfter"],"mappings":";;AAaO,SAASA,qBAAqBC,IAAY;IAC7C,MAAMC,UAAiCC,CAAAA;QACnC,OAAOA,QAAQ,YAAY,SAASF;IACxC;IAEA,8DAA8D;IAC9DC,QAAQ,IAAI,GAAG;QACX,MAAMF,qBAAqB,IAAI;QAC/B,OAAOC;IACX;IAEA,OAAOC;AACX;AAOO,SAASE,WAAWC,MAAqB,EAAEH,OAAsB;IACpE,MAAMI,UAAyB,EAAE;IAEjCD,OAAO,OAAO,EAAE,QAAQ,CAACE,GAAGC,OAAOC;QAC/B,IAAIP,QAAQK,GAAGC,OAAOC,QAAQ;YAC1BH,QAAQ,IAAI,CAAC;gBACT,QAAQC;gBACRC;YACJ;QACJ;IACJ;IAEA,IAAIF,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAM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AAO,EAAE,UAAU;IAE9CA,OAAO,OAAO,GAAGA,OAAO,OAAO,EAAE,OAAO,CAAC,GAAGgB,OAAS,CAACnB,WAAWmB;IAEjE,MAAMC,aAAajB,OAAO,OAAO,EAAE,UAAU;IAE7C,IAAIe,gBAAgBE,YAAY;QAC5B,MAAMZ,cAAeR,QAAkC,IAAI;QAE3D,MAAM,IAAIS,MAAM,CAAC,yGAAyG,EAAEC,KAAK,SAAS,CAACF,aAAa,CAAC,CAAC;IAC9J;AACJ"}
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export { Configuration as WebpackConfig } from 'webpack';
1
+ export type { Configuration as WebpackConfig } from "webpack";
package/dist/types.js CHANGED
@@ -1 +1,6 @@
1
- import './chunk-6F4PWJZI.js';
1
+
2
+ ;// CONCATENATED MODULE: ./src/types.ts?__rslib_entry__
3
+
4
+
5
+
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["webpack://@workleap/webpack-configs/./src/types.ts"],"sourcesContent":["export type { Configuration as WebpackConfig } from \"webpack\";\n"],"names":[],"mappings":";;AAA8D"}
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- declare function isObject(value: any): value is Record<string, unknown>;
2
- declare function isNull(value: any): value is null;
3
- declare function isUndefined(value: any): value is undefined;
4
- declare function isNil(value: any): value is null | undefined;
5
-
6
- export { isNil, isNull, isObject, isUndefined };
1
+ export declare function isObject(value: any): value is Record<string, unknown>;
2
+ export declare function isNull(value: any): value is null;
3
+ export declare function isUndefined(value: any): value is undefined;
4
+ export declare function isNil(value: any): value is null | undefined;
package/dist/utils.js CHANGED
@@ -1 +1,22 @@
1
- export { isNil, isNull, isObject, isUndefined } from './chunk-2YARCRX5.js';
1
+
2
+ ;// CONCATENATED MODULE: ./src/utils.ts?__rslib_entry__
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ function isObject(value) {
5
+ return typeof value === "object" && !Array.isArray(value) && value != null;
6
+ }
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ function isNull(value) {
9
+ return value == null;
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ function isUndefined(value) {
13
+ return typeof value === "undefined" || value === undefined;
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ function isNil(value) {
17
+ return isNull(value) || isUndefined(value);
18
+ }
19
+
20
+ export { isNil, isNull, isObject, isUndefined };
21
+
22
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["webpack://@workleap/webpack-configs/./src/utils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isObject(value: any): value is Record<string, unknown> {\n return typeof value === \"object\" && !Array.isArray(value) && value != null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isNull(value: any): value is null {\n return value == null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isUndefined(value: any): value is undefined {\n return typeof value === \"undefined\" || value === undefined;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isNil(value: any): value is null | undefined {\n return isNull(value) || isUndefined(value);\n}\n"],"names":["isObject","value","Array","isNull","isUndefined","undefined","isNil"],"mappings":";;AAAA,8DAA8D;AACvD,SAASA,SAASC,KAAU;IAC/B,OAAO,OAAOA,UAAU,YAAY,CAACC,MAAM,OAAO,CAACD,UAAUA,SAAS;AAC1E;AAEA,8DAA8D;AACvD,SAASE,OAAOF,KAAU;IAC7B,OAAOA,SAAS;AACpB;AAEA,8DAA8D;AACvD,SAASG,YAAYH,KAAU;IAClC,OAAO,OAAOA,UAAU,eAAeA,UAAUI;AACrD;AAEA,8DAA8D;AACvD,SAASC,MAAML,KAAU;IAC5B,OAAOE,OAAOF,UAAUG,YAAYH;AACxC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@workleap/webpack-configs",
3
3
  "author": "Workleap",
4
- "description": "Workleap recommended webpack config.",
5
- "version": "1.5.2",
4
+ "description": "Workleap recommended webpack configurations.",
5
+ "version": "1.5.3",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -22,6 +22,7 @@
22
22
  }
23
23
  },
24
24
  "files": [
25
+ "src",
25
26
  "dist",
26
27
  "CHANGELOG.md",
27
28
  "README.md"
@@ -39,24 +40,6 @@
39
40
  "optional": true
40
41
  }
41
42
  },
42
- "devDependencies": {
43
- "@svgr/core": "8.1.0",
44
- "@swc/core": "1.10.1",
45
- "@swc/helpers": "0.5.15",
46
- "@swc/jest": "0.2.37",
47
- "@types/jest": "29.5.14",
48
- "@types/node": "22.10.1",
49
- "@typescript-eslint/parser": "8.18.0",
50
- "eslint": "8.57.0",
51
- "jest": "29.7.0",
52
- "ts-node": "10.9.2",
53
- "tsup": "8.3.5",
54
- "typescript": "5.5.4",
55
- "@workleap/eslint-plugin": "3.2.4",
56
- "@workleap/swc-configs": "2.2.3",
57
- "@workleap/tsup-configs": "3.0.6",
58
- "@workleap/typescript-configs": "3.0.2"
59
- },
60
43
  "dependencies": {
61
44
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
62
45
  "@svgr/webpack": "^8.1.0",
@@ -67,10 +50,29 @@
67
50
  "react-refresh": "^0.16.0",
68
51
  "style-loader": "^4.0.0",
69
52
  "swc-loader": "^0.2.6",
70
- "terser-webpack-plugin": "^5.3.10"
53
+ "terser-webpack-plugin": "^5.3.11"
54
+ },
55
+ "devDependencies": {
56
+ "@rsbuild/core": "1.1.13",
57
+ "@rslib/core": "0.3.1",
58
+ "@svgr/core": "8.1.0",
59
+ "@swc/core": "1.10.7",
60
+ "@swc/helpers": "0.5.15",
61
+ "@swc/jest": "0.2.37",
62
+ "@types/jest": "29.5.14",
63
+ "@types/node": "22.10.7",
64
+ "@typescript-eslint/parser": "8.20.0",
65
+ "eslint": "8.57.0",
66
+ "jest": "29.7.0",
67
+ "ts-node": "10.9.2",
68
+ "typescript": "5.5.4",
69
+ "@workleap/eslint-plugin": "3.2.6",
70
+ "@workleap/rslib-configs": "1.0.2",
71
+ "@workleap/swc-configs": "2.2.4",
72
+ "@workleap/typescript-configs": "3.0.2"
71
73
  },
72
74
  "scripts": {
73
- "build": "tsup",
75
+ "build": "rslib build -c rslib.config.ts",
74
76
  "eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
75
77
  "typecheck": "tsc",
76
78
  "test": "jest"