@rspack/core 1.0.0-beta.0 → 1.0.0-beta.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 (115) hide show
  1. package/dist/Compilation.d.ts +1 -1
  2. package/dist/Compiler.d.ts +11 -10
  3. package/dist/Compiler.js +14 -14
  4. package/dist/Module.d.ts +1 -0
  5. package/dist/Module.js +1 -0
  6. package/dist/NormalModule.d.ts +1 -0
  7. package/dist/NormalModule.js +1 -0
  8. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  9. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  10. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  11. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  12. package/dist/builtin-plugin/BannerPlugin.d.ts +31 -31
  13. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  14. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  15. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  17. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  18. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/EntryPlugin.d.ts +3 -2
  28. package/dist/builtin-plugin/EntryPlugin.js +1 -0
  29. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/ExternalsPlugin.d.ts +5 -5
  32. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  37. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -11
  43. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/base.d.ts +1 -1
  67. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  68. package/dist/builtin-plugin/css-extract/loader.js +24 -13
  69. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  70. package/dist/config/adapter.js +15 -2
  71. package/dist/config/adapterRuleUse.js +3 -3
  72. package/dist/config/defaults.js +7 -10
  73. package/dist/config/normalization.d.ts +6 -3
  74. package/dist/config/normalization.js +2 -0
  75. package/dist/config/zod.d.ts +1224 -1055
  76. package/dist/config/zod.js +10 -1
  77. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  78. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  79. package/dist/exports.d.ts +1 -1
  80. package/dist/lib/AbstractMethodError.d.ts +12 -3
  81. package/dist/lib/AbstractMethodError.js +29 -21
  82. package/dist/lib/Cache.d.ts +40 -46
  83. package/dist/lib/Cache.js +43 -78
  84. package/dist/lib/CacheFacade.d.ts +119 -143
  85. package/dist/lib/CacheFacade.js +123 -124
  86. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  87. package/dist/lib/EntryOptionPlugin.js +22 -6
  88. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  89. package/dist/lib/EnvironmentPlugin.js +16 -15
  90. package/dist/lib/HookWebpackError.d.ts +27 -33
  91. package/dist/lib/HookWebpackError.js +33 -34
  92. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  93. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  94. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  95. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  96. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  97. package/dist/lib/LoaderTargetPlugin.js +17 -15
  98. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  99. package/dist/lib/ModuleFilenameHelpers.js +9 -0
  100. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  101. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  102. package/dist/lib/WebpackError.d.ts +29 -22
  103. package/dist/lib/WebpackError.js +17 -29
  104. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  105. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  106. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  107. package/dist/lib/cache/mergeEtags.js +18 -11
  108. package/dist/lib/formatLocation.d.ts +13 -8
  109. package/dist/lib/formatLocation.js +17 -15
  110. package/dist/rspackOptionsApply.js +2 -2
  111. package/dist/stats/DefaultStatsFactoryPlugin.js +1 -1
  112. package/dist/util/comparators.d.ts +1 -1
  113. package/package.json +3 -3
  114. package/compiled/enhanced-resolve/index.js +0 -5566
  115. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -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
  /**
@@ -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,30 @@
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
+ /**
23
+ * Creates an instance of WebpackError.
24
+ * @param message error message
25
+ * @returns
26
+ */
27
+ constructor(message?: string);
28
+ [inspect.custom](): string;
29
+ }
30
+ export default WebpackError;
@@ -1,40 +1,28 @@
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
  /**
15
16
  * Creates an instance of WebpackError.
16
- * @param {string=} message error message
17
+ * @param message error message
18
+ * @returns
17
19
  */
18
20
  constructor(message) {
19
21
  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
22
  }
35
- [inspect]() {
23
+ [node_util_1.inspect.custom]() {
36
24
  return this.stack + (this.details ? `\n${this.details}` : "");
37
25
  }
38
26
  }
39
- // makeSerializable(WebpackError, "webpack/lib/WebpackError");
40
- module.exports = WebpackError;
27
+ exports.WebpackError = WebpackError;
28
+ exports.default = WebpackError;
@@ -1,35 +1,35 @@
1
- export = getter;
2
1
  /**
3
- * @param {HashableObject} obj object with updateHash method
4
- * @param {string | HashConstructor} hashFunction the hash function to use
5
- * @returns {LazyHashedEtag} etag
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/cache/getLazyHashedEtag.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
6
9
  */
7
- declare function getter(obj: HashableObject, hashFunction?: string | HashConstructor): LazyHashedEtag;
8
- declare namespace getter {
9
- export { Hash, HashConstructor, HashableObject };
10
+ import type Hash from "../../util/hash";
11
+ export type HashConstructor = typeof Hash;
12
+ export interface HashableObject {
13
+ updateHash(hash: Hash): void;
10
14
  }
11
- type HashableObject = {
12
- updateHash: (arg0: Hash) => void;
13
- };
14
- type HashConstructor = any;
15
- /** @typedef {any} Hash */
16
- /** @typedef {any} HashConstructor */
17
- /**
18
- * @typedef {Object} HashableObject
19
- * @property {function(Hash): void} updateHash
20
- */
21
15
  declare class LazyHashedEtag {
16
+ _obj: HashableObject;
17
+ _hash?: string;
18
+ _hashFunction: string | HashConstructor;
22
19
  /**
23
- * @param {HashableObject} obj object with updateHash method
24
- * @param {string | HashConstructor} hashFunction the hash function to use
20
+ * @param obj object with updateHash method
21
+ * @param hashFunction the hash function to use
25
22
  */
26
23
  constructor(obj: HashableObject, hashFunction?: string | HashConstructor);
27
- _obj: HashableObject;
28
- _hash: string | undefined;
29
- _hashFunction: any;
30
24
  /**
31
- * @returns {string} hash of object
25
+ * @returns hash of object
32
26
  */
33
27
  toString(): string;
34
28
  }
35
- type Hash = any;
29
+ /**
30
+ * @param obj object with updateHash method
31
+ * @param ashFunction the hash function to use
32
+ * @returns etag
33
+ */
34
+ export declare const getter: (obj: HashableObject, hashFunction?: string | HashConstructor) => LazyHashedEtag;
35
+ export default getter;