@rspack/core 1.0.0-beta.0 → 1.0.0-beta.2

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 (177) hide show
  1. package/dist/ChunkGroup.d.ts +1 -0
  2. package/dist/ChunkGroup.js +3 -0
  3. package/dist/Compilation.d.ts +19 -1
  4. package/dist/Compiler.d.ts +11 -10
  5. package/dist/Compiler.js +16 -16
  6. package/dist/ExecuteModulePlugin.d.ts +0 -1
  7. package/dist/ExecuteModulePlugin.js +0 -1
  8. package/dist/Module.d.ts +2 -2
  9. package/dist/Module.js +1 -1
  10. package/dist/MultiCompiler.js +1 -1
  11. package/dist/NormalModule.d.ts +1 -0
  12. package/dist/NormalModule.js +1 -0
  13. package/dist/Resolver.d.ts +1 -2
  14. package/dist/RspackError.js +1 -1
  15. package/dist/Stats.js +22 -2
  16. package/dist/Template.js +2 -2
  17. package/dist/builtin-loader/lightningcss/index.js +1 -1
  18. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/BannerPlugin.d.ts +31 -31
  23. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/DefinePlugin.js +1 -1
  31. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  36. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
  37. package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
  38. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  39. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
  40. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/EntryPlugin.d.ts +3 -2
  42. package/dist/builtin-plugin/EntryPlugin.js +1 -0
  43. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/ExternalsPlugin.d.ts +5 -5
  46. package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
  47. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  52. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
  56. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  57. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -11
  60. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +2 -3
  81. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  82. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/base.d.ts +1 -1
  84. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
  85. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
  86. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  87. package/dist/builtin-plugin/css-extract/loader.js +27 -22
  88. package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
  89. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  90. package/dist/config/adapter.js +16 -2
  91. package/dist/config/adapterRuleUse.d.ts +2 -6
  92. package/dist/config/adapterRuleUse.js +10 -9
  93. package/dist/config/defaults.js +28 -42
  94. package/dist/config/normalization.d.ts +7 -3
  95. package/dist/config/normalization.js +7 -2
  96. package/dist/config/zod.d.ts +1634 -1093
  97. package/dist/config/zod.js +31 -2
  98. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  99. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  100. package/dist/container/default.runtime.js +1 -1
  101. package/dist/exports.d.ts +1 -1
  102. package/dist/lib/AbstractMethodError.d.ts +12 -3
  103. package/dist/lib/AbstractMethodError.js +29 -22
  104. package/dist/lib/Cache.d.ts +40 -46
  105. package/dist/lib/Cache.js +43 -78
  106. package/dist/lib/CacheFacade.d.ts +119 -143
  107. package/dist/lib/CacheFacade.js +123 -124
  108. package/dist/lib/Dependency.d.ts +23 -0
  109. package/dist/lib/Dependency.js +11 -0
  110. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  111. package/dist/lib/EntryOptionPlugin.js +22 -6
  112. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  113. package/dist/lib/EnvironmentPlugin.js +16 -17
  114. package/dist/lib/HookWebpackError.d.ts +27 -33
  115. package/dist/lib/HookWebpackError.js +33 -34
  116. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  117. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  118. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  119. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  120. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  121. package/dist/lib/LoaderTargetPlugin.js +17 -15
  122. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  123. package/dist/lib/ModuleFilenameHelpers.js +10 -1
  124. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  125. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  126. package/dist/lib/WebpackError.d.ts +23 -22
  127. package/dist/lib/WebpackError.js +15 -35
  128. package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
  129. package/dist/lib/cache/MemoryCachePlugin.js +40 -0
  130. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  131. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  132. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  133. package/dist/lib/cache/mergeEtags.js +18 -11
  134. package/dist/lib/formatLocation.d.ts +14 -9
  135. package/dist/lib/formatLocation.js +17 -15
  136. package/dist/loader-runner/index.js +6 -7
  137. package/dist/loader-runner/loadLoader.js +8 -11
  138. package/dist/logging/Logger.js +3 -3
  139. package/dist/logging/createConsoleLogger.d.ts +26 -6
  140. package/dist/logging/createConsoleLogger.js +21 -58
  141. package/dist/logging/runtime.d.ts +4 -10
  142. package/dist/logging/runtime.js +8 -23
  143. package/dist/logging/truncateArgs.d.ts +4 -4
  144. package/dist/logging/truncateArgs.js +5 -10
  145. package/dist/node/NodeEnvironmentPlugin.js +2 -2
  146. package/dist/node/NodeWatchFileSystem.js +6 -6
  147. package/dist/node/nodeConsole.d.ts +7 -21
  148. package/dist/node/nodeConsole.js +29 -36
  149. package/dist/rspackOptionsApply.d.ts +0 -1
  150. package/dist/rspackOptionsApply.js +10 -9
  151. package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
  152. package/dist/sharing/ProvideSharedPlugin.js +26 -17
  153. package/dist/sharing/SharePlugin.d.ts +3 -0
  154. package/dist/sharing/SharePlugin.js +4 -1
  155. package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
  156. package/dist/stats/DefaultStatsPresetPlugin.js +1 -2
  157. package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
  158. package/dist/stats/StatsFactory.d.ts +2 -1
  159. package/dist/stats/StatsFactory.js +2 -6
  160. package/dist/stats/statsFactoryUtils.d.ts +63 -23
  161. package/dist/util/SizeFormatHelpers.js +1 -1
  162. package/dist/util/bindingVersionCheck.js +3 -3
  163. package/dist/util/cleverMerge.js +3 -2
  164. package/dist/util/comparators.d.ts +2 -2
  165. package/dist/util/comparators.js +5 -4
  166. package/dist/util/createHash.js +1 -1
  167. package/dist/util/fs.js +2 -2
  168. package/dist/util/identifier.js +2 -2
  169. package/dist/util/index.js +1 -1
  170. package/dist/util/memoize.js +1 -4
  171. package/dist/util/smartGrouping.js +4 -6
  172. package/dist/util/webpack.d.ts +1 -1
  173. package/dist/util/webpack.js +2 -1
  174. package/module.d.ts +1 -1
  175. package/package.json +3 -3
  176. package/compiled/enhanced-resolve/index.js +0 -5566
  177. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -1,46 +1,40 @@
