@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,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RealContentHashPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.RealContentHashPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RealContentHashPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoveEmptyChunksPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.RemoveEmptyChunksPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RemoveEmptyChunksPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RuntimeChunkPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.RuntimeChunkPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RuntimeChunkPlugin, (options) => options, "thisCompilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RuntimePlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.RuntimePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RuntimePlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SideEffectsFlagPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.SideEffectsFlagPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SideEffectsFlagPlugin, () => { }, "compilation");
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SizeLimitsPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.SizeLimitsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SizeLimitsPlugin, (options) => {
7
- const hints = options.hints === false ? undefined : options.hints;
8
- return { ...options, hints };
9
- });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SourceMapDevToolPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const ModuleFilenameHelpers_1 = require("../lib/ModuleFilenameHelpers");
6
- const base_1 = require("./base");
7
- exports.SourceMapDevToolPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SourceMapDevToolPlugin, (options) => {
8
- const { test, include, exclude, ...rest } = options;
9
- const rawOptions = rest;
10
- if (test || include || exclude) {
11
- rawOptions.test = text => (0, ModuleFilenameHelpers_1.matchObject)({ test, include, exclude }, text);
12
- }
13
- return rawOptions;
14
- }, "compilation");
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SplitChunksPlugin = void 0;
7
- const node_assert_1 = __importDefault(require("node:assert"));
8
- const binding_1 = require("@rspack/binding");
9
- const Chunk_1 = require("../Chunk");
10
- const Module_1 = require("../Module");
11
- const SplitChunkSize_1 = require("../util/SplitChunkSize");
12
- const base_1 = require("./base");
13
- class SplitChunksPlugin extends base_1.RspackBuiltinPlugin {
14
- constructor(options) {
15
- super();
16
- this.options = options;
17
- this.name = binding_1.BuiltinPluginName.SplitChunksPlugin;
18
- this.affectedHooks = "thisCompilation";
19
- }
20
- raw(compiler) {
21
- const rawOptions = toRawSplitChunksOptions(this.options, compiler);
22
- (0, node_assert_1.default)(typeof rawOptions !== "undefined");
23
- return (0, base_1.createBuiltinPlugin)(this.name, rawOptions);
24
- }
25
- }
26
- exports.SplitChunksPlugin = SplitChunksPlugin;
27
- function toRawSplitChunksOptions(sc, compiler) {
28
- if (!sc) {
29
- return;
30
- }
31
- function getName(name) {
32
- if (typeof name === "function") {
33
- return (ctx) => {
34
- if (typeof ctx.module === "undefined") {
35
- return name(undefined);
36
- }
37
- return name(Module_1.Module.__from_binding(ctx.module, compiler._lastCompilation), getChunks(ctx.chunks), ctx.cacheGroupKey);
38
- };
39
- }
40
- return name;
41
- }
42
- function getTest(test) {
43
- if (typeof test === "function") {
44
- return (ctx) => {
45
- if (typeof ctx.module === "undefined") {
46
- return test(undefined);
47
- }
48
- return test(Module_1.Module.__from_binding(ctx.module, compiler._lastCompilation));
49
- };
50
- }
51
- return test;
52
- }
53
- function getChunks(chunks) {
54
- if (typeof chunks === "function") {
55
- return (chunk) => chunks(Chunk_1.Chunk.__from_binding(chunk, compiler._lastCompilation.__internal_getInner()));
56
- }
57
- return chunks;
58
- }
59
- const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
60
- return {
61
- name: getName(name),
62
- chunks: getChunks(chunks),
63
- defaultSizeTypes: defaultSizeTypes || ["javascript", "unknown"],
64
- cacheGroups: Object.entries(cacheGroups)
65
- .filter(([_key, group]) => group !== false)
66
- .map(([key, group]) => {
67
- group = group;
68
- const { test, name, chunks, minSize, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
69
- const rawGroup = {
70
- key,
71
- test: getTest(test),
72
- name: getName(name),
73
- chunks: getChunks(chunks),
74
- minSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(minSize),
75
- maxSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxSize),
76
- maxAsyncSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxAsyncSize),
77
- maxInitialSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxInitialSize),
78
- ...passThrough
79
- };
80
- return rawGroup;
81
- }),
82
- fallbackCacheGroup: {
83
- chunks: getChunks(chunks),
84
- ...fallbackCacheGroup
85
- },
86
- minSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(minSize),
87
- maxSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxSize),
88
- maxAsyncSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxAsyncSize),
89
- maxInitialSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxInitialSize),
90
- ...passThrough
91
- };
92
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwcJsMinimizerRspackPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- function isObject(value) {
7
- const type = typeof value;
8
- return value != null && (type === "object" || type === "function");
9
- }
10
- function getRawExtractCommentsOptions(extractComments) {
11
- const conditionStr = (condition) => {
12
- if (typeof condition === "undefined" || condition === true) {
13
- // copied from terser-webpack-plugin
14
- return "@preserve|@lic|@cc_on|^\\**!";
15
- }
16
- if (condition === false) {
17
- throw Error("unreachable");
18
- }
19
- // FIXME: flags
20
- return condition.source;
21
- };
22
- if (typeof extractComments === "boolean") {
23
- if (!extractComments) {
24
- return undefined;
25
- }
26
- const res = {
27
- condition: conditionStr(extractComments)
28
- };
29
- return res;
30
- }
31
- if (extractComments instanceof RegExp) {
32
- const res = {
33
- condition: extractComments.source
34
- };
35
- return res;
36
- }
37
- if (isObject(extractComments)) {
38
- if (extractComments.condition === false) {
39
- return undefined;
40
- }
41
- const res = {
42
- condition: conditionStr(extractComments.condition),
43
- banner: extractComments.banner
44
- };
45
- return res;
46
- }
47
- return undefined;
48
- }
49
- exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => {
50
- let compress = options?.minimizerOptions?.compress ?? true;
51
- const mangle = options?.minimizerOptions?.mangle ?? true;
52
- const format = {
53
- comments: false,
54
- ...options?.minimizerOptions?.format
55
- };
56
- if (compress && typeof compress === "object") {
57
- compress = {
58
- passes: 1,
59
- ...compress
60
- };
61
- }
62
- else if (compress) {
63
- compress = {
64
- passes: 1
65
- };
66
- }
67
- return {
68
- test: options?.test,
69
- include: options?.include,
70
- exclude: options?.exclude,
71
- extractComments: getRawExtractCommentsOptions(options?.extractComments),
72
- minimizerOptions: {
73
- compress,
74
- mangle,
75
- format,
76
- minify: options?.minimizerOptions?.minify,
77
- module: options?.minimizerOptions?.module
78
- }
79
- };
80
- }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WarnCaseSensitiveModulesPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.WarnCaseSensitiveModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.WarnCaseSensitiveModulesPlugin, () => { }, "compilation");
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebWorkerTemplatePlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("./base");
6
- exports.WebWorkerTemplatePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.WebWorkerTemplatePlugin, () => undefined);
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkerPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const EnableChunkLoadingPlugin_1 = require("./EnableChunkLoadingPlugin");
6
- const EnableWasmLoadingPlugin_1 = require("./EnableWasmLoadingPlugin");
7
- const base_1 = require("./base");
8
- class WorkerPlugin extends base_1.RspackBuiltinPlugin {
9
- constructor(chunkLoading, wasmLoading,
10
- // @ts-expect-error not implemented
11
- module,
12
- // @ts-expect-error not implemented
13
- workerPublicPath) {
14
- super();
15
- this.chunkLoading = chunkLoading;
16
- this.wasmLoading = wasmLoading;
17
- this.module = module;
18
- this.workerPublicPath = workerPublicPath;
19
- this.name = binding_1.BuiltinPluginName.WorkerPlugin;
20
- }
21
- raw(compiler) {
22
- if (this.chunkLoading) {
23
- new EnableChunkLoadingPlugin_1.EnableChunkLoadingPlugin(this.chunkLoading).apply(compiler);
24
- }
25
- if (this.wasmLoading) {
26
- new EnableWasmLoadingPlugin_1.EnableWasmLoadingPlugin(this.wasmLoading).apply(compiler);
27
- }
28
- return (0, base_1.createBuiltinPlugin)(this.name, undefined);
29
- }
30
- }
31
- exports.WorkerPlugin = WorkerPlugin;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = exports.createBuiltinPlugin = exports.RspackBuiltinPlugin = exports.canInherentFromParent = exports.HOOKS_CAN_NOT_INHERENT_FROM_PARENT = void 0;
4
- exports.HOOKS_CAN_NOT_INHERENT_FROM_PARENT = [
5
- "make",
6
- "compile",
7
- "emit",
8
- "afterEmit",
9
- "invalid",
10
- "done",
11
- "thisCompilation"
12
- ];
13
- function canInherentFromParent(affectedHooks) {
14
- if (typeof affectedHooks === "undefined") {
15
- // this arm should be removed
16
- return false;
17
- }
18
- return !exports.HOOKS_CAN_NOT_INHERENT_FROM_PARENT.includes(affectedHooks);
19
- }
20
- exports.canInherentFromParent = canInherentFromParent;
21
- class RspackBuiltinPlugin {
22
- apply(compiler) {
23
- const raw = this.raw(compiler);
24
- if (raw) {
25
- raw.canInherentFromParent = canInherentFromParent(this.affectedHooks);
26
- compiler.__internal__registerBuiltinPlugin(raw);
27
- }
28
- }
29
- }
30
- exports.RspackBuiltinPlugin = RspackBuiltinPlugin;
31
- function createBuiltinPlugin(name, options) {
32
- return {
33
- name: name,
34
- options: options ?? false // undefined or null will cause napi error, so false for fallback
35
- };
36
- }
37
- exports.createBuiltinPlugin = createBuiltinPlugin;
38
- function create(name, resolve,
39
- // `affectedHooks` is used to inform `createChildCompile` about which builtin plugin can be reserved.
40
- // However, this has a drawback as it doesn't represent the actual condition but merely serves as an indicator.
41
- affectedHooks) {
42
- class Plugin extends RspackBuiltinPlugin {
43
- constructor(...args) {
44
- super();
45
- this.name = name;
46
- this.affectedHooks = affectedHooks;
47
- this._args = args;
48
- }
49
- raw(compiler) {
50
- return createBuiltinPlugin(name, resolve.apply(compiler, this._args));
51
- }
52
- }
53
- // Make the plugin class name consistent with webpack
54
- // https://stackoverflow.com/a/46132163
55
- Object.defineProperty(Plugin, "name", { value: name });
56
- return Plugin;
57
- }
58
- exports.create = create;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cssReload = void 0;
4
- const normalizeUrl_1 = require("./normalizeUrl");
5
- const srcByModuleId = Object.create(null);
6
- const noDocument = typeof document === "undefined";
7
- const { forEach } = Array.prototype;
8
- function debounce(fn, time) {
9
- let timeout = 0;
10
- return function (...args) {
11
- const self = this;
12
- const functionCall = function functionCall() {
13
- return fn.apply(self, args);
14
- };
15
- clearTimeout(timeout);
16
- timeout = setTimeout(functionCall, time);
17
- };
18
- }
19
- function noop() { }
20
- function getCurrentScriptUrl(moduleId) {
21
- let src = srcByModuleId[moduleId];
22
- if (!src) {
23
- if (document.currentScript) {
24
- ({ src } = document.currentScript);
25
- }
26
- else {
27
- const scripts = document.getElementsByTagName("script");
28
- const lastScriptTag = scripts[scripts.length - 1];
29
- if (lastScriptTag) {
30
- ({ src } = lastScriptTag);
31
- }
32
- }
33
- srcByModuleId[moduleId] = src;
34
- }
35
- return (fileMap) => {
36
- if (!src) {
37
- return null;
38
- }
39
- const splitResult = src.match(/([^\\/]+)\.js$/);
40
- // biome-ignore lint/complexity/useOptionalChain: not use optionalChain to support legacy browser
41
- const filename = splitResult && splitResult[1];
42
- if (!filename || !fileMap) {
43
- return [src.replace(".js", ".css")];
44
- }
45
- return fileMap.split(",").map(mapRule => {
46
- const reg = new RegExp(`${filename}\\.js$`, "g");
47
- return (0, normalizeUrl_1.normalizeUrl)(src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`));
48
- });
49
- };
50
- }
51
- function updateCss(el, url) {
52
- let normalizedUrl;
53
- if (!url) {
54
- if (!el.href) {
55
- return;
56
- }
57
- normalizedUrl = el.href.split("?")[0];
58
- }
59
- else {
60
- normalizedUrl = url;
61
- }
62
- if (!isUrlRequest(normalizedUrl)) {
63
- return;
64
- }
65
- if (el.isLoaded === false) {
66
- // We seem to be about to replace a css link that hasn't loaded yet.
67
- // We're probably changing the same file more than once.
68
- return;
69
- }
70
- if (!normalizedUrl || !(normalizedUrl.indexOf(".css") > -1)) {
71
- return;
72
- }
73
- el.visited = true;
74
- const newEl = el.cloneNode();
75
- newEl.isLoaded = false;
76
- newEl.addEventListener("load", () => {
77
- if (newEl.isLoaded) {
78
- return;
79
- }
80
- newEl.isLoaded = true;
81
- if (el.parentNode) {
82
- el.parentNode.removeChild(el);
83
- }
84
- });
85
- newEl.addEventListener("error", () => {
86
- if (newEl.isLoaded) {
87
- return;
88
- }
89
- newEl.isLoaded = true;
90
- if (el.parentNode) {
91
- el.parentNode.removeChild(el);
92
- }
93
- });
94
- newEl.href = `${normalizedUrl}?${Date.now()}`;
95
- const parent = el.parentNode;
96
- if (!parent) {
97
- return;
98
- }
99
- if (el.nextSibling) {
100
- parent.insertBefore(newEl, el.nextSibling);
101
- }
102
- else {
103
- parent.appendChild(newEl);
104
- }
105
- }
106
- function getReloadUrl(href, src) {
107
- let ret = "";
108
- const normalizedHref = (0, normalizeUrl_1.normalizeUrl)(href);
109
- src.some(url => {
110
- if (normalizedHref.indexOf(src) > -1) {
111
- ret = url;
112
- }
113
- });
114
- return ret;
115
- }
116
- function reloadStyle(src) {
117
- if (!src) {
118
- return false;
119
- }
120
- const elements = document.querySelectorAll("link");
121
- let loaded = false;
122
- forEach.call(elements, el => {
123
- if (!el.href) {
124
- return;
125
- }
126
- const url = getReloadUrl(el.href, src);
127
- if (!isUrlRequest(url)) {
128
- return;
129
- }
130
- if (el.visited === true) {
131
- return;
132
- }
133
- if (url) {
134
- updateCss(el, url);
135
- loaded = true;
136
- }
137
- });
138
- return loaded;
139
- }
140
- function reloadAll() {
141
- const elements = document.querySelectorAll("link");
142
- forEach.call(elements, el => {
143
- if (el.visited === true) {
144
- return;
145
- }
146
- updateCss(el);
147
- });
148
- }
149
- function isUrlRequest(url) {
150
- // An URL is not an request if
151
- // It is not http or https
152
- if (!/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
153
- return false;
154
- }
155
- return true;
156
- }
157
- function cssReload(moduleId, options) {
158
- if (noDocument) {
159
- console.log("no window.document found, will not HMR CSS");
160
- return noop;
161
- }
162
- const getScriptSrc = getCurrentScriptUrl(moduleId);
163
- function update() {
164
- const src = getScriptSrc(options.filename);
165
- const reloaded = reloadStyle(src);
166
- if (options.locals) {
167
- console.log("[HMR] Detected local css modules. Reload all css");
168
- reloadAll();
169
- return;
170
- }
171
- if (reloaded) {
172
- // biome-ignore lint/complexity/useOptionalChain: not use optionalChain to support legacy browser
173
- console.log("[HMR] css reload %s", src && src.join(" "));
174
- }
175
- else {
176
- console.log("[HMR] Reload all css");
177
- reloadAll();
178
- }
179
- }
180
- return debounce(update, 50);
181
- }
182
- exports.cssReload = cssReload;
@@ -1,2 +0,0 @@
1
- declare function normalizeUrl(url: string): string;
2
- export { normalizeUrl };
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeUrl = void 0;
4
- function normalizeUrl(url) {
5
- const urlString = url.trim();
6
- if (/^data:/i.test(urlString)) {
7
- return urlString;
8
- }
9
- const protocol = urlString.indexOf("//") !== -1 ? `${urlString.split("//")[0]}//` : "";
10
- const components = urlString
11
- .replace(new RegExp(protocol, "i"), "")
12
- .split("/");
13
- const host = components[0].toLowerCase().replace(/\.$/, "");
14
- components[0] = "";
15
- const path = components
16
- .reduce((accumulator, item) => {
17
- switch (item) {
18
- case "..":
19
- accumulator.pop();
20
- break;
21
- case ".":
22
- break;
23
- default:
24
- accumulator.push(item);
25
- }
26
- return accumulator;
27
- }, [])
28
- .join("/");
29
- return protocol + host + path;
30
- }
31
- exports.normalizeUrl = normalizeUrl;
@@ -1,105 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.CssExtractRspackPlugin = void 0;
18
- const binding_1 = require("@rspack/binding");
19
- const loader_1 = require("./loader");
20
- __exportStar(require("./loader"), exports);
21
- const DEFAULT_FILENAME = "[name].css";
22
- const LOADER_PATH = require.resolve("./loader");
23
- class CssExtractRspackPlugin {
24
- constructor(options) {
25
- this.options = options || {};
26
- }
27
- apply(compiler) {
28
- const { splitChunks } = compiler.options.optimization;
29
- if (splitChunks) {
30
- if (
31
- /** @type {string[]} */ splitChunks.defaultSizeTypes.includes("...")) {
32
- /** @type {string[]} */
33
- splitChunks.defaultSizeTypes.push(loader_1.MODULE_TYPE);
34
- }
35
- }
36
- if (compiler.options.output.pathinfo &&
37
- this.options.pathinfo === undefined) {
38
- this.options.pathinfo = true;
39
- }
40
- compiler.__internal__registerBuiltinPlugin({
41
- name: binding_1.BuiltinPluginName.CssExtractRspackPlugin,
42
- options: this.normalizeOptions(this.options)
43
- });
44
- }
45
- normalizeOptions(options) {
46
- let chunkFilename = options.chunkFilename;
47
- if (!chunkFilename) {
48
- const filename = options.filename || DEFAULT_FILENAME;
49
- if (typeof filename !== "function") {
50
- const hasName = /** @type {string} */ filename.includes("[name]");
51
- const hasId = /** @type {string} */ filename.includes("[id]");
52
- const hasChunkHash =
53
- /** @type {string} */
54
- filename.includes("[chunkhash]");
55
- const hasContentHash =
56
- /** @type {string} */
57
- filename.includes("[contenthash]");
58
- // Anything changing depending on chunk is fine
59
- if (hasChunkHash || hasContentHash || hasName || hasId) {
60
- chunkFilename = filename;
61
- }
62
- else {
63
- // Otherwise prefix "[id]." in front of the basename to make it changing
64
- chunkFilename =
65
- /** @type {string} */
66
- filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
67
- }
68
- }
69
- else {
70
- chunkFilename = "[id].css";
71
- }
72
- }
73
- const normalzedOptions = {
74
- filename: options.filename || DEFAULT_FILENAME,
75
- chunkFilename: chunkFilename,
76
- ignoreOrder: options.ignoreOrder ?? false,
77
- runtime: options.runtime ?? true,
78
- insert: typeof options.insert === "function"
79
- ? options.insert.toString()
80
- : JSON.stringify(options.insert),
81
- linkType: typeof options.linkType === "undefined"
82
- ? JSON.stringify("text/css")
83
- : options.linkType === false
84
- ? undefined
85
- : JSON.stringify(options.linkType),
86
- attributes: options.attributes
87
- ? Reflect.ownKeys(options.attributes)
88
- .map(k => [
89
- JSON.stringify(k),
90
- JSON.stringify(options.attributes[k])
91
- ])
92
- .reduce((obj, [k, v]) => {
93
- obj[k] = v;
94
- return obj;
95
- }, {})
96
- : {},
97
- pathinfo: options.pathinfo ?? false
98
- };
99
- return normalzedOptions;
100
- }
101
- }
102
- CssExtractRspackPlugin.pluginName = "css-extract-rspack-plugin";
103
- CssExtractRspackPlugin.loader = LOADER_PATH;
104
- exports.CssExtractRspackPlugin = CssExtractRspackPlugin;
105
- exports.default = CssExtractRspackPlugin;