@rspack/core 1.0.9 → 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 (219) hide show
  1. package/dist/Dependency.d.ts +7 -6
  2. package/dist/Module.d.ts +19 -17
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +545 -0
  5. package/dist/config/zod.d.ts +202 -1347
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23347 -31
  9. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  10. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  11. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  12. package/package.json +8 -5
  13. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  14. package/compiled/json-parse-even-better-errors/index.js +0 -193
  15. package/compiled/json-parse-even-better-errors/package.json +0 -1
  16. package/compiled/neo-async/index.d.ts +0 -685
  17. package/compiled/neo-async/index.js +0 -9207
  18. package/compiled/neo-async/license +0 -22
  19. package/compiled/neo-async/package.json +0 -1
  20. package/compiled/zod-validation-error/index.d.ts +0 -41
  21. package/compiled/zod-validation-error/index.js +0 -335
  22. package/compiled/zod-validation-error/license +0 -9
  23. package/compiled/zod-validation-error/package.json +0 -1
  24. package/dist/Chunk.js +0 -118
  25. package/dist/ChunkGraph.js +0 -27
  26. package/dist/ChunkGroup.js +0 -76
  27. package/dist/Compilation.js +0 -854
  28. package/dist/Compiler.js +0 -920
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -32
  32. package/dist/Entrypoint.js +0 -21
  33. package/dist/ErrorHelpers.js +0 -62
  34. package/dist/ExecuteModulePlugin.js +0 -46
  35. package/dist/FileSystem.js +0 -34
  36. package/dist/FileSystemInfo.js +0 -2
  37. package/dist/Module.js +0 -143
  38. package/dist/ModuleTypeConstants.js +0 -92
  39. package/dist/MultiCompiler.js +0 -440
  40. package/dist/MultiStats.js +0 -161
  41. package/dist/MultiWatching.js +0 -62
  42. package/dist/NormalModule.js +0 -97
  43. package/dist/NormalModuleFactory.js +0 -43
  44. package/dist/Resolver.js +0 -39
  45. package/dist/ResolverFactory.js +0 -61
  46. package/dist/RspackError.js +0 -21
  47. package/dist/RuleSetCompiler.js +0 -10
  48. package/dist/RuntimeGlobals.js +0 -357
  49. package/dist/RuntimeModule.js +0 -58
  50. package/dist/Stats.js +0 -161
  51. package/dist/Template.js +0 -206
  52. package/dist/Watching.js +0 -290
  53. package/dist/builtin-loader/index.js +0 -17
  54. package/dist/builtin-loader/lightningcss/index.js +0 -175
  55. package/dist/builtin-loader/swc/index.js +0 -5
  56. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  57. package/dist/builtin-loader/swc/react.js +0 -7
  58. package/dist/builtin-loader/swc/types.js +0 -2
  59. package/dist/builtin-plugin/APIPlugin.js +0 -6
  60. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  61. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  62. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  63. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  64. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  65. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  66. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  67. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  68. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  69. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  70. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  71. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  72. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  73. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  74. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  75. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  76. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  78. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  79. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  80. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  81. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  82. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  83. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  84. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  85. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  86. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  87. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  88. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  89. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  90. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  91. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  92. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  93. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  94. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  95. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  96. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  97. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  98. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  99. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  100. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  101. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  102. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  106. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  107. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  108. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  109. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  110. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  111. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  112. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  113. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  114. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  115. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  116. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  117. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  118. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  119. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  120. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  121. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  122. package/dist/builtin-plugin/base.js +0 -58
  123. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  124. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  125. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  126. package/dist/builtin-plugin/css-extract/index.js +0 -105
  127. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  128. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  129. package/dist/builtin-plugin/index.js +0 -84
  130. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  131. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  132. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  133. package/dist/config/adapter.js +0 -691
  134. package/dist/config/adapterRuleUse.js +0 -107
  135. package/dist/config/browserslistTargetHandler.js +0 -345
  136. package/dist/config/defaults.js +0 -876
  137. package/dist/config/index.js +0 -20
  138. package/dist/config/normalization.js +0 -299
  139. package/dist/config/target.js +0 -318
  140. package/dist/config/types.js +0 -3
  141. package/dist/config/zod.js +0 -1028
  142. package/dist/container/ContainerPlugin.js +0 -50
  143. package/dist/container/ContainerReferencePlugin.js +0 -49
  144. package/dist/container/ModuleFederationPlugin.js +0 -137
  145. package/dist/container/ModuleFederationPluginV1.js +0 -63
  146. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  147. package/dist/container/options.js +0 -48
  148. package/dist/error/ConcurrentCompilationError.js +0 -20
  149. package/dist/exports.js +0 -183
  150. package/dist/lib/AbstractMethodError.js +0 -51
  151. package/dist/lib/Cache.js +0 -111
  152. package/dist/lib/CacheFacade.js +0 -321
  153. package/dist/lib/Dependency.js +0 -11
  154. package/dist/lib/EntryOptionPlugin.js +0 -89
  155. package/dist/lib/EnvironmentPlugin.js +0 -57
  156. package/dist/lib/HookWebpackError.js +0 -83
  157. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  158. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  159. package/dist/lib/LoaderTargetPlugin.js +0 -37
  160. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  161. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  162. package/dist/lib/WebpackError.js +0 -20
  163. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  164. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  165. package/dist/lib/cache/mergeEtags.js +0 -74
  166. package/dist/lib/formatLocation.js +0 -64
  167. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  168. package/dist/loader-runner/index.js +0 -735
  169. package/dist/loader-runner/loadLoader.js +0 -64
  170. package/dist/logging/Logger.js +0 -143
  171. package/dist/logging/createConsoleLogger.js +0 -176
  172. package/dist/logging/runtime.js +0 -37
  173. package/dist/logging/truncateArgs.js +0 -81
  174. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  175. package/dist/node/NodeTemplatePlugin.js +0 -26
  176. package/dist/node/NodeWatchFileSystem.js +0 -144
  177. package/dist/node/nodeConsole.js +0 -146
  178. package/dist/rspack.js +0 -123
  179. package/dist/rspackOptionsApply.js +0 -274
  180. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  181. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  182. package/dist/sharing/SharePlugin.js +0 -66
  183. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  184. package/dist/sharing/utils.js +0 -8
  185. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  186. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  187. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  188. package/dist/stats/StatsFactory.js +0 -167
  189. package/dist/stats/StatsPrinter.js +0 -142
  190. package/dist/stats/statsFactoryUtils.js +0 -341
  191. package/dist/util/ArrayQueue.js +0 -108
  192. package/dist/util/AssetInfo.js +0 -39
  193. package/dist/util/IterableHelpers.js +0 -35
  194. package/dist/util/MergeCaller.js +0 -24
  195. package/dist/util/SizeFormatHelpers.js +0 -24
  196. package/dist/util/SplitChunkSize.js +0 -18
  197. package/dist/util/assertNotNil.js +0 -9
  198. package/dist/util/assetCondition.js +0 -2
  199. package/dist/util/bindingVersionCheck.js +0 -124
  200. package/dist/util/cleverMerge.js +0 -504
  201. package/dist/util/comparators.js +0 -108
  202. package/dist/util/createHash.js +0 -161
  203. package/dist/util/createReadonlyMap.js +0 -29
  204. package/dist/util/fake.js +0 -28
  205. package/dist/util/fs.js +0 -120
  206. package/dist/util/hash/BatchedHash.js +0 -69
  207. package/dist/util/hash/index.js +0 -39
  208. package/dist/util/hash/md4.js +0 -27
  209. package/dist/util/hash/wasm-hash.js +0 -167
  210. package/dist/util/hash/xxhash64.js +0 -27
  211. package/dist/util/identifier.js +0 -330
  212. package/dist/util/index.js +0 -123
  213. package/dist/util/memoize.js +0 -61
  214. package/dist/util/scheme.js +0 -57
  215. package/dist/util/smartGrouping.js +0 -148
  216. package/dist/util/source.js +0 -42
  217. package/dist/util/validate.js +0 -77
  218. package/dist/util/webpack.js +0 -27
  219. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,204 +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.pitch = exports.hotLoader = exports.SINGLE_DOT_PATH_SEGMENT = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = exports.BASE_URI = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const index_1 = require("./index");
