@rspack/core 0.5.7-canary-9e2ce60-20240320055406 → 0.5.8-canary-6b6429d-20240321010409

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 (77) hide show
  1. package/dist/Chunk.d.ts +2 -0
  2. package/dist/Chunk.js +4 -0
  3. package/dist/Compilation.d.ts +16 -17
  4. package/dist/Compilation.js +10 -10
  5. package/dist/Compiler.js +57 -78
  6. package/dist/Module.d.ts +3 -0
  7. package/dist/Module.js +12 -0
  8. package/dist/Watching.d.ts +0 -1
  9. package/dist/Watching.js +0 -3
  10. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  11. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  12. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  13. package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
  14. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  15. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  17. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  18. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/ExternalsPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  43. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/base.d.ts +1 -1
  60. package/dist/builtin-plugin/base.js +1 -1
  61. package/dist/builtin-plugin/index.d.ts +0 -1
  62. package/dist/builtin-plugin/index.js +0 -1
  63. package/dist/config/normalization.d.ts +2 -2
  64. package/dist/config/normalization.js +1 -2
  65. package/dist/config/zod.d.ts +16 -109
  66. package/dist/config/zod.js +1 -8
  67. package/dist/exports.d.ts +13 -25
  68. package/dist/rspackOptionsApply.js +1 -12
  69. package/package.json +5 -5
  70. package/dist/builtin-plugin/lazy-compilation/backend.d.ts +0 -52
  71. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -143
  72. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +0 -30
  73. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  74. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +0 -13
  75. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  76. package/dist/util/normalization.d.ts +0 -5
  77. package/dist/util/normalization.js +0 -9
