@rspack/core 1.0.10 → 1.0.11

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 (217) hide show
  1. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  2. package/dist/config/types.d.ts +309 -0
  3. package/dist/config/zod.d.ts +22 -534
  4. package/dist/cssExtractHmr.js +224 -0
  5. package/dist/cssExtractLoader.js +277 -0
  6. package/dist/index.js +23347 -31
  7. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  8. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  9. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  10. package/package.json +8 -5
  11. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  12. package/compiled/json-parse-even-better-errors/index.js +0 -193
  13. package/compiled/json-parse-even-better-errors/package.json +0 -1
  14. package/compiled/neo-async/index.d.ts +0 -685
  15. package/compiled/neo-async/index.js +0 -9207
  16. package/compiled/neo-async/license +0 -22
  17. package/compiled/neo-async/package.json +0 -1
  18. package/compiled/zod-validation-error/index.d.ts +0 -41
  19. package/compiled/zod-validation-error/index.js +0 -335
  20. package/compiled/zod-validation-error/license +0 -9
  21. package/compiled/zod-validation-error/package.json +0 -1
  22. package/dist/Chunk.js +0 -118
  23. package/dist/ChunkGraph.js +0 -27
  24. package/dist/ChunkGroup.js +0 -76
  25. package/dist/Compilation.js +0 -854
  26. package/dist/Compiler.js +0 -925
  27. package/dist/ContextModuleFactory.js +0 -36
  28. package/dist/DependenciesBlock.js +0 -30
  29. package/dist/Dependency.js +0 -43
  30. package/dist/Entrypoint.js +0 -21
  31. package/dist/ErrorHelpers.js +0 -62
  32. package/dist/ExecuteModulePlugin.js +0 -46
  33. package/dist/FileSystem.js +0 -34
  34. package/dist/FileSystemInfo.js +0 -2
  35. package/dist/Module.js +0 -226
  36. package/dist/ModuleTypeConstants.js +0 -92
  37. package/dist/MultiCompiler.js +0 -440
  38. package/dist/MultiStats.js +0 -161
  39. package/dist/MultiWatching.js +0 -62
  40. package/dist/NormalModule.js +0 -97
  41. package/dist/NormalModuleFactory.js +0 -43
  42. package/dist/Resolver.js +0 -39
  43. package/dist/ResolverFactory.js +0 -61
  44. package/dist/RspackError.js +0 -21
  45. package/dist/RuleSetCompiler.js +0 -10
  46. package/dist/RuntimeGlobals.js +0 -357
  47. package/dist/RuntimeModule.js +0 -58
  48. package/dist/Stats.js +0 -161
  49. package/dist/Template.js +0 -206
  50. package/dist/Watching.js +0 -290
  51. package/dist/builtin-loader/index.js +0 -17
  52. package/dist/builtin-loader/lightningcss/index.js +0 -175
  53. package/dist/builtin-loader/swc/index.js +0 -5
  54. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  55. package/dist/builtin-loader/swc/react.js +0 -7
  56. package/dist/builtin-loader/swc/types.js +0 -2
  57. package/dist/builtin-plugin/APIPlugin.js +0 -6
  58. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  59. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  60. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  61. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  62. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  63. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  64. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  65. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  66. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  67. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  68. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  69. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  70. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  71. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  72. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  73. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  74. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  75. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  76. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  78. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  79. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  80. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  81. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  82. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  83. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  84. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  85. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  86. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  87. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  88. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  89. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  90. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  91. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  92. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  93. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  94. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  95. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  96. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  97. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  98. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  99. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  100. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  101. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  102. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  106. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  107. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  108. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  109. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  110. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  111. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  112. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  113. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  114. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  115. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  116. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  117. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  118. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  119. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  120. package/dist/builtin-plugin/base.js +0 -58
  121. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  122. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  123. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  124. package/dist/builtin-plugin/css-extract/index.js +0 -105
  125. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  126. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  127. package/dist/builtin-plugin/index.js +0 -84
  128. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  129. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  130. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  131. package/dist/config/adapter.js +0 -691
  132. package/dist/config/adapterRuleUse.js +0 -107
  133. package/dist/config/browserslistTargetHandler.js +0 -345
  134. package/dist/config/defaults.js +0 -876
  135. package/dist/config/index.js +0 -20
  136. package/dist/config/normalization.js +0 -299
  137. package/dist/config/target.js +0 -318
  138. package/dist/config/types.js +0 -3
  139. package/dist/config/zod.js +0 -1030
  140. package/dist/container/ContainerPlugin.js +0 -50
  141. package/dist/container/ContainerReferencePlugin.js +0 -49
  142. package/dist/container/ModuleFederationPlugin.js +0 -137
  143. package/dist/container/ModuleFederationPluginV1.js +0 -63
  144. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  145. package/dist/container/options.js +0 -48
  146. package/dist/error/ConcurrentCompilationError.js +0 -20
  147. package/dist/exports.js +0 -183
  148. package/dist/lib/AbstractMethodError.js +0 -51
  149. package/dist/lib/Cache.js +0 -111
  150. package/dist/lib/CacheFacade.js +0 -321
  151. package/dist/lib/Dependency.js +0 -11
  152. package/dist/lib/EntryOptionPlugin.js +0 -89
  153. package/dist/lib/EnvironmentPlugin.js +0 -57
  154. package/dist/lib/HookWebpackError.js +0 -83
  155. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  156. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  157. package/dist/lib/LoaderTargetPlugin.js +0 -37
  158. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  159. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  160. package/dist/lib/WebpackError.js +0 -20
  161. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  162. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  163. package/dist/lib/cache/mergeEtags.js +0 -74
  164. package/dist/lib/formatLocation.js +0 -64
  165. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  166. package/dist/loader-runner/index.js +0 -735
  167. package/dist/loader-runner/loadLoader.js +0 -64
  168. package/dist/logging/Logger.js +0 -143
  169. package/dist/logging/createConsoleLogger.js +0 -176
  170. package/dist/logging/runtime.js +0 -37
  171. package/dist/logging/truncateArgs.js +0 -81
  172. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  173. package/dist/node/NodeTemplatePlugin.js +0 -26
  174. package/dist/node/NodeWatchFileSystem.js +0 -144
  175. package/dist/node/nodeConsole.js +0 -146
  176. package/dist/rspack.js +0 -123
  177. package/dist/rspackOptionsApply.js +0 -274
  178. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  179. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  180. package/dist/sharing/SharePlugin.js +0 -66
  181. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  182. package/dist/sharing/utils.js +0 -8
  183. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  184. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  185. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  186. package/dist/stats/StatsFactory.js +0 -167
  187. package/dist/stats/StatsPrinter.js +0 -142
  188. package/dist/stats/statsFactoryUtils.js +0 -341
  189. package/dist/util/ArrayQueue.js +0 -108
  190. package/dist/util/AssetInfo.js +0 -39
  191. package/dist/util/IterableHelpers.js +0 -35
  192. package/dist/util/MergeCaller.js +0 -24
  193. package/dist/util/SizeFormatHelpers.js +0 -24
  194. package/dist/util/SplitChunkSize.js +0 -18
  195. package/dist/util/assertNotNil.js +0 -9
  196. package/dist/util/assetCondition.js +0 -2
  197. package/dist/util/bindingVersionCheck.js +0 -124
  198. package/dist/util/cleverMerge.js +0 -504
  199. package/dist/util/comparators.js +0 -108
  200. package/dist/util/createHash.js +0 -161
  201. package/dist/util/createReadonlyMap.js +0 -29
  202. package/dist/util/fake.js +0 -28
  203. package/dist/util/fs.js +0 -120
  204. package/dist/util/hash/BatchedHash.js +0 -69
  205. package/dist/util/hash/index.js +0 -39
  206. package/dist/util/hash/md4.js +0 -27
  207. package/dist/util/hash/wasm-hash.js +0 -167
  208. package/dist/util/hash/xxhash64.js +0 -27
  209. package/dist/util/identifier.js +0 -330
  210. package/dist/util/index.js +0 -123
  211. package/dist/util/memoize.js +0 -61
  212. package/dist/util/scheme.js +0 -57
  213. package/dist/util/smartGrouping.js +0 -148
  214. package/dist/util/source.js +0 -42
  215. package/dist/util/validate.js +0 -77
  216. package/dist/util/webpack.js +0 -27
  217. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExternalsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.ExternalsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ExternalsPlugin, (type, externals) => {
7
- return {
8
- type,
9
- externals: (Array.isArray(externals) ? externals : [externals])
10
- .filter(Boolean)
11
- .map(getRawExternalItem)
12
- };
13
- });
14
- function getRawExternalItem(item) {
15
- if (typeof item === "string" || item instanceof RegExp) {
16
- return item;
17
- }
18
- if (typeof item === "function") {
19
- return async (ctx) => {
20
- return await new Promise((resolve, reject) => {
21
- const promise = item(ctx, (err, result, type) => {
22
- if (err)
23
- reject(err);
24
- resolve({
25
- result: getRawExternalItemValueFormFnResult(result),
26
- externalType: type
27
- });
28
- });
29
- if (promise?.then) {
30
- promise.then(result => resolve({
31
- result: getRawExternalItemValueFormFnResult(result),
32
- externalType: undefined
33
- }), e => reject(e));
34
- }
35
- });
36
- };
37
- }
38
- if (typeof item === "object") {
39
- return Object.fromEntries(Object.entries(item).map(([k, v]) => [k, getRawExternalItemValue(v)]));
40
- }
41
- throw new TypeError(`Unexpected type of external item: ${typeof item}`);
42
- }
43
- function getRawExternalItemValueFormFnResult(result) {
44
- return result === undefined ? result : getRawExternalItemValue(result);
45
- }
46
- function getRawExternalItemValue(value) {
47
- if (value && typeof value === "object" && !Array.isArray(value)) {
48
- return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, Array.isArray(v) ? v : [v]]));
49
- }
50
- return value;
51
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FetchCompileAsyncWasmPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.FetchCompileAsyncWasmPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.FetchCompileAsyncWasmPlugin, () => { }, "thisCompilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileUriPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.FileUriPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.FileUriPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlagDependencyExportsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.FlagDependencyExportsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.FlagDependencyExportsPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlagDependencyUsagePlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.FlagDependencyUsagePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.FlagDependencyUsagePlugin, (global) => global, "compilation");
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HotModuleReplacementPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- class HotModuleReplacementPlugin extends base_1.RspackBuiltinPlugin {
7
- constructor() {
8
- super(...arguments);
9
- this.name = binding_1.BuiltinPluginName.HotModuleReplacementPlugin;
10
- }
11
- raw(compiler) {
12
- if (compiler.options.output.strictModuleErrorHandling === undefined) {
13
- compiler.options.output.strictModuleErrorHandling = true;
14
- }
15
- return (0, base_1.createBuiltinPlugin)(this.name, undefined);
16
- }
17
- }
18
- exports.HotModuleReplacementPlugin = HotModuleReplacementPlugin;
@@ -1,285 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.HtmlRspackPlugin = void 0;
30
- const node_fs_1 = __importDefault(require("node:fs"));
31
- const node_path_1 = __importDefault(require("node:path"));
32
- const binding_1 = require("@rspack/binding");
33
- const liteTapable = __importStar(require("@rspack/lite-tapable"));
34
- const zod_1 = require("../../compiled/zod");
35
- const Compilation_1 = require("../Compilation");
36
- const validate_1 = require("../util/validate");
37
- const base_1 = require("./base");
38
- const templateRenderFunction = zod_1.z
39
- .function()
40
- .args(zod_1.z.record(zod_1.z.string(), zod_1.z.any()))
41
- .returns(zod_1.z.string().or(zod_1.z.promise(zod_1.z.string())));
42
- const templateParamFunction = zod_1.z
43
- .function()
44
- .args(zod_1.z.record(zod_1.z.string(), zod_1.z.any()))
45
- .returns(zod_1.z.record(zod_1.z.string(), zod_1.z.any()).or(zod_1.z.promise(zod_1.z.record(zod_1.z.string(), zod_1.z.any()))));
46
- const htmlRspackPluginOptions = zod_1.z.strictObject({
47
- filename: zod_1.z.string().optional(),
48
- template: zod_1.z
49
- .string()
50
- .refine(val => !val.includes("!"), () => ({
51
- message: "HtmlRspackPlugin does not support template path with loader yet"
52
- }))
53
- .optional(),
54
- templateContent: zod_1.z.string().or(templateRenderFunction).optional(),
55
- templateParameters: zod_1.z
56
- .record(zod_1.z.string())
57
- .or(zod_1.z.boolean())
58
- .or(templateParamFunction)
59
- .optional(),
60
- inject: zod_1.z.enum(["head", "body"]).or(zod_1.z.boolean()).optional(),
61
- publicPath: zod_1.z.string().optional(),
62
- base: zod_1.z
63
- .string()
64
- .or(zod_1.z.strictObject({
65
- href: zod_1.z.string().optional(),
66
- target: zod_1.z.enum(["_self", "_blank", "_parent", "_top"]).optional()
67
- }))
68
- .optional(),
69
- scriptLoading: zod_1.z
70
- .enum(["blocking", "defer", "module", "systemjs-module"])
71
- .optional(),
72
- chunks: zod_1.z.string().array().optional(),
73
- excludeChunks: zod_1.z.string().array().optional(),
74
- sri: zod_1.z.enum(["sha256", "sha384", "sha512"]).optional(),
75
- minify: zod_1.z.boolean().optional(),
76
- title: zod_1.z.string().optional(),
77
- favicon: zod_1.z.string().optional(),
78
- meta: zod_1.z.record(zod_1.z.string().or(zod_1.z.record(zod_1.z.string()))).optional(),
79
- hash: zod_1.z.boolean().optional()
80
- });
81
- const HtmlRspackPluginImpl = (0, base_1.create)(binding_1.BuiltinPluginName.HtmlRspackPlugin, function (c = {}) {
82
- (0, validate_1.validate)(c, htmlRspackPluginOptions);
83
- const meta = {};
84
- for (const key in c.meta) {
85
- const value = c.meta[key];
86
- if (typeof value === "string") {
87
- meta[key] = {
88
- name: key,
89
- content: value
90
- };
91
- }
92
- else {
93
- meta[key] = {
94
- name: key,
95
- ...value
96
- };
97
- }
98
- }
99
- const scriptLoading = c.scriptLoading ?? "defer";
100
- const configInject = c.inject ?? true;
101
- const inject = configInject === true
102
- ? scriptLoading === "blocking"
103
- ? "body"
104
- : "head"
105
- : configInject === false
106
- ? "false"
107
- : configInject;
108
- const base = typeof c.base === "string" ? { href: c.base } : c.base;
109
- let compilation = null;
110
- this.hooks.compilation.tap("HtmlRspackPlugin", compilationInstance => {
111
- compilation = compilationInstance;
112
- compilationOptionsMap.set(compilation, c);
113
- });
114
- this.hooks.done.tap("HtmlRspackPlugin", stats => {
115
- compilationHooksMap.delete(stats.compilation);
116
- compilationOptionsMap.delete(stats.compilation);
117
- });
118
- function generateRenderData(data) {
119
- const json = JSON.parse(data);
120
- if (typeof c.templateParameters !== "function") {
121
- json.compilation = compilation;
122
- }
123
- const renderTag = function () {
124
- return htmlTagObjectToString(this);
125
- };
126
- const renderTagList = function () {
127
- return this.join("");
128
- };
129
- if (Array.isArray(json.htmlRspackPlugin?.tags?.headTags)) {
130
- for (const tag of json.htmlRspackPlugin.tags.headTags) {
131
- tag.toString = renderTag;
132
- }
133
- json.htmlRspackPlugin.tags.headTags.toString = renderTagList;
134
- }
135
- if (Array.isArray(json.htmlRspackPlugin?.tags?.bodyTags)) {
136
- for (const tag of json.htmlRspackPlugin.tags.bodyTags) {
137
- tag.toString = renderTag;
138
- }
139
- json.htmlRspackPlugin.tags.bodyTags.toString = renderTagList;
140
- }
141
- return json;
142
- }
143
- let templateContent = c.templateContent;
144
- let templateFn = undefined;
145
- if (typeof templateContent === "function") {
146
- templateFn = async (data) => {
147
- try {
148
- const renderer = c.templateContent;
149
- if (c.templateParameters === false) {
150
- return await renderer({});
151
- }
152
- return await renderer(generateRenderData(data));
153
- }
154
- catch (e) {
155
- const error = new Error(`HtmlRspackPlugin: render template function failed, ${e.message}`);
156
- error.stack = e.stack;
157
- throw error;
158
- }
159
- };
160
- templateContent = "";
161
- }
162
- else if (c.template) {
163
- const filename = c.template.split("?")[0];
164
- if ([".js", ".cjs"].includes(node_path_1.default.extname(filename))) {
165
- templateFn = async (data) => {
166
- const context = this.options.context || process.cwd();
167
- const templateFilePath = node_path_1.default.resolve(context, filename);
168
- if (!node_fs_1.default.existsSync(templateFilePath)) {
169
- throw new Error(`HtmlRspackPlugin: could not load file \`${filename}\` from \`${context}\``);
170
- }
171
- try {
172
- const renderer = require(templateFilePath);
173
- if (c.templateParameters === false) {
174
- return await renderer({});
175
- }
176
- return await renderer(generateRenderData(data));
177
- }
178
- catch (e) {
179
- const error = new Error(`HtmlRspackPlugin: render template function failed, ${e.message}`);
180
- error.stack = e.stack;
181
- throw error;
182
- }
183
- };
184
- }
185
- }
186
- const rawTemplateParameters = c.templateParameters;
187
- let templateParameters;
188
- if (typeof rawTemplateParameters === "function") {
189
- templateParameters = async (data) => {
190
- const newData = await rawTemplateParameters(JSON.parse(data));
191
- return JSON.stringify(newData);
192
- };
193
- }
194
- else {
195
- templateParameters = rawTemplateParameters;
196
- }
197
- return {
198
- filename: c.filename,
199
- template: c.template,
200
- hash: c.hash,
201
- title: c.title,
202
- favicon: c.favicon,
203
- publicPath: c.publicPath,
204
- chunks: c.chunks,
205
- excludeChunks: c.excludeChunks,
206
- sri: c.sri,
207
- minify: c.minify,
208
- meta,
209
- scriptLoading,
210
- inject,
211
- base,
212
- templateFn,
213
- templateContent,
214
- templateParameters
215
- };
216
- });
217
- function htmlTagObjectToString(tag) {
218
- const attributes = Object.keys(tag.attributes || {})
219
- .filter(attributeName => tag.attributes[attributeName] === "" || tag.attributes[attributeName])
220
- .map(attributeName => {
221
- if (tag.attributes[attributeName] === "true") {
222
- return attributeName;
223
- }
224
- return `${attributeName}="${tag.attributes[attributeName]}"`;
225
- });
226
- const res = `<${[tag.tagName].concat(attributes).join(" ")}${tag.voidTag && !tag.innerHTML ? "/" : ""}>${tag.innerHTML || ""}${tag.voidTag && !tag.innerHTML ? "" : `</${tag.tagName}>`}`;
227
- return res;
228
- }
229
- const compilationHooksMap = new WeakMap();
230
- const compilationOptionsMap = new WeakMap();
231
- const HtmlRspackPlugin = HtmlRspackPluginImpl;
232
- exports.HtmlRspackPlugin = HtmlRspackPlugin;
233
- const voidTags = [
234
- "area",
235
- "base",
236
- "br",
237
- "col",
238
- "embed",
239
- "hr",
240
- "img",
241
- "input",
242
- "keygen",
243
- "link",
244
- "meta",
245
- "param",
246
- "source",
247
- "track",
248
- "wbr"
249
- ];
250
- HtmlRspackPlugin.createHtmlTagObject = (tagName, attributes, innerHTML) => {
251
- return {
252
- tagName,
253
- voidTag: voidTags.includes(tagName),
254
- attributes: attributes || {},
255
- innerHTML
256
- };
257
- };
258
- HtmlRspackPlugin.getCompilationOptions = (compilation) => {
259
- if (!(compilation instanceof Compilation_1.Compilation)) {
260
- throw new TypeError("The 'compilation' argument must be an instance of Compilation");
261
- }
262
- return compilationOptionsMap.get(compilation);
263
- };
264
- HtmlRspackPlugin.getCompilationHooks = (compilation) => {
265
- if (!(compilation instanceof Compilation_1.Compilation)) {
266
- throw new TypeError("The 'compilation' argument must be an instance of Compilation");
267
- }
268
- let hooks = compilationHooksMap.get(compilation);
269
- if (hooks === undefined) {
270
- hooks = {
271
- beforeAssetTagGeneration: new liteTapable.AsyncSeriesWaterfallHook([
272
- "data"
273
- ]),
274
- alterAssetTags: new liteTapable.AsyncSeriesWaterfallHook(["data"]),
275
- alterAssetTagGroups: new liteTapable.AsyncSeriesWaterfallHook(["data"]),
276
- afterTemplateExecution: new liteTapable.AsyncSeriesWaterfallHook([
277
- "data"
278
- ]),
279
- beforeEmit: new liteTapable.AsyncSeriesWaterfallHook(["data"]),
280
- afterEmit: new liteTapable.AsyncSeriesWaterfallHook(["data"])
281
- };
282
- compilationHooksMap.set(compilation, hooks);
283
- }
284
- return hooks;
285
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpExternalsRspackPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.HttpExternalsRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.HttpExternalsRspackPlugin, (css, webAsync) => {
7
- return {
8
- css,
9
- webAsync
10
- };
11
- });
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IgnorePlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const zod_1 = require("../../compiled/zod");
6
- const validate_1 = require("../util/validate");
7
- const base_1 = require("./base");
8
- const IgnorePluginOptions = zod_1.z.union([
9
- zod_1.z.object({
10
- contextRegExp: zod_1.z.instanceof(RegExp).optional(),
11
- resourceRegExp: zod_1.z.instanceof(RegExp)
12
- }),
13
- zod_1.z.object({
14
- checkResource: zod_1.z.function(zod_1.z.tuple([zod_1.z.string(), zod_1.z.string()]), zod_1.z.boolean())
15
- })
16
- ]);
17
- exports.IgnorePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.IgnorePlugin, (options) => {
18
- (0, validate_1.validate)(options, IgnorePluginOptions);
19
- return options;
20
- });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InferAsyncModulesPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.InferAsyncModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.InferAsyncModulesPlugin, () => { }, "compilation");
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.JavascriptModulesPlugin = void 0;
27
- const binding_1 = require("@rspack/binding");
28
- const liteTapable = __importStar(require("@rspack/lite-tapable"));
29
- const Compilation_1 = require("../Compilation");
30
- const base_1 = require("./base");
31
- const compilationHooksMap = new WeakMap();
32
- class JavascriptModulesPlugin extends base_1.RspackBuiltinPlugin {
33
- constructor() {
34
- super(...arguments);
35
- this.name = binding_1.BuiltinPluginName.JavascriptModulesPlugin;
36
- this.affectedHooks = "compilation";
37
- }
38
- raw() {
39
- return (0, base_1.createBuiltinPlugin)(this.name, undefined);
40
- }
41
- static getCompilationHooks(compilation) {
42
- if (!(compilation instanceof Compilation_1.Compilation)) {
43
- throw new TypeError("The 'compilation' argument must be an instance of Compilation");
44
- }
45
- let hooks = compilationHooksMap.get(compilation);
46
- if (hooks === undefined) {
47
- hooks = {
48
- chunkHash: new liteTapable.SyncHook(["chunk", "hash"])
49
- };
50
- compilationHooksMap.set(compilation, hooks);
51
- }
52
- return hooks;
53
- }
54
- }
55
- exports.JavascriptModulesPlugin = JavascriptModulesPlugin;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsLoaderRspackPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const loader_runner_1 = require("../loader-runner");
6
- const base_1 = require("./base");
7
- exports.JsLoaderRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JsLoaderRspackPlugin, (compiler) => loader_runner_1.runLoaders.bind(null, compiler),
8
- /* Not Inheretable */
9
- "thisCompilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonModulesPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.JsonModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JsonModulesPlugin, () => { }, "compilation");
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LightningCssMinimizerRspackPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const lightningcss_1 = require("../builtin-loader/lightningcss");
6
- const base_1 = require("./base");
7
- exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LightningCssMinimizerRspackPlugin, (options) => {
8
- const { include, exclude, draft, nonStandard, pseudoClasses } = options?.minimizerOptions ?? {};
9
- const targets = options?.minimizerOptions?.targets ?? "fully supports es6"; // last not support es module chrome version
10
- return {
11
- test: options?.test,
12
- include: options?.include,
13
- exclude: options?.exclude,
14
- removeUnusedLocalIdents: options?.removeUnusedLocalIdents ?? true,
15
- minimizerOptions: {
16
- errorRecovery: options?.minimizerOptions?.errorRecovery ?? true,
17
- unusedSymbols: options?.minimizerOptions?.unusedSymbols ?? [],
18
- include: include ? (0, lightningcss_1.toFeatures)(include) : undefined,
19
- exclude: exclude ? (0, lightningcss_1.toFeatures)(exclude) : undefined,
20
- targets: typeof targets === "string" ? [targets] : targets,
21
- draft: draft ? { customMedia: draft.customMedia ?? false } : undefined,
22
- nonStandard: nonStandard
23
- ? {
24
- deepSelectorCombinator: nonStandard.deepSelectorCombinator ?? false
25
- }
26
- : undefined,
27
- pseudoClasses
28
- }
29
- };
30
- });
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LimitChunkCountPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.LimitChunkCountPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LimitChunkCountPlugin, (options) => {
7
- return options;
8
- });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MangleExportsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.MangleExportsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.MangleExportsPlugin, (deterministic) => deterministic, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MergeDuplicateChunksPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.MergeDuplicateChunksPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.MergeDuplicateChunksPlugin, () => { });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModuleChunkFormatPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.ModuleChunkFormatPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ModuleChunkFormatPlugin, () => { });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModuleConcatenationPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.ModuleConcatenationPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ModuleConcatenationPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NamedChunkIdsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NamedChunkIdsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NamedChunkIdsPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NamedModuleIdsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NamedModuleIdsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NamedModuleIdsPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NaturalChunkIdsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NaturalChunkIdsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NaturalChunkIdsPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NaturalModuleIdsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NaturalModuleIdsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NaturalModuleIdsPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoEmitOnErrorsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NoEmitOnErrorsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NoEmitOnErrorsPlugin, () => undefined);
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeTargetPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.NodeTargetPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NodeTargetPlugin, () => undefined);
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProgressPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) => {
7
- if (typeof progress === "function") {
8
- return {
9
- handler: (percentage, msg, items) => {
10
- progress(percentage, msg, ...items);
11
- }
12
- };
13
- }
14
- return progress;
15
- });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProvidePlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.ProvidePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProvidePlugin, (provide) => {
7
- const entries = Object.entries(provide).map(([key, value]) => {
8
- if (typeof value === "string") {
9
- value = [value];
10
- }
11
- return [key, value];
12
- });
13
- return Object.fromEntries(entries);
14
- });