1
- export = HookWebpackError;
2
- /** @typedef {any} Module */
3
1
  /**
4
- * @template T
5
- * @callback Callback
6
- * @param {Error=} err
7
- * @param {T=} stats
8
- * @returns {void}
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/HookWebpackError.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- declare class HookWebpackError extends WebpackError {
10
+ import type { Callback } from "@rspack/lite-tapable";
11
+ import WebpackError from "./WebpackError";
12
+ export declare class HookWebpackError extends WebpackError {
13
+ hook: string;
14
+ error: Error;
11
15
  /**
12
16
  * Creates an instance of HookWebpackError.
13
- * @param {Error} error inner error
14
- * @param {string} hook name of hook
17
+ * @param error inner error
18
+ * @param hook name of hook
15
19
  */
16
20
  constructor(error: Error, hook: string);
17
- hook: string;
18
- error: Error;
19
- details: string;
20
- }
21
- declare namespace HookWebpackError {
22
- export { makeWebpackError, makeWebpackErrorCallback, tryRunOrWebpackError, Module, Callback };
23
21
  }
24
- import WebpackError = require("./WebpackError.js");
22
+ export default HookWebpackError;
25
23
  /**
26
- * @param {Error} error an error
27
- * @param {string} hook name of the hook
28
- * @returns {WebpackError} a webpack error
24
+ * @param error an error
25
+ * @param hook name of the hook
26
+ * @returns a webpack error
29
27
  */
30
- declare function makeWebpackError(error: Error, hook: string): WebpackError;
28
+ export declare const makeWebpackError: (error: Error, hook: string) => WebpackError;
31
29
  /**
32
- * @template T
33
- * @param {function((WebpackError | null)=, T=): void} callback webpack error callback
34
- * @param {string} hook name of hook
35
- * @returns {Callback<T>} generic callback
30
+ * @param callback webpack error callback
31
+ * @param hook name of hook
32
+ * @returns generic callback
36
33
  */
37
- declare function makeWebpackErrorCallback<T>(callback: (arg0?: (WebpackError | null) | undefined, arg1?: T | undefined) => void, hook: string): Callback<T>;
34
+ export declare const makeWebpackErrorCallback: <T>(callback: (error?: WebpackError | null, result?: T | undefined) => void, hook: string) => Callback<Error, T>;
38
35
  /**
39
- * @template T
40
- * @param {function(): T} fn function which will be wrapping in try catch
41
- * @param {string} hook name of hook
42
- * @returns {T} the result
36
+ * @param fn function which will be wrapping in try catch
37
+ * @param hook name of hook
38
+ * @returns the result
43
39
  */