@@ -1,143 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- "use strict";
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.moduleImpl = exports.dispose = void 0;
8
- /**
9
- * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
10
- * @returns {BackendHandler} backend
11
- */
12
- const getBackend = (options) => (compiler, callback) => {
13
- const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
14
- const activeModules = new Map();
15
- const filesByKey = new Map();
16
- const prefix = "/lazy-compilation-using-";
17
- const isHttps = options.protocol === "https" ||
18
- (typeof options.server === "object" &&
19
- ("key" in options.server || "pfx" in options.server));
20
- const createServer = typeof options.server === "function"
21
- ? options.server
22
- : (() => {
23
- const http = isHttps ? require("https") : require("http");
24
- return http.createServer.bind(http, options.server);
25
- })();
26
- const listen = typeof options.listen === "function"
27
- ? options.listen
28
- : (server) => {
29
- let listen = options.listen;
30
- if (typeof listen === "object" && !("port" in listen))
31
- listen = { ...listen, port: undefined };
32
- server.listen(listen);
33
- };
34
- const protocol = options.protocol || (isHttps ? "https" : "http");
35
- const requestListener = (req, res) => {
36
- const keys = req.url.slice(prefix.length).split("@");
37
- req.socket.on("close", () => {
38
- setTimeout(() => {
39
- for (const key of keys) {
40
- const oldValue = activeModules.get(key) || 0;
41
- activeModules.set(key, oldValue - 1);
42
- if (oldValue === 1) {
43
- logger.log(`${key} is no longer in use. Next compilation will skip this module.`);
44
- }
45
- }
46
- }, 120000);
47
- });
48
- req.socket.setNoDelay(true);
49
- res.writeHead(200, {
50
- "content-type": "text/event-stream",
51
- "Access-Control-Allow-Origin": "*",
52
- "Access-Control-Allow-Methods": "*",
53
- "Access-Control-Allow-Headers": "*"
54
- });
55
- res.write("\n");
56
- const moduleActivated = [];
57
- for (const key of keys) {
58
- const oldValue = activeModules.get(key) || 0;
59
- activeModules.set(key, oldValue + 1);
60
- if (oldValue === 0) {
61
- logger.log(`${key} is now in use and will be compiled.`);
62
- moduleActivated.push(key);
63
- }
64
- }
65
- if (moduleActivated.length && compiler.watching) {
66
- compiler.watching.lazyCompilationInvalidate(new Set(moduleActivated.map(key => filesByKey.get(key))));
67
- }
68
- };
69
- const server = createServer();
70
- server.on("request", requestListener);
71
- let isClosing = false;
72
- const sockets = new Set();
73
- server.on("connection", socket => {
74
- sockets.add(socket);
75
- socket.on("close", () => {
76
- sockets.delete(socket);
77
- });
78
- if (isClosing)
79
- socket.destroy();
80
- });
81
- server.on("clientError", e => {
82
- if (e.message !== "Server is disposing")
83
- logger.warn(e);
84
- });
85
- server.on("listening", (err) => {
86
- if (err)
87
- return callback(err);
88
- const addr = server.address();
89
- if (typeof addr === "string")
90
- throw new Error("addr must not be a string");
91
- const urlBase = addr.address === "::" || addr.address === "0.0.0.0"
92
- ? `${protocol}://localhost:${addr.port}`
93
- : addr.family === "IPv6"
94
- ? `${protocol}://[${addr.address}]:${addr.port}`
95
- : `${protocol}://${addr.address}:${addr.port}`;
96
- logger.log(`Server-Sent-Events server for lazy compilation open at ${urlBase}.`);
97
- const result = {
98
- dispose(callback) {
99
- isClosing = true;
100
- // Removing the listener is a workaround for a memory leak in node.js
101
- server.off("request", requestListener);
102
- server.close(err => {
103
- callback(err);
104
- });
105
- for (const socket of sockets) {
106
- socket.destroy(new Error("Server is disposing"));
107
- }
108
- },
109
- module({ module: originalModule, path }) {
110
- const key = `${encodeURIComponent(originalModule.replace(/\\/g, "/").replace(/@/g, "_")).replace(/%(2F|3A|24|26|2B|2C|3B|3D|3A)/g, decodeURIComponent)}`;
111
- filesByKey.set(key, path);
112
- const active = activeModules.get(key) > 0;
113
- return {
114
- client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
115
- data: key,
116
- active
117
- };
118
- }
119
- };
120
- state.module = result.module;
121
- state.dispose = result.dispose;
122
- callback(null, result);
123
- });
124
- listen(server);
125
- };
126
- exports.default = getBackend;
127
- function unimplemented() {
128
- throw new Error("access before initialization");
129
- }
130
- const state = {
131
- module: unimplemented,
132
- dispose: unimplemented
133
- };
134
- function dispose(callback) {
135
- state.dispose(callback);
136
- state.dispose = unimplemented;
137
- state.module = unimplemented;
138
- }
139
- exports.dispose = dispose;
140
- function moduleImpl(args) {
141
- return state.module(args);
142
- }
143
- exports.moduleImpl = moduleImpl;
@@ -1,30 +0,0 @@
1
- import { BuiltinPluginName, RawRegexMatcher } from "@rspack/binding";
2
- export declare const BuiltinLazyCompilationPlugin: {
3
- new (module: (args: {
4
- module: string;
5
- path: string;
6
- }) => {
7
- active: boolean;
8
- data: string;
9
- client: string;
10
- }, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegexMatcher | undefined): {
11
- name: BuiltinPluginName;
12
- _options: {
13
- module: (args: {
14
- module: string;
15
- path: string;
16
- }) => {
17
- active: boolean;
18
- data: string;
19
- client: string;
20
- };
21
- cacheable: boolean;
22
- imports: boolean;
23
- entries: boolean;
24
- test: RawRegexMatcher | undefined;
25
- };
26
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
27
- raw(): import("@rspack/binding").BuiltinPlugin;
28
- apply(compiler: import("../../Compiler").Compiler): void;
29
- };
30
- };
@@ -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.LazyCompilation, (module, cacheable, entries, imports, test) => ({ module, cacheable, imports, entries, test }), "thisCompilation");
@@ -1,13 +0,0 @@
1
- import type { Compiler } from "../..";
2
- import { LazyCompilationDefaultBackendOptions } from "./backend";
3
- import { RawRegexMatcher } from "@rspack/binding";
4
- export default class LazyCompilationPlugin {
5
- cacheable: boolean;
6
- entries: boolean;
7
- imports: boolean;
8
- test?: RawRegexMatcher;
9
- backend?: LazyCompilationDefaultBackendOptions;
10
- constructor(cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegexMatcher, backend?: LazyCompilationDefaultBackendOptions);
11
- apply(compiler: Compiler): void;
12
- }
13
- export { LazyCompilationPlugin };
@@ -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 lazyCompilation_1 = require("./lazyCompilation");
28
- const backend_1 = __importStar(require("./backend"));
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;
@@ -1,5 +0,0 @@
1
- import type { JsModule } from "@rspack/binding";
2
- export interface NormalizedJsModule extends JsModule {
3
- identifier: () => string;
4
- }
5
- export declare function normalizeJsModule(m: JsModule): NormalizedJsModule;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeJsModule = void 0;
4
- function normalizeJsModule(m) {
5
- return Object.assign(m, {
6
- identifier: () => m.moduleIdentifier
7
- });
8
- }
9
- exports.normalizeJsModule = normalizeJsModule;