@rspack/core 0.5.7-canary-3320ea8-20240312032922 → 0.5.7-canary-dcd4782-20240312094134
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.
- package/dist/Watching.d.ts +1 -0
- package/dist/Watching.js +3 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/builtin-plugin/lazy-compilation/backend.d.ts +27 -0
- package/dist/builtin-plugin/lazy-compilation/backend.js +144 -0
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +30 -0
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +6 -0
- package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +10 -0
- package/dist/builtin-plugin/lazy-compilation/plugin.js +57 -0
- package/dist/config/normalization.d.ts +2 -2
- package/dist/config/normalization.js +2 -1
- package/dist/config/zod.d.ts +72 -10
- package/dist/config/zod.js +6 -1
- package/dist/exports.d.ts +12 -4
- package/dist/rspackOptionsApply.js +9 -0
- package/package.json +5 -5
package/dist/Watching.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare class Watching {
|
|
|
33
33
|
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>): void;
|
|
34
34
|
close(callback?: () => void): void;
|
|
35
35
|
invalidate(callback?: Callback<Error, void>): void;
|
|
36
|
+
lazyCompilationInvalidate(files: Set<string>): void;
|
|
36
37
|
/**
|
|
37
38
|
* The reason why this is _done instead of #done, is that in Webpack,
|
|
38
39
|
* it will rewrite this function to another function
|
package/dist/Watching.js
CHANGED
|
@@ -150,6 +150,9 @@ class Watching {
|
|
|
150
150
|
this.onChange();
|
|
151
151
|
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
152
152
|
}
|
|
153
|
+
lazyCompilationInvalidate(files) {
|
|
154
|
+
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, new Map(), new Map(), files, new Set());
|
|
155
|
+
}
|
|
153
156
|
_done(error, compilation) {
|
|
154
157
|
this.running = false;
|
|
155
158
|
let stats = undefined;
|
|
@@ -50,6 +50,7 @@ export * from "./HtmlRspackPlugin";
|
|
|
50
50
|
export * from "./CopyRspackPlugin";
|
|
51
51
|
export * from "./SwcJsMinimizerPlugin";
|
|
52
52
|
export * from "./SwcCssMinimizerPlugin";
|
|
53
|
+
export * from "./lazy-compilation/plugin";
|
|
53
54
|
import { RawBuiltins, RawCssModulesConfig } from "@rspack/binding";
|
|
54
55
|
import { RspackOptionsNormalized } from "..";
|
|
55
56
|
type BuiltinsCssConfig = {
|
|
@@ -68,6 +68,7 @@ __exportStar(require("./HtmlRspackPlugin"), exports);
|
|
|
68
68
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
69
69
|
__exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
70
70
|
__exportStar(require("./SwcCssMinimizerPlugin"), exports);
|
|
71
|
+
__exportStar(require("./lazy-compilation/plugin"), exports);
|
|
71
72
|
function resolveTreeShaking(treeShaking, production) {
|
|
72
73
|
return treeShaking !== undefined
|
|
73
74
|
? treeShaking.toString()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Compiler } from "../..";
|
|
3
|
+
/**
|
|
4
|
+
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
|
|
5
|
+
* @returns {BackendHandler} backend
|
|
6
|
+
*/
|
|
7
|
+
declare const getBackend: (options: any) => (compiler: Compiler, callback: (err: any, obj?: {
|
|
8
|
+
dispose: (callback: (err: any) => void) => void;
|
|
9
|
+
module: (args: {
|
|
10
|
+
module: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}) => {
|
|
13
|
+
data: string;
|
|
14
|
+
client: string;
|
|
15
|
+
active: boolean;
|
|
16
|
+
};
|
|
17
|
+
} | undefined) => void) => void;
|
|
18
|
+
export default getBackend;
|
|
19
|
+
export declare function dispose(callback: any): void;
|
|
20
|
+
export declare function moduleImpl(args: {
|
|
21
|
+
module: string;
|
|
22
|
+
path: string;
|
|
23
|
+
}): {
|
|
24
|
+
active: boolean;
|
|
25
|
+
data: string;
|
|
26
|
+
client: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
console.log("server shutdown");
|
|
104
|
+
callback(err);
|
|
105
|
+
});
|
|
106
|
+
for (const socket of sockets) {
|
|
107
|
+
socket.destroy(new Error("Server is disposing"));
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
module({ module: originalModule, path }) {
|
|
111
|
+
const key = `${encodeURIComponent(originalModule.replace(/\\/g, "/").replace(/@/g, "_")).replace(/%(2F|3A|24|26|2B|2C|3B|3D|3A)/g, decodeURIComponent)}`;
|
|
112
|
+
filesByKey.set(key, path);
|
|
113
|
+
const active = activeModules.get(key) > 0;
|
|
114
|
+
return {
|
|
115
|
+
client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
|
|
116
|
+
data: key,
|
|
117
|
+
active
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
state.module = result.module;
|
|
122
|
+
state.dispose = result.dispose;
|
|
123
|
+
callback(null, result);
|
|
124
|
+
});
|
|
125
|
+
listen(server);
|
|
126
|
+
};
|
|
127
|
+
exports.default = getBackend;
|
|
128
|
+
function unimplemented() {
|
|
129
|
+
throw new Error("access before initialization");
|
|
130
|
+
}
|
|
131
|
+
const state = {
|
|
132
|
+
module: unimplemented,
|
|
133
|
+
dispose: unimplemented
|
|
134
|
+
};
|
|
135
|
+
function dispose(callback) {
|
|
136
|
+
state.dispose(callback);
|
|
137
|
+
state.dispose = unimplemented;
|
|
138
|
+
state.module = unimplemented;
|
|
139
|
+
}
|
|
140
|
+
exports.dispose = dispose;
|
|
141
|
+
function moduleImpl(args) {
|
|
142
|
+
return state.module(args);
|
|
143
|
+
}
|
|
144
|
+
exports.moduleImpl = moduleImpl;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}, dispose: (callback: any) => void, 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
|
+
dispose: (callback: any) => void;
|
|
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
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
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, dispose, entries, imports, test) => ({ module, dispose, imports, entries, test }), "compilation");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Compiler } from "../..";
|
|
2
|
+
import { RawRegexMatcher } from "@rspack/binding";
|
|
3
|
+
export default class LazyCompilationPlugin {
|
|
4
|
+
entries: boolean;
|
|
5
|
+
imports: boolean;
|
|
6
|
+
test?: RawRegexMatcher;
|
|
7
|
+
constructor(entries: boolean, imports: boolean, test?: RawRegexMatcher);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
}
|
|
10
|
+
export { LazyCompilationPlugin };
|
|
@@ -0,0 +1,57 @@
|
|
|
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(entries, imports, test) {
|
|
31
|
+
this.entries = entries;
|
|
32
|
+
this.imports = imports;
|
|
33
|
+
this.test = test;
|
|
34
|
+
}
|
|
35
|
+
apply(compiler) {
|
|
36
|
+
const backend = (0, backend_1.default)({
|
|
37
|
+
client: require.resolve(`../../../hot/lazy-compilation-${compiler.options.externalsPresets.node ? "node" : "web"}.js`)
|
|
38
|
+
});
|
|
39
|
+
new lazyCompilation_1.BuiltinLazyCompilationPlugin(backend_1.moduleImpl, backend_1.dispose, this.entries, this.imports, this.test).apply(compiler);
|
|
40
|
+
let initialized = false;
|
|
41
|
+
compiler.hooks.beforeCompile.tapAsync("LazyCompilationPlugin", (_params, callback) => {
|
|
42
|
+
if (initialized)
|
|
43
|
+
return callback();
|
|
44
|
+
backend(compiler, (err, result) => {
|
|
45
|
+
if (err)
|
|
46
|
+
return callback(err);
|
|
47
|
+
initialized = true;
|
|
48
|
+
callback();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
compiler.hooks.shutdown.tapAsync("LazyCompilationPlugin", callback => {
|
|
52
|
+
(0, backend_1.dispose)(callback);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.default = LazyCompilationPlugin;
|
|
57
|
+
exports.LazyCompilationPlugin = LazyCompilationPlugin;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
10
|
import { Compilation } from "..";
|
|
11
|
-
import type { Context, Dependencies, Node, DevTool, Externals, ExternalsPresets, ExternalsType, InfrastructureLogging, LibraryOptions, Mode, Name, Resolve, RspackOptions, Target, SnapshotOptions, CacheOptions, StatsValue, Optimization, Plugins, Watch, WatchOptions, DevServer, Profile, Bail, Builtins, EntryRuntime, ChunkLoading, PublicPath, EntryFilename, Path, Clean, Filename, ChunkFilename, CrossOriginLoading, CssFilename, CssChunkFilename, HotUpdateMainFilename, HotUpdateChunkFilename, AssetModuleFilename, UniqueName, ChunkLoadingGlobal, EnabledLibraryTypes, OutputModule, StrictModuleErrorHandling, GlobalObject, ImportFunctionName, Iife, WasmLoading, EnabledWasmLoadingTypes, WebassemblyModuleFilename, TrustedTypes, SourceMapFilename, HashDigest, HashDigestLength, HashFunction, HashSalt, WorkerPublicPath, RuleSetRules, ParserOptionsByModuleType, GeneratorOptionsByModuleType, RspackFutureOptions, HotUpdateGlobal, ScriptType, NoParseOption, DevtoolNamespace, DevtoolModuleFilenameTemplate, DevtoolFallbackModuleFilenameTemplate } from "./zod";
|
|
11
|
+
import type { Context, Dependencies, Node, DevTool, Externals, ExternalsPresets, ExternalsType, InfrastructureLogging, LibraryOptions, Mode, Name, Resolve, RspackOptions, Target, SnapshotOptions, CacheOptions, StatsValue, Optimization, Plugins, Watch, WatchOptions, DevServer, Profile, Bail, Builtins, EntryRuntime, ChunkLoading, PublicPath, EntryFilename, Path, Clean, Filename, ChunkFilename, CrossOriginLoading, CssFilename, CssChunkFilename, HotUpdateMainFilename, HotUpdateChunkFilename, AssetModuleFilename, UniqueName, ChunkLoadingGlobal, EnabledLibraryTypes, OutputModule, StrictModuleErrorHandling, GlobalObject, ImportFunctionName, Iife, WasmLoading, EnabledWasmLoadingTypes, WebassemblyModuleFilename, TrustedTypes, SourceMapFilename, HashDigest, HashDigestLength, HashFunction, HashSalt, WorkerPublicPath, RuleSetRules, ParserOptionsByModuleType, GeneratorOptionsByModuleType, RspackFutureOptions, HotUpdateGlobal, ScriptType, NoParseOption, DevtoolNamespace, DevtoolModuleFilenameTemplate, DevtoolFallbackModuleFilenameTemplate, LazyCompilationOptions } from "./zod";
|
|
12
12
|
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
|
|
13
13
|
export type EntryNormalized = EntryStaticNormalized;
|
|
14
14
|
export interface EntryStaticNormalized {
|
|
@@ -75,7 +75,7 @@ export interface ModuleOptionsNormalized {
|
|
|
75
75
|
noParse?: NoParseOption;
|
|
76
76
|
}
|
|
77
77
|
export interface ExperimentsNormalized {
|
|
78
|
-
lazyCompilation?:
|
|
78
|
+
lazyCompilation?: false | LazyCompilationOptions;
|
|
79
79
|
asyncWebAssembly?: boolean;
|
|
80
80
|
outputModule?: boolean;
|
|
81
81
|
newSplitChunks?: boolean;
|
|
@@ -183,7 +183,8 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
183
183
|
}),
|
|
184
184
|
plugins: nestedArray(config.plugins, p => [...p]),
|
|
185
185
|
experiments: nestedConfig(config.experiments, experiments => ({
|
|
186
|
-
...experiments
|
|
186
|
+
...experiments,
|
|
187
|
+
lazyCompilation: optionalNestedConfig(experiments.lazyCompilation, options => (options === true ? {} : options))
|
|
187
188
|
})),
|
|
188
189
|
watch: config.watch,
|
|
189
190
|
watchOptions: cloneObject(config.watchOptions),
|
package/dist/config/zod.d.ts
CHANGED
|
@@ -3154,8 +3154,34 @@ declare const rspackFutureOptions: z.ZodObject<{
|
|
|
3154
3154
|
} | undefined;
|
|
3155
3155
|
}>;
|
|
3156
3156
|
export type RspackFutureOptions = z.infer<typeof rspackFutureOptions>;
|
|
3157
|
+
declare const lazyCompilationOptions: z.ZodObject<{
|
|
3158
|
+
imports: z.ZodOptional<z.ZodBoolean>;
|
|
3159
|
+
entries: z.ZodOptional<z.ZodBoolean>;
|
|
3160
|
+
test: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
3161
|
+
}, "strip", z.ZodTypeAny, {
|
|
3162
|
+
imports?: boolean | undefined;
|
|
3163
|
+
entries?: boolean | undefined;
|
|
3164
|
+
test?: RegExp | undefined;
|
|
3165
|
+
}, {
|
|
3166
|
+
imports?: boolean | undefined;
|
|
3167
|
+
entries?: boolean | undefined;
|
|
3168
|
+
test?: RegExp | undefined;
|
|
3169
|
+
}>;
|
|
3170
|
+
export type LazyCompilationOptions = z.infer<typeof lazyCompilationOptions>;
|
|
3157
3171
|
declare const experiments: z.ZodObject<{
|
|
3158
|
-
lazyCompilation: z.ZodOptional<z.ZodBoolean
|
|
3172
|
+
lazyCompilation: z.ZodUnion<[z.ZodOptional<z.ZodBoolean>, z.ZodObject<{
|
|
3173
|
+
imports: z.ZodOptional<z.ZodBoolean>;
|
|
3174
|
+
entries: z.ZodOptional<z.ZodBoolean>;
|
|
3175
|
+
test: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
3176
|
+
}, "strip", z.ZodTypeAny, {
|
|
3177
|
+
imports?: boolean | undefined;
|
|
3178
|
+
entries?: boolean | undefined;
|
|
3179
|
+
test?: RegExp | undefined;
|
|
3180
|
+
}, {
|
|
3181
|
+
imports?: boolean | undefined;
|
|
3182
|
+
entries?: boolean | undefined;
|
|
3183
|
+
test?: RegExp | undefined;
|
|
3184
|
+
}>]>;
|
|
3159
3185
|
asyncWebAssembly: z.ZodOptional<z.ZodBoolean>;
|
|
3160
3186
|
outputModule: z.ZodOptional<z.ZodBoolean>;
|
|
3161
3187
|
topLevelAwait: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3191,7 +3217,11 @@ declare const experiments: z.ZodObject<{
|
|
|
3191
3217
|
} | undefined;
|
|
3192
3218
|
}>>;
|
|
3193
3219
|
}, "strict", z.ZodTypeAny, {
|
|
3194
|
-
lazyCompilation?: boolean |
|
|
3220
|
+
lazyCompilation?: boolean | {
|
|
3221
|
+
imports?: boolean | undefined;
|
|
3222
|
+
entries?: boolean | undefined;
|
|
3223
|
+
test?: RegExp | undefined;
|
|
3224
|
+
} | undefined;
|
|
3195
3225
|
asyncWebAssembly?: boolean | undefined;
|
|
3196
3226
|
outputModule?: boolean | undefined;
|
|
3197
3227
|
topLevelAwait?: boolean | undefined;
|
|
@@ -3207,7 +3237,11 @@ declare const experiments: z.ZodObject<{
|
|
|
3207
3237
|
} | undefined;
|
|
3208
3238
|
} | undefined;
|
|
3209
3239
|
}, {
|
|
3210
|
-
lazyCompilation?: boolean |
|
|
3240
|
+
lazyCompilation?: boolean | {
|
|
3241
|
+
imports?: boolean | undefined;
|
|
3242
|
+
entries?: boolean | undefined;
|
|
3243
|
+
test?: RegExp | undefined;
|
|
3244
|
+
} | undefined;
|
|
3211
3245
|
asyncWebAssembly?: boolean | undefined;
|
|
3212
3246
|
outputModule?: boolean | undefined;
|
|
3213
3247
|
topLevelAwait?: boolean | undefined;
|
|
@@ -3689,7 +3723,19 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
3689
3723
|
target: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>, "many">]>>;
|
|
3690
3724
|
mode: z.ZodOptional<z.ZodEnum<["development", "production", "none"]>>;
|
|
3691
3725
|
experiments: z.ZodOptional<z.ZodObject<{
|
|
3692
|
-
lazyCompilation: z.ZodOptional<z.ZodBoolean
|
|
3726
|
+
lazyCompilation: z.ZodUnion<[z.ZodOptional<z.ZodBoolean>, z.ZodObject<{
|
|
3727
|
+
imports: z.ZodOptional<z.ZodBoolean>;
|
|
3728
|
+
entries: z.ZodOptional<z.ZodBoolean>;
|
|
3729
|
+
test: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
3730
|
+
}, "strip", z.ZodTypeAny, {
|
|
3731
|
+
imports?: boolean | undefined;
|
|
3732
|
+
entries?: boolean | undefined;
|
|
3733
|
+
test?: RegExp | undefined;
|
|
3734
|
+
}, {
|
|
3735
|
+
imports?: boolean | undefined;
|
|
3736
|
+
entries?: boolean | undefined;
|
|
3737
|
+
test?: RegExp | undefined;
|
|
3738
|
+
}>]>;
|
|
3693
3739
|
asyncWebAssembly: z.ZodOptional<z.ZodBoolean>;
|
|
3694
3740
|
outputModule: z.ZodOptional<z.ZodBoolean>;
|
|
3695
3741
|
topLevelAwait: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3725,7 +3771,11 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
3725
3771
|
} | undefined;
|
|
3726
3772
|
}>>;
|
|
3727
3773
|
}, "strict", z.ZodTypeAny, {
|
|
3728
|
-
lazyCompilation?: boolean |
|
|
3774
|
+
lazyCompilation?: boolean | {
|
|
3775
|
+
imports?: boolean | undefined;
|
|
3776
|
+
entries?: boolean | undefined;
|
|
3777
|
+
test?: RegExp | undefined;
|
|
3778
|
+
} | undefined;
|
|
3729
3779
|
asyncWebAssembly?: boolean | undefined;
|
|
3730
3780
|
outputModule?: boolean | undefined;
|
|
3731
3781
|
topLevelAwait?: boolean | undefined;
|
|
@@ -3741,7 +3791,11 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
3741
3791
|
} | undefined;
|
|
3742
3792
|
} | undefined;
|
|
3743
3793
|
}, {
|
|
3744
|
-
lazyCompilation?: boolean |
|
|
3794
|
+
lazyCompilation?: boolean | {
|
|
3795
|
+
imports?: boolean | undefined;
|
|
3796
|
+
entries?: boolean | undefined;
|
|
3797
|
+
test?: RegExp | undefined;
|
|
3798
|
+
} | undefined;
|
|
3745
3799
|
asyncWebAssembly?: boolean | undefined;
|
|
3746
3800
|
outputModule?: boolean | undefined;
|
|
3747
3801
|
topLevelAwait?: boolean | undefined;
|
|
@@ -4684,10 +4738,14 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
4684
4738
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
4685
4739
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
4686
4740
|
} | undefined;
|
|
4687
|
-
target?: false | "node" | "async-node" | "
|
|
4741
|
+
target?: false | "node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
4688
4742
|
mode?: "production" | "development" | "none" | undefined;
|
|
4689
4743
|
experiments?: {
|
|
4690
|
-
lazyCompilation?: boolean |
|
|
4744
|
+
lazyCompilation?: boolean | {
|
|
4745
|
+
imports?: boolean | undefined;
|
|
4746
|
+
entries?: boolean | undefined;
|
|
4747
|
+
test?: RegExp | undefined;
|
|
4748
|
+
} | undefined;
|
|
4691
4749
|
asyncWebAssembly?: boolean | undefined;
|
|
4692
4750
|
outputModule?: boolean | undefined;
|
|
4693
4751
|
topLevelAwait?: boolean | undefined;
|
|
@@ -5010,10 +5068,14 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
5010
5068
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
5011
5069
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
5012
5070
|
} | undefined;
|
|
5013
|
-
target?: false | "node" | "async-node" | "
|
|
5071
|
+
target?: false | "node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
5014
5072
|
mode?: "production" | "development" | "none" | undefined;
|
|
5015
5073
|
experiments?: {
|
|
5016
|
-
lazyCompilation?: boolean |
|
|
5074
|
+
lazyCompilation?: boolean | {
|
|
5075
|
+
imports?: boolean | undefined;
|
|
5076
|
+
entries?: boolean | undefined;
|
|
5077
|
+
test?: RegExp | undefined;
|
|
5078
|
+
} | undefined;
|
|
5017
5079
|
asyncWebAssembly?: boolean | undefined;
|
|
5018
5080
|
outputModule?: boolean | undefined;
|
|
5019
5081
|
topLevelAwait?: boolean | undefined;
|
package/dist/config/zod.js
CHANGED
|
@@ -690,8 +690,13 @@ const rspackFutureOptions = zod_1.z.strictObject({
|
|
|
690
690
|
})
|
|
691
691
|
.optional()
|
|
692
692
|
});
|
|
693
|
+
const lazyCompilationOptions = zod_1.z.object({
|
|
694
|
+
imports: zod_1.z.boolean().optional(),
|
|
695
|
+
entries: zod_1.z.boolean().optional(),
|
|
696
|
+
test: zod_1.z.instanceof(RegExp).optional()
|
|
697
|
+
});
|
|
693
698
|
const experiments = zod_1.z.strictObject({
|
|
694
|
-
lazyCompilation: zod_1.z.boolean().optional(),
|
|
699
|
+
lazyCompilation: zod_1.z.boolean().optional().or(lazyCompilationOptions),
|
|
695
700
|
asyncWebAssembly: zod_1.z.boolean().optional(),
|
|
696
701
|
outputModule: zod_1.z.boolean().optional(),
|
|
697
702
|
topLevelAwait: zod_1.z.boolean().optional(),
|
package/dist/exports.d.ts
CHANGED
|
@@ -128,10 +128,14 @@ export declare const config: {
|
|
|
128
128
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
129
129
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
130
130
|
} | undefined;
|
|
131
|
-
target?: false | "node" | "async-node" | "
|
|
131
|
+
target?: false | "node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
132
132
|
mode?: "production" | "development" | "none" | undefined;
|
|
133
133
|
experiments?: {
|
|
134
|
-
lazyCompilation?: boolean |
|
|
134
|
+
lazyCompilation?: boolean | {
|
|
135
|
+
imports?: boolean | undefined;
|
|
136
|
+
entries?: boolean | undefined;
|
|
137
|
+
test?: RegExp | undefined;
|
|
138
|
+
} | undefined;
|
|
135
139
|
asyncWebAssembly?: boolean | undefined;
|
|
136
140
|
outputModule?: boolean | undefined;
|
|
137
141
|
topLevelAwait?: boolean | undefined;
|
|
@@ -456,10 +460,14 @@ export declare const config: {
|
|
|
456
460
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
457
461
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
458
462
|
} | undefined;
|
|
459
|
-
target?: false | "node" | "async-node" | "
|
|
463
|
+
target?: false | "node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "es5" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
460
464
|
mode?: "production" | "development" | "none" | undefined;
|
|
461
465
|
experiments?: {
|
|
462
|
-
lazyCompilation?: boolean |
|
|
466
|
+
lazyCompilation?: boolean | {
|
|
467
|
+
imports?: boolean | undefined;
|
|
468
|
+
entries?: boolean | undefined;
|
|
469
|
+
test?: RegExp | undefined;
|
|
470
|
+
} | undefined;
|
|
463
471
|
asyncWebAssembly?: boolean | undefined;
|
|
464
472
|
outputModule?: boolean | undefined;
|
|
465
473
|
topLevelAwait?: boolean | undefined;
|
|
@@ -170,6 +170,15 @@ class RspackOptionsApply {
|
|
|
170
170
|
new builtin_plugin_1.MangleExportsPlugin(options.optimization.mangleExports !== "size").apply(compiler);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
+
if (options.experiments.lazyCompilation) {
|
|
174
|
+
const lazyOptions = options.experiments.lazyCompilation;
|
|
175
|
+
new builtin_plugin_1.LazyCompilationPlugin(lazyOptions.entries || true, lazyOptions.imports || true, lazyOptions.test
|
|
176
|
+
? {
|
|
177
|
+
source: lazyOptions.test.source,
|
|
178
|
+
flags: lazyOptions.test.flags
|
|
179
|
+
}
|
|
180
|
+
: undefined).apply(compiler);
|
|
181
|
+
}
|
|
173
182
|
if (options.output.enabledLibraryTypes &&
|
|
174
183
|
options.output.enabledLibraryTypes.length > 0) {
|
|
175
184
|
for (const type of options.output.enabledLibraryTypes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.5.7-canary-
|
|
3
|
+
"version": "0.5.7-canary-dcd4782-20240312094134",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"styled-components": "^6.0.8",
|
|
56
56
|
"terser": "5.27.2",
|
|
57
57
|
"wast-loader": "^1.11.4",
|
|
58
|
-
"@rspack/plugin-
|
|
59
|
-
"@rspack/core": "0.5.7-canary-
|
|
60
|
-
"@rspack/plugin-
|
|
58
|
+
"@rspack/plugin-minify": "^0.5.7-canary-dcd4782-20240312094134",
|
|
59
|
+
"@rspack/core": "0.5.7-canary-dcd4782-20240312094134",
|
|
60
|
+
"@rspack/plugin-node-polyfill": "^0.5.7-canary-dcd4782-20240312094134"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@module-federation/runtime-tools": "0.0.8",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"webpack-sources": "3.2.3",
|
|
73
73
|
"zod": "^3.21.4",
|
|
74
74
|
"zod-validation-error": "1.3.1",
|
|
75
|
-
"@rspack/binding": "0.5.7-canary-
|
|
75
|
+
"@rspack/binding": "0.5.7-canary-dcd4782-20240312094134"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@swc/helpers": ">=0.5.1"
|