44
- declare function tryRunOrWebpackError<T>(fn: () => T, hook: string): T;
45
- type Module = any;
46
- type Callback<T> = (err?: Error | undefined, stats?: T | undefined) => void;
40
+ export declare const tryRunOrWebpackError: <T>(fn: () => T, hook: string) => T;
@@ -1,23 +1,24 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Sean Larkin @thelarkinn
4
- */
5
1
  "use strict";
6
- const WebpackError = require("./WebpackError.js");
7
- // /** @typedef {import("./Module")} Module */
8
- /** @typedef {any} Module */
9
2
  /**
10
- * @template T
11
- * @callback Callback
12
- * @param {Error=} err
13
- * @param {T=} stats
14
- * @returns {void}
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/HookWebpackError.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
15
10
  */
16
- class HookWebpackError extends WebpackError {
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.tryRunOrWebpackError = exports.makeWebpackErrorCallback = exports.makeWebpackError = exports.HookWebpackError = void 0;
16
+ const WebpackError_1 = __importDefault(require("./WebpackError"));
17
+ class HookWebpackError extends WebpackError_1.default {
17
18
  /**
18
19
  * Creates an instance of HookWebpackError.
19
- * @param {Error} error inner error
20
- * @param {string} hook name of hook
20
+ * @param error inner error
21
+ * @param hook name of hook
21
22
  */
22
23
  constructor(error, hook) {
23
24
  super(error.message);
@@ -29,28 +30,28 @@ class HookWebpackError extends WebpackError {
29
30
  this.stack += `\n-- inner error --\n${error.stack}`;
30
31
  }
31
32
  }
32
- module.exports = HookWebpackError;
33
+ exports.HookWebpackError = HookWebpackError;
34
+ exports.default = HookWebpackError;
33
35
  /**
34
- * @param {Error} error an error
35
- * @param {string} hook name of the hook
36
- * @returns {WebpackError} a webpack error
36
+ * @param error an error
37
+ * @param hook name of the hook
38
+ * @returns a webpack error
37
39
  */
38
40
  const makeWebpackError = (error, hook) => {
39
- if (error instanceof WebpackError)
41
+ if (error instanceof WebpackError_1.default)
40
42
  return error;
41
43
  return new HookWebpackError(error, hook);
42
44
  };
43
- module.exports.makeWebpackError = makeWebpackError;
45
+ exports.makeWebpackError = makeWebpackError;
44
46
  /**
45
- * @template T
46
- * @param {function((WebpackError | null)=, T=): void} callback webpack error callback
47
- * @param {string} hook name of hook
48
- * @returns {Callback<T>} generic callback
47
+ * @param callback webpack error callback
48
+ * @param hook name of hook
49
+ * @returns generic callback
49
50
  */
50
51
  const makeWebpackErrorCallback = (callback, hook) => {
51
52
  return (err, result) => {
52
53
  if (err) {
53
- if (err instanceof WebpackError) {
54
+ if (err instanceof WebpackError_1.default) {
54
55
  callback(err);
55
56
  return;
56
57
  }
@@ -60,12 +61,11 @@ const makeWebpackErrorCallback = (callback, hook) => {
60
61
  callback(null, result);
61
62
  };
62
63
  };
63
- module.exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
64
+ exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
64
65
  /**
65
- * @template T
66
- * @param {function(): T} fn function which will be wrapping in try catch
67
- * @param {string} hook name of hook
68
- * @returns {T} the result
66
+ * @param fn function which will be wrapping in try catch
67
+ * @param hook name of hook
68
+ * @returns the result
69
69
  */
70
70
  const tryRunOrWebpackError = (fn, hook) => {
71
71
  let r;
@@ -73,12 +73,11 @@ const tryRunOrWebpackError = (fn, hook) => {
73
73
  r = fn();
74
74
  }
75
75
  catch (err) {
76
- if (err instanceof WebpackError) {
76
+ if (err instanceof WebpackError_1.default) {
77
77
  throw err;
78
78
  }
79
- // @ts-expect-error
80
79
  throw new HookWebpackError(err, hook);
81
80
  }
82
81
  return r;
83
82
  };
84
- module.exports.tryRunOrWebpackError = tryRunOrWebpackError;
83
+ exports.tryRunOrWebpackError = tryRunOrWebpackError;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/IgnoreWarningsPlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import type { Compiler, IgnoreWarningsNormalized, RspackPluginInstance } from "..";
11
+ declare class IgnoreWarningsPlugin implements RspackPluginInstance {
12
+ _ignorePattern: IgnoreWarningsNormalized;
13
+ name: string;
14
+ /**
15
+ * @param ignoreWarnings conditions to ignore warnings
16
+ */
17
+ constructor(ignorePattern: IgnoreWarningsNormalized);
18
+ /**
19
+ * Apply the plugin
20
+ * @param compiler the compiler instance
21
+ * @returns
22
+ */
23
+ apply(compiler: Compiler): void;
24
+ }
25
+ export default IgnoreWarningsPlugin;
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/IgnoreWarningsPlugin.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  class IgnoreWarningsPlugin {
13
+ /**
14
+ * @param ignoreWarnings conditions to ignore warnings
15
+ */
4
16
  constructor(ignorePattern) {
5
17
  this.name = "IgnoreWarningsPlugin";
6
18
  this._ignorePattern = ignorePattern;
7
19
  }
20
+ /**
21
+ * Apply the plugin
22
+ * @param compiler the compiler instance
23
+ * @returns
24
+ */
8
25
  apply(compiler) {
9
26
  compiler.hooks.compilation.tap(this.name, compilation => {
10
27
  compilation.hooks.processWarnings.tap(this.name, warnings => {
@@ -1,17 +1,26 @@
1
- export type Compiler = import("../Compiler").Compiler;
2
- export type LoaderOptionsPluginOptions = any;
3
- /** @typedef {import("../Compiler").Compiler} Compiler */
4
- /** @typedef {any} LoaderOptionsPluginOptions */
5
- export class LoaderOptionsPlugin {
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/LoaderOptionsPlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import type { Compiler } from "../Compiler";
11
+ import type { MatchObject } from "./ModuleFilenameHelpers";
12
+ type LoaderOptionsPluginOptions = any;
13
+ export declare class LoaderOptionsPlugin {
14
+ options: MatchObject;
6
15
  /**
7
- * @param {LoaderOptionsPluginOptions} options options object
16
+ * @param options options object
8
17
  */
9
18
  constructor(options?: LoaderOptionsPluginOptions);
10
- options: any;
11
19
  /**
12
20
  * Apply the plugin
13
- * @param {Compiler} compiler the compiler instance
14
- * @returns {void}
21
+ * @param compiler the compiler instance
22
+ * @returns
15
23
  */
16
24
  apply(compiler: Compiler): void;
17
25
  }
26
+ export {};
@@ -1,18 +1,43 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
1
  "use strict";
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/LoaderOptionsPlugin.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
6
34
  Object.defineProperty(exports, "__esModule", { value: true });
7
35
  exports.LoaderOptionsPlugin = void 0;
8
- const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
9
- const { NormalModule } = require("../NormalModule");
10
- // /** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */
11
- /** @typedef {import("../Compiler").Compiler} Compiler */
12
- /** @typedef {any} LoaderOptionsPluginOptions */
36
+ const NormalModule_1 = require("../NormalModule");
37
+ const ModuleFilenameHelpers = __importStar(require("./ModuleFilenameHelpers"));
13
38
  class LoaderOptionsPlugin {
14
39
  /**
15
- * @param {LoaderOptionsPluginOptions} options options object
40
+ * @param options options object
16
41
  */
17
42
  constructor(options = {}) {
18
43
  if (typeof options !== "object")
@@ -26,13 +51,13 @@ class LoaderOptionsPlugin {
26
51
  }
27
52
  /**
28
53
  * Apply the plugin
29
- * @param {Compiler} compiler the compiler instance
30
- * @returns {void}
54
+ * @param compiler the compiler instance
55
+ * @returns
31
56
  */
32
57
  apply(compiler) {
33
58
  const options = this.options;
34
59
  compiler.hooks.compilation.tap("LoaderOptionsPlugin", compilation => {
35
- NormalModule.getCompilationHooks(compilation).loader.tap("LoaderOptionsPlugin", context => {
60
+ NormalModule_1.NormalModule.getCompilationHooks(compilation).loader.tap("LoaderOptionsPlugin", context => {
36
61
  const resource = context.resourcePath;
37
62
  if (!resource)
38
63
  return;
@@ -41,7 +66,6 @@ class LoaderOptionsPlugin {
41
66
  if (key === "include" || key === "exclude" || key === "test") {
42
67
  continue;
43
68
  }
44
- // @ts-expect-error
45
69
  context[key] = options[key];
46
70
  }
47
71
  }
@@ -1,15 +1,24 @@
1
- export type Compiler = any;
2
- /** @typedef {any} Compiler */
3
- export class LoaderTargetPlugin {
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/LoaderTargetPlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import type { Compiler } from "../Compiler";
11
+ import type { Target } from "../config";
12
+ export declare class LoaderTargetPlugin {
13
+ readonly target: Target;
4
14
  /**
5
- * @param {string} target the target
15
+ * @param target the target
6
16
  */
7
- constructor(target: string);
8
- target: string;
17
+ constructor(target: Target);
9
18
  /**
10
19
  * Apply the plugin
11
- * @param {Compiler} compiler the compiler instance
12
- * @returns {void}
20
+ * @param compiler the compiler instance
21
+ * @returns
13
22
  */
14
23
  apply(compiler: Compiler): void;
15
24
  }
@@ -1,32 +1,34 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
1
  "use strict";
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/LoaderTargetPlugin.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
6
14
  Object.defineProperty(exports, "__esModule", { value: true });
7
15
  exports.LoaderTargetPlugin = void 0;
8
- const NormalModule = require("../NormalModule");
9
- // /** @typedef {import("./Compiler")} Compiler */
10
- /** @typedef {any} Compiler */
16
+ const NormalModule_1 = __importDefault(require("../NormalModule"));
11
17
  class LoaderTargetPlugin {
12
18
  /**
13
- * @param {string} target the target
19
+ * @param target the target
14
20
  */
15
21
  constructor(target) {
16
22
  this.target = target;
17
23
  }
18
24
  /**
19
25
  * Apply the plugin
20
- * @param {Compiler} compiler the compiler instance
21
- * @returns {void}
26
+ * @param compiler the compiler instance
27
+ * @returns
22
28
  */
23
29
  apply(compiler) {
24
- // @ts-expect-error
25
30
  compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => {
26
- // @ts-expect-error
27
- NormalModule.getCompilationHooks(compilation).loader.tap("LoaderTargetPlugin",
28
- // @ts-expect-error
29
- loaderContext => {
31
+ NormalModule_1.default.getCompilationHooks(compilation).loader.tap("LoaderTargetPlugin", loaderContext => {
30
32
  loaderContext.target = this.target;
31
33
  });
32
34
  });
@@ -1,3 +1,12 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/ModuleFilenameHelpers.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
1
10
  type Matcher = string | RegExp | (string | RegExp)[];
2
11
  /**
3
12
  * Returns a function that returns the string with the token replaced with the replacement
@@ -12,7 +21,7 @@ type Matcher = string | RegExp | (string | RegExp)[];
12
21
  */
13
22
  export declare const asRegExp: (test: string | RegExp) => RegExp;
14
23
  export declare const matchPart: (str: string, test: Matcher) => boolean;
15
- interface MatchObject {
24
+ export interface MatchObject {
16
25
  test?: Matcher;
17
26
  include?: Matcher;
18
27
  exclude?: Matcher;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/ModuleFilenameHelpers.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.matchObject = exports.matchPart = exports.asRegExp = void 0;
4
13
  /**
@@ -16,7 +25,7 @@ const asRegExp = (test) => {
16
25
  if (typeof test === "string") {
17
26
  // Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
18
27
  // adding a backslash before each special character
19
- return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
28
+ return new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`);
20
29
  }
21
30
  return test;
22
31
  };
@@ -1,7 +1,11 @@
1
1
  /**
2
- * Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
3
- * Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
4
- * Original Author Tobias Koppers @sokra
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/NormalModuleReplacementPlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
5
9
  */
6
10
  import type { Compiler } from "../Compiler";
7
11
  import type { ResolveData } from "../Module";
@@ -10,10 +14,16 @@ export declare class NormalModuleReplacementPlugin {
10
14
  readonly resourceRegExp: RegExp;
11
15
  readonly newResource: string | ModuleReplacer;
12
16
  /**
13
- * @param {RegExp} resourceRegExp the resource matcher
14
- * @param {string|ModuleReplacer} newResource the resource replacement
17
+ * Create an instance of the plugin
18
+ * @param resourceRegExp the resource matcher
19
+ * @param newResource the resource replacement
15
20
  */
16
21
  constructor(resourceRegExp: RegExp, newResource: string | ModuleReplacer);
22
+ /**
23
+ * Apply the plugin
24
+ * @param compiler the compiler instance
25
+ * @returns
26
+ */
17
27
  apply(compiler: Compiler): void;
18
28
  }
19
29
  export {};
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
- * Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
4
- * Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
5
- * Original Author Tobias Koppers @sokra
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/NormalModuleReplacementPlugin.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
6
10
  */
7
11
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
12
  if (k2 === undefined) k2 = k;
@@ -32,13 +36,19 @@ exports.NormalModuleReplacementPlugin = void 0;
32
36
  const NodePath = __importStar(require("node:path"));
33
37
  class NormalModuleReplacementPlugin {
34
38
  /**
35
- * @param {RegExp} resourceRegExp the resource matcher
36
- * @param {string|ModuleReplacer} newResource the resource replacement
39
+ * Create an instance of the plugin
40
+ * @param resourceRegExp the resource matcher
41
+ * @param newResource the resource replacement
37
42
  */
38
43
  constructor(resourceRegExp, newResource) {
39
44
  this.resourceRegExp = resourceRegExp;
40
45
  this.newResource = newResource;
41
46
  }
47
+ /**
48
+ * Apply the plugin
49
+ * @param compiler the compiler instance
50
+ * @returns
51
+ */
42
52
  apply(compiler) {
43
53
  const { resourceRegExp, newResource } = this;
44
54
  compiler.hooks.normalModuleFactory.tap("NormalModuleReplacementPlugin", nmf => {
@@ -1,23 +1,24 @@
1
- export = WebpackError;
2
- /** @typedef {any} Chunk */
3
- /** @typedef {any} DependencyLocation */
4
- /** @typedef {any} Module */
5
- declare class WebpackError extends Error {
6
- details: any;
7
- /** @type {Module} */
8
- module: Module;
9
- /** @type {DependencyLocation} */
10
- loc: DependencyLocation;
11
- /** @type {boolean} */
12
- hideStack: boolean;
13
- /** @type {Chunk} */
14
- chunk: Chunk;
15
- /** @type {string} */
16
- file: string;
17
- }
18
- declare namespace WebpackError {
19
- export { Chunk, DependencyLocation, Module };
20
- }
21
- type Module = any;
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/WebpackError.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ /// <reference types="node" />
11
+ import { inspect } from "node:util";
12
+ import type { Chunk } from "../Chunk";
13
+ import type { Module } from "../Module";
22
14
  type DependencyLocation = any;
23
- type Chunk = any;
15
+ export declare class WebpackError extends Error {
16
+ loc?: DependencyLocation;
17
+ file?: string;
18
+ chunk?: Chunk;
19
+ module?: Module;
20
+ details?: string;
21
+ hideStack?: boolean;
22
+ [inspect.custom](): string;
23
+ }
24
+ export default WebpackError;
@@ -1,40 +1,20 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Jarid Margolin @jaridmargolin
4
- */
5
1
  "use strict";
6
- const inspect = require("node:util").inspect.custom;
7
- // /** @typedef {import("./Chunk")} Chunk */
8
- // /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
9
- // /** @typedef {import("./Module")} Module */
10
- /** @typedef {any} Chunk */
11
- /** @typedef {any} DependencyLocation */
12
- /** @typedef {any} Module */
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/WebpackError.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WebpackError = void 0;
13
+ const node_util_1 = require("node:util");
13
14
  class WebpackError extends Error {
14
- /**
15
- * Creates an instance of WebpackError.
16
- * @param {string=} message error message
17
- */
18
- constructor(message) {
19
- super(message);
20
- // @ts-expect-error
21
- this.details = undefined;
22
- /** @type {Module} */
23
- this.module = undefined;
24
- /** @type {DependencyLocation} */
25
- this.loc = undefined;
26
- /** @type {boolean} */
27
- // @ts-expect-error
28
- this.hideStack = undefined;
29
- /** @type {Chunk} */
30
- this.chunk = undefined;
31
- /** @type {string} */
32
- // @ts-expect-error
33
- this.file = undefined;
34
- }
35
- [inspect]() {
15
+ [node_util_1.inspect.custom]() {
36
16
  return this.stack + (this.details ? `\n${this.details}` : "");
37
17
  }
38
18
  }
39
- // makeSerializable(WebpackError, "webpack/lib/WebpackError");
40
- module.exports = WebpackError;
19
+ exports.WebpackError = WebpackError;
20
+ exports.default = WebpackError;