9
- const utils_1 = require("./utils");
10
- exports.BASE_URI = "webpack://";
11
- exports.MODULE_TYPE = "css/mini-extract";
12
- exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
13
- exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`;
14
- exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
15
- function hotLoader(content, context) {
16
- const localsJsonString = JSON.stringify(JSON.stringify(context.locals));
17
- return `${content}
18
- if(module.hot) {
19
- (function() {
20
- var localsJsonString = ${localsJsonString};
21
- // ${Date.now()}
22
- var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, node_path_1.default.join(__dirname, "hmr/hotModuleReplacement.js"))}).cssReload(module.id, ${JSON.stringify(context.options ?? {})});
23
- // only invalidate when locals change
24
- if (
25
- module.hot.data &&
26
- module.hot.data.value &&
27
- module.hot.data.value !== localsJsonString
28
- ) {
29
- module.hot.invalidate();
30
- } else {
31
- module.hot.accept();
32
- }
33
- module.hot.dispose(function(data) {
34
- data.value = localsJsonString;
35
- cssReload();
36
- });
37
- })();
38
- }
39
- `;
40
- }
41
- exports.hotLoader = hotLoader;
42
- const loader = function loader(content) {
43
- if (this._compiler?.options?.experiments?.css &&
44
- this._module &&
45
- (this._module.type === "css" ||
46
- this._module.type === "css/auto" ||
47
- this._module.type === "css/global" ||
48
- this._module.type === "css/module")) {
49
- return content;
50
- }
51
- };
52
- const pitch = function (request, _, data) {
53
- if (this._compiler?.options?.experiments?.css &&
54
- this._module &&
55
- (this._module.type === "css" ||
56
- this._module.type === "css/auto" ||
57
- this._module.type === "css/global" ||
58
- this._module.type === "css/module")) {
59
- const e = new Error(`use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`);
60
- e.stack = undefined;
61
- this.emitWarning(e);
62
- return;
63
- }
64
- const options = this.getOptions();
65
- const emit = typeof options.emit !== "undefined" ? options.emit : true;
66
- const callback = this.async();
67
- const filepath = this.resourcePath;
68
- const parseMeta = this.__internal__parseMeta;
69
- let { publicPath } = this._compilation.outputOptions;
70
- if (typeof options.publicPath === "string") {
71
- // eslint-disable-next-line prefer-destructuring
72
- publicPath = options.publicPath;
73
- }
74
- else if (typeof options.publicPath === "function") {
75
- publicPath = options.publicPath(this.resourcePath, this.rootContext);
76
- }
77
- if (publicPath === "auto") {
78
- publicPath = exports.AUTO_PUBLIC_PATH;
79
- }
80
- let publicPathForExtract;
81
- if (typeof publicPath === "string") {
82
- const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
83
- publicPathForExtract = isAbsolutePublicPath
84
- ? publicPath
85
- : `${exports.ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, exports.SINGLE_DOT_PATH_SEGMENT)}`;
86
- }
87
- else {
88
- publicPathForExtract = publicPath;
89
- }
90
- const handleExports = (originalExports) => {
91
- let locals;
92
- let namedExport;
93
- const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
94
- let dependencies = [];
95
- try {
96
- // eslint-disable-next-line no-underscore-dangle
97
- const exports = originalExports.__esModule
98
- ? originalExports.default
99
- : originalExports;
100
- namedExport =
101
- // eslint-disable-next-line no-underscore-dangle
102
- originalExports.__esModule &&
103
- (!originalExports.default || !("locals" in originalExports.default));
104
- if (namedExport) {
105
- for (const key of Object.keys(originalExports)) {
106
- if (key !== "default") {
107
- if (!locals) {
108
- locals = {};
109
- }
110
- locals[key] = originalExports[key];
111
- }
112
- }
113
- }
114
- else {
115
- locals = exports?.locals;
116
- }
117
- if (Array.isArray(exports) && emit) {
118
- const identifierCountMap = new Map();
119
- dependencies = exports
120
- .map(([id, content, media, sourceMap, supports, layer]) => {
121
- const identifier = id;
122
- const context = this.rootContext;
123
- const count = identifierCountMap.get(identifier) || 0;
124
- identifierCountMap.set(identifier, count + 1);
125
- return {
126
- identifier,
127
- context,
128
- content,
129
- media,
130
- supports,
131
- layer,
132
- identifierIndex: count,
133
- sourceMap: sourceMap
134
- ? JSON.stringify(sourceMap)
135
- : // eslint-disable-next-line no-undefined
136
- undefined,
137
- filepath
138
- };
139
- })
140
- .filter(item => item !== null);
141
- }
142
- }
143
- catch (e) {
144
- callback(e);
145
- return;
146
- }
147
- const result = (function makeResult() {
148
- if (locals) {
149
- if (namedExport) {
150
- const identifiers = Array.from((function* generateIdentifiers() {
151
- let identifierId = 0;
152
- for (const key of Object.keys(locals)) {
153
- identifierId += 1;
154
- yield [`_${identifierId.toString(16)}`, key];
155
- }
156
- })());
157
- const localsString = identifiers
158
- .map(([id, key]) => `\nvar ${id} = ${(0, utils_1.stringifyLocal)(locals[key])};`)
159
- .join("");
160
- const exportsString = `export { ${identifiers
161
- .map(([id, key]) => `${id} as ${JSON.stringify(key)}`)
162
- .join(", ")} }`;
163
- const defaultExport = typeof options.defaultExport !== "undefined"
164
- ? options.defaultExport
165
- : false;
166
- return defaultExport
167
- ? `${localsString}\n${exportsString}\nexport default { ${identifiers
168
- .map(([id, key]) => `${JSON.stringify(key)}: ${id}`)
169
- .join(", ")} }\n`
170
- : `${localsString}\n${exportsString}\n`;
171
- }
172
- return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
173
- }
174
- if (esModule) {
175
- return "\nexport {};";
176
- }
177
- return "";
178
- })();
179
- let resultSource = `// extracted by ${index_1.CssExtractRspackPlugin.pluginName}`;
180
- // only attempt hotreloading if the css is actually used for something other than hash values
181
- resultSource +=
182
- this.hot && emit
183
- ? hotLoader(result, { loaderContext: this, options, locals: locals })
184
- : result;
185
- if (dependencies.length > 0) {
186
- parseMeta[index_1.CssExtractRspackPlugin.pluginName] =
187
- JSON.stringify(dependencies);
188
- }
189
- callback(null, resultSource, undefined, data);
190
- };
191
- this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
192
- layer: options.layer,
193
- publicPath: publicPathForExtract,
194
- baseUri: `${exports.BASE_URI}/`
195
- }, (error, exports) => {
196
- if (error) {
197
- callback(error);
198
- return;
199
- }
200
- handleExports(exports);
201
- });
202
- };
203
- exports.pitch = pitch;
204
- exports.default = loader;
@@ -1,51 +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.stringifyLocal = exports.stringifyRequest = exports.isRelativePath = exports.isAbsolutePath = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- function isAbsolutePath(str) {
9
- return node_path_1.default.posix.isAbsolute(str) || node_path_1.default.win32.isAbsolute(str);
10
- }
11
- exports.isAbsolutePath = isAbsolutePath;
12
- const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
13
- function isRelativePath(str) {
14
- return RELATIVE_PATH_REGEXP.test(str);
15
- }
16
- exports.isRelativePath = isRelativePath;
17
- function stringifyRequest(loaderContext, request) {
18
- if (typeof loaderContext.utils !== "undefined" &&
19
- typeof loaderContext.utils.contextify === "function") {
20
- return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
21
- }
22
- const splitted = request.split("!");
23
- const { context } = loaderContext;
24
- return JSON.stringify(splitted
25
- .map(part => {
26
- // First, separate singlePath from query, because the query might contain paths again
27
- const splittedPart = part.match(/^(.*?)(\?.*)/);
28
- const query = splittedPart ? splittedPart[2] : "";
29
- let singlePath = splittedPart ? splittedPart[1] : part;
30
- if (isAbsolutePath(singlePath) && context) {
31
- singlePath = node_path_1.default.relative(context, singlePath);
32
- if (isAbsolutePath(singlePath)) {
33
- // If singlePath still matches an absolute path, singlePath was on a different drive than context.
34
- // In this case, we leave the path platform-specific without replacing any separators.
35
- // @see https://github.com/webpack/loader-utils/pull/14
36
- return singlePath + query;
37
- }
38
- if (isRelativePath(singlePath) === false) {
39
- // Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
40
- singlePath = `./${singlePath}`;
41
- }
42
- }
43
- return singlePath.replace(/\\/g, "/") + query;
44
- })
45
- .join("!"));
46
- }
47
- exports.stringifyRequest = stringifyRequest;
48
- function stringifyLocal(value) {
49
- return typeof value === "function" ? value.toString() : JSON.stringify(value);
50
- }
51
- exports.stringifyLocal = stringifyLocal;
@@ -1,84 +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.RspackBuiltinPlugin = void 0;
18
- var base_1 = require("./base");
19
- Object.defineProperty(exports, "RspackBuiltinPlugin", { enumerable: true, get: function () { return base_1.RspackBuiltinPlugin; } });
20
- __exportStar(require("./APIPlugin"), exports);
21
- __exportStar(require("./ArrayPushCallbackChunkFormatPlugin"), exports);
22
- __exportStar(require("./AssetModulesPlugin"), exports);
23
- __exportStar(require("./AsyncWebAssemblyModulesPlugin"), exports);
24
- __exportStar(require("./BannerPlugin"), exports);
25
- __exportStar(require("./BundlerInfoRspackPlugin"), exports);
26
- __exportStar(require("./ChunkPrefetchPreloadPlugin"), exports);
27
- __exportStar(require("./CommonJsChunkFormatPlugin"), exports);
28
- __exportStar(require("./CopyRspackPlugin"), exports);
29
- __exportStar(require("./css-extract"), exports);
30
- __exportStar(require("./CssModulesPlugin"), exports);
31
- __exportStar(require("./DataUriPlugin"), exports);
32
- __exportStar(require("./DefinePlugin"), exports);
33
- __exportStar(require("./DeterministicChunkIdsPlugin"), exports);
34
- __exportStar(require("./DeterministicModuleIdsPlugin"), exports);
35
- __exportStar(require("./DynamicEntryPlugin"), exports);
36
- __exportStar(require("./ElectronTargetPlugin"), exports);
37
- __exportStar(require("./EnableChunkLoadingPlugin"), exports);
38
- __exportStar(require("./EnableLibraryPlugin"), exports);
39
- __exportStar(require("./EnableWasmLoadingPlugin"), exports);
40
- __exportStar(require("./EnsureChunkConditionsPlugin"), exports);
41
- __exportStar(require("./EntryPlugin"), exports);
42
- __exportStar(require("./EvalDevToolModulePlugin"), exports);
43
- __exportStar(require("./EvalSourceMapDevToolPlugin"), exports);
44
- __exportStar(require("./ExternalsPlugin"), exports);
45
- __exportStar(require("./FileUriPlugin"), exports);
46
- __exportStar(require("./FlagDependencyExportsPlugin"), exports);
47
- __exportStar(require("./FlagDependencyUsagePlugin"), exports);
48
- __exportStar(require("./HotModuleReplacementPlugin"), exports);
49
- __exportStar(require("./HtmlRspackPlugin"), exports);
50
- __exportStar(require("./HttpExternalsRspackPlugin"), exports);
51
- __exportStar(require("./IgnorePlugin"), exports);
52
- __exportStar(require("./InferAsyncModulesPlugin"), exports);
53
- __exportStar(require("./JavascriptModulesPlugin"), exports);
54
- __exportStar(require("./JsLoaderRspackPlugin"), exports);
55
- __exportStar(require("./JsonModulesPlugin"), exports);
56
- __exportStar(require("./lazy-compilation/plugin"), exports);
57
- __exportStar(require("./LimitChunkCountPlugin"), exports);
58
- __exportStar(require("./MangleExportsPlugin"), exports);
59
- __exportStar(require("./MergeDuplicateChunksPlugin"), exports);
60
- __exportStar(require("./ModuleChunkFormatPlugin"), exports);
61
- __exportStar(require("./ModuleConcatenationPlugin"), exports);
62
- __exportStar(require("./NamedChunkIdsPlugin"), exports);
63
- __exportStar(require("./NamedModuleIdsPlugin"), exports);
64
- __exportStar(require("./NaturalChunkIdsPlugin"), exports);
65
- __exportStar(require("./NaturalModuleIdsPlugin"), exports);
66
- __exportStar(require("./NodeTargetPlugin"), exports);
67
- __exportStar(require("./ProgressPlugin"), exports);
68
- __exportStar(require("./ProvidePlugin"), exports);
69
- __exportStar(require("./RealContentHashPlugin"), exports);
70
- __exportStar(require("./RemoveEmptyChunksPlugin"), exports);
71
- __exportStar(require("./RuntimeChunkPlugin"), exports);
72
- __exportStar(require("./RuntimePlugin"), exports);
73
- __exportStar(require("./SideEffectsFlagPlugin"), exports);
74
- __exportStar(require("./SizeLimitsPlugin"), exports);
75
- __exportStar(require("./SourceMapDevToolPlugin"), exports);
76
- __exportStar(require("./SplitChunksPlugin"), exports);
77
- __exportStar(require("./LightningCssMiminizerRspackPlugin"), exports);
78
- __exportStar(require("./SwcJsMinimizerPlugin"), exports);
79
- __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
80
- __exportStar(require("./WebWorkerTemplatePlugin"), exports);
81
- __exportStar(require("./WorkerPlugin"), exports);
82
- __exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
83
- __exportStar(require("./NoEmitOnErrorsPlugin"), exports);
84
- __exportStar(require("./ContextReplacementPlugin"), exports);
@@ -1,139 +0,0 @@
1
- "use strict";
2
- /*
3
- * MIT License http://www.opensource.org/licenses/mit-license.php
4
- * Author Tobias Koppers @sokra
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.moduleImpl = exports.dispose = void 0;
8
- const getBackend = (options) => (compiler, callback) => {
9
- const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
10
- const activeModules = new Map();
11
- const filesByKey = new Map();
12
- const prefix = "/lazy-compilation-using-";
13
- const isHttps = options.protocol === "https" ||
14
- (typeof options.server === "object" &&
15
- ("key" in options.server || "pfx" in options.server));
16
- const createServer = typeof options.server === "function"
17
- ? options.server
18
- : (() => {
19
- const http = isHttps ? require("node:https") : require("node:http");
20
- return http.createServer.bind(http, options.server);
21
- })();
22
- const listen = typeof options.listen === "function"
23
- ? options.listen
24
- : (server) => {
25
- let listen = options.listen;
26
- if (typeof listen === "object" && !("port" in listen))
27
- listen = { ...listen, port: undefined };
28
- server.listen(listen);
29
- };
30
- const protocol = options.protocol || (isHttps ? "https" : "http");
31
- const requestListener = (req, res) => {
32
- const keys = req.url.slice(prefix.length).split("@");
33
- req.socket.on("close", () => {
34
- setTimeout(() => {
35
- for (const key of keys) {
36
- const oldValue = activeModules.get(key) || 0;
37
- activeModules.set(key, oldValue - 1);
38
- if (oldValue === 1) {
39
- logger.log(`${key} is no longer in use. Next compilation will skip this module.`);
40
- }
41
- }
42
- }, 120000);
43
- });
44
- req.socket.setNoDelay(true);
45
- res.writeHead(200, {
46
- "content-type": "text/event-stream",
47
- "Access-Control-Allow-Origin": "*",
48
- "Access-Control-Allow-Methods": "*",
49
- "Access-Control-Allow-Headers": "*"
50
- });
51
- res.write("\n");
52
- const moduleActivated = [];
53
- for (const key of keys) {
54
- const oldValue = activeModules.get(key) || 0;
55
- activeModules.set(key, oldValue + 1);
56
- if (oldValue === 0) {
57
- logger.log(`${key} is now in use and will be compiled.`);
58
- moduleActivated.push(key);
59
- }
60
- }
61
- if (moduleActivated.length && compiler.watching) {
62
- compiler.watching.lazyCompilationInvalidate(new Set(moduleActivated.map(key => filesByKey.get(key))));
63
- }
64
- };
65
- const server = createServer();
66
- server.on("request", requestListener);
67
- let isClosing = false;
68
- const sockets = new Set();
69
- server.on("connection", socket => {
70
- sockets.add(socket);
71
- socket.on("close", () => {
72
- sockets.delete(socket);
73
- });
74
- if (isClosing)
75
- socket.destroy();
76
- });
77
- server.on("clientError", e => {
78
- if (e.message !== "Server is disposing")
79
- logger.warn(e);
80
- });
81
- server.on("listening", (err) => {
82
- if (err)
83
- return callback(err);
84
- const addr = server.address();
85
- if (typeof addr === "string")
86
- throw new Error("addr must not be a string");
87
- const urlBase = addr.address === "::" || addr.address === "0.0.0.0"
88
- ? `${protocol}://localhost:${addr.port}`
89
- : addr.family === "IPv6"
90
- ? `${protocol}://[${addr.address}]:${addr.port}`
91
- : `${protocol}://${addr.address}:${addr.port}`;
92
- logger.log(`Server-Sent-Events server for lazy compilation open at ${urlBase}.`);
93
- const result = {
94
- dispose(callback) {
95
- isClosing = true;
96
- // Removing the listener is a workaround for a memory leak in node.js
97
- server.off("request", requestListener);
98
- server.close(err => {
99
- callback(err);
100
- });
101
- for (const socket of sockets) {
102
- socket.destroy(new Error("Server is disposing"));
103
- }
104
- },
105
- module({ module: originalModule, path }) {
106
- const key = `${encodeURIComponent(originalModule.replace(/\\/g, "/").replace(/@/g, "_")).replace(/%(2F|3A|24|26|2B|2C|3B|3D|3A)/g, decodeURIComponent)}`;
107
- filesByKey.set(key, path);
108
- const active = activeModules.get(key) > 0;
109
- return {
110
- client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
111
- data: key,
112
- active
113
- };
114
- }
115
- };
116
- state.module = result.module;
117
- state.dispose = result.dispose;
118
- callback(null, result);
119
- });
120
- listen(server);
121
- };
122
- exports.default = getBackend;
123
- function unimplemented() {
124
- throw new Error("access before initialization");
125
- }
126
- const state = {
127
- module: unimplemented,
128
- dispose: unimplemented
129
- };
130
- function dispose(callback) {
131
- state.dispose(callback);
132
- state.dispose = unimplemented;
133
- state.module = unimplemented;
134
- }
135
- exports.dispose = dispose;
136
- function moduleImpl(args) {
137
- return state.module(args);
138
- }
139
- exports.moduleImpl = moduleImpl;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuiltinLazyCompilationPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("../base");
6
- exports.BuiltinLazyCompilationPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LazyCompilationPlugin, (module, cacheable, entries, imports, test) => ({ module, cacheable, imports, entries, test }), "thisCompilation");
@@ -1,60 +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.LazyCompilationPlugin = void 0;
27
- const backend_1 = __importStar(require("./backend"));
28
- const lazyCompilation_1 = require("./lazyCompilation");
29
- class LazyCompilationPlugin {
30
- constructor(cacheable, entries, imports, test, backend) {
31
- this.cacheable = cacheable;
32
- this.entries = entries;
33
- this.imports = imports;
34
- this.test = test;
35
- this.backend = backend;
36
- }
37
- apply(compiler) {
38
- const backend = (0, backend_1.default)({
39
- ...this.backend,
40
- client: require.resolve(`../../../hot/lazy-compilation-${compiler.options.externalsPresets.node ? "node" : "web"}.js`)
41
- });
42
- new lazyCompilation_1.BuiltinLazyCompilationPlugin(backend_1.moduleImpl, this.cacheable, this.entries, this.imports, this.test).apply(compiler);
43
- let initialized = false;
44
- compiler.hooks.beforeCompile.tapAsync("LazyCompilationPlugin", (_params, callback) => {
45
- if (initialized)
46
- return callback();
47
- backend(compiler, (err, result) => {
48
- if (err)
49
- return callback(err);
50
- initialized = true;
51
- callback();
52
- });
53
- });
54
- compiler.hooks.shutdown.tapAsync("LazyCompilationPlugin", callback => {
55
- (0, backend_1.dispose)(callback);
56
- });
57
- }
58
- }
59
- exports.default = LazyCompilationPlugin;
60
- exports.LazyCompilationPlugin = LazyCompilationPlugin;