@rspack/core 0.6.5-canary-5042eed-20240515115707 → 0.6.5-canary-b7b5c75-20240821125908
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/Chunk.d.ts +1 -1
- package/dist/Chunk.js +1 -1
- package/dist/ChunkGroup.d.ts +1 -1
- package/dist/ChunkGroup.js +3 -3
- package/dist/Compilation.d.ts +65 -46
- package/dist/Compilation.js +222 -128
- package/dist/Compiler.d.ts +44 -75
- package/dist/Compiler.js +260 -301
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/Entrypoint.js +1 -1
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/Module.js +2 -2
- package/dist/MultiCompiler.d.ts +25 -10
- package/dist/MultiCompiler.js +3 -3
- package/dist/MultiStats.d.ts +1 -1
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/Stats.d.ts +2 -2
- package/dist/Watching.d.ts +9 -1
- package/dist/Watching.js +2 -15
- package/dist/builtin-loader/swc/index.d.ts +6 -6
- package/dist/builtin-loader/swc/index.js +3 -3
- package/dist/builtin-loader/swc/types.d.ts +2 -2
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/BannerPlugin.js +1 -1
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.js +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.js +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.js +2 -2
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
- package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
- package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/builtin-plugin/base.js +1 -1
- package/dist/builtin-plugin/css-extract/index.d.ts +4 -5
- package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/loader.js +2 -2
- package/dist/builtin-plugin/index.d.ts +43 -44
- package/dist/builtin-plugin/index.js +43 -44
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/adapter.js +5 -6
- package/dist/config/adapterRuleUse.d.ts +1 -2
- package/dist/config/adapterRuleUse.js +2 -2
- package/dist/config/defaults.js +4 -6
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/normalization.d.ts +3 -2
- package/dist/config/normalization.js +1 -2
- package/dist/config/zod.d.ts +192 -328
- package/dist/config/zod.js +29 -17
- package/dist/container/ContainerPlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.js +1 -1
- package/dist/container/ModuleFederationPlugin.js +1 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
- package/dist/container/ModuleFederationPluginV1.js +1 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/exports.d.ts +30 -32
- package/dist/exports.js +17 -15
- package/dist/fileSystem.d.ts +8 -12
- package/dist/fileSystem.js +48 -25
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/loader-runner/index.js +13 -13
- package/dist/logging/Logger.d.ts +1 -1
- package/dist/logging/createConsoleLogger.js +14 -0
- package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/nodeConsole.js +4 -0
- package/dist/rspack.d.ts +13 -4
- package/dist/rspack.js +8 -8
- package/dist/rspackOptionsApply.d.ts +10 -1
- package/dist/rspackOptionsApply.js +6 -34
- package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
- package/dist/sharing/ConsumeSharedPlugin.js +1 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/dist/stats/StatsFactory.d.ts +2 -2
- package/dist/stats/StatsFactory.js +9 -0
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/stats/statsFactoryUtils.d.ts +1 -1
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/createSource.d.ts +5 -0
- package/dist/util/createSource.js +65 -0
- package/dist/util/fs.d.ts +0 -64
- package/dist/util/fs.js +0 -122
- package/dist/util/index.d.ts +1 -2
- package/dist/util/index.js +11 -16
- package/package.json +4 -4
- package/dist/builtin-plugin/lazy-compilation/backend.d.ts +0 -50
- package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +0 -30
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
- package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +0 -13
- package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
- package/dist/util/source.d.ts +0 -18
- package/dist/util/source.js +0 -66
package/dist/util/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.deprecatedWarn = exports.toJsAssetInfo = exports.asArray = exports.stringifyLoaderObject = exports.indent = exports.concatErrorMsgAndStack = exports.isJsStatsError = exports.isPromiseLike = exports.serializeObject = exports.toObject = exports.toBuffer = exports.isNil = exports.mapValues = void 0;
|
|
4
4
|
function mapValues(record, fn) {
|
|
5
5
|
return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, fn(value)]));
|
|
6
6
|
}
|
|
@@ -60,13 +60,16 @@ function isJsStatsError(err) {
|
|
|
60
60
|
}
|
|
61
61
|
exports.isJsStatsError = isJsStatsError;
|
|
62
62
|
function concatErrorMsgAndStack(err) {
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
// deduplicate the error if message is already shown in the stack
|
|
64
|
+
//@ts-ignore
|
|
65
|
+
const stackStartPrefix = err.name ? `${err.name}: ` : "Error: ";
|
|
66
|
+
return isJsStatsError(err)
|
|
67
|
+
? err.formatted
|
|
68
|
+
: err.stack
|
|
69
|
+
? err.stack.startsWith(`${stackStartPrefix}${err.message}`)
|
|
70
|
+
? `${err.stack}`
|
|
71
|
+
: `${err.message}\n${err.stack}`
|
|
72
|
+
: `${err.message}`;
|
|
70
73
|
}
|
|
71
74
|
exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
|
|
72
75
|
function indent(str, prefix) {
|
|
@@ -113,11 +116,3 @@ const deprecatedWarn = (content, enable = getDeprecationStatus()) => {
|
|
|
113
116
|
}
|
|
114
117
|
};
|
|
115
118
|
exports.deprecatedWarn = deprecatedWarn;
|
|
116
|
-
const unsupported = (name, issue) => {
|
|
117
|
-
let s = `${name} is not supported by rspack.`;
|
|
118
|
-
if (issue) {
|
|
119
|
-
s += ` Please refer to issue ${issue} for more information.`;
|
|
120
|
-
}
|
|
121
|
-
throw new Error(s);
|
|
122
|
-
};
|
|
123
|
-
exports.unsupported = unsupported;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.6.5-canary-
|
|
3
|
+
"version": "0.6.5-canary-b7b5c75-20240821125908",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"watchpack": "^2.4.0",
|
|
72
72
|
"zod": "^3.21.4",
|
|
73
73
|
"zod-validation-error": "1.3.1",
|
|
74
|
-
"@rspack/plugin-minify": "^0.6.5-canary-
|
|
75
|
-
"@rspack/core": "0.6.5-canary-
|
|
74
|
+
"@rspack/plugin-minify": "^0.6.5-canary-b7b5c75-20240821125908",
|
|
75
|
+
"@rspack/core": "0.6.5-canary-b7b5c75-20240821125908"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@module-federation/runtime-tools": "0.1.6",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"enhanced-resolve": "5.12.0",
|
|
81
81
|
"tapable": "2.2.1",
|
|
82
82
|
"webpack-sources": "3.2.3",
|
|
83
|
-
"@rspack/binding": "0.6.5-canary-
|
|
83
|
+
"@rspack/binding": "0.6.5-canary-b7b5c75-20240821125908"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@swc/helpers": ">=0.5.1"
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
import type { IncomingMessage, ServerResponse, ServerOptions as ServerOptionsImport } from "http";
|
|
6
|
-
import type { ListenOptions, Server } from "net";
|
|
7
|
-
import type { Compiler } from "../..";
|
|
8
|
-
import type { SecureContextOptions, TlsOptions } from "tls";
|
|
9
|
-
export interface LazyCompilationDefaultBackendOptions {
|
|
10
|
-
/**
|
|
11
|
-
* A custom client.
|
|
12
|
-
*/
|
|
13
|
-
client?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Specifies where to listen to from the server.
|
|
16
|
-
*/
|
|
17
|
-
listen?: number | ListenOptions | ((server: Server) => void);
|
|
18
|
-
/**
|
|
19
|
-
* Specifies the protocol the client should use to connect to the server.
|
|
20
|
-
*/
|
|
21
|
-
protocol?: "http" | "https";
|
|
22
|
-
/**
|
|
23
|
-
* Specifies how to create the server handling the EventSource requests.
|
|
24
|
-
*/
|
|
25
|
-
server?: ServerOptionsImport<typeof IncomingMessage> | ServerOptionsHttps<typeof IncomingMessage, typeof ServerResponse> | (() => Server);
|
|
26
|
-
}
|
|
27
|
-
export type ServerOptionsHttps<Request extends typeof IncomingMessage = typeof IncomingMessage, Response extends typeof ServerResponse = typeof ServerResponse> = SecureContextOptions & TlsOptions & ServerOptionsImport<Request, Response>;
|
|
28
|
-
declare const getBackend: (options: Omit<LazyCompilationDefaultBackendOptions, "client"> & {
|
|
29
|
-
client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>;
|
|
30
|
-
}) => (compiler: Compiler, callback: (err: any, obj?: {
|
|
31
|
-
dispose: (callback: (err: any) => void) => void;
|
|
32
|
-
module: (args: {
|
|
33
|
-
module: string;
|
|
34
|
-
path: string;
|
|
35
|
-
}) => {
|
|
36
|
-
data: string;
|
|
37
|
-
client: string;
|
|
38
|
-
active: boolean;
|
|
39
|
-
};
|
|
40
|
-
} | undefined) => void) => void;
|
|
41
|
-
export default getBackend;
|
|
42
|
-
export declare function dispose(callback: any): void;
|
|
43
|
-
export declare function moduleImpl(args: {
|
|
44
|
-
module: string;
|
|
45
|
-
path: string;
|
|
46
|
-
}): {
|
|
47
|
-
active: boolean;
|
|
48
|
-
data: string;
|
|
49
|
-
client: string;
|
|
50
|
-
};
|
|
@@ -1,139 +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
|
-
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("https") : require("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,30 +0,0 @@
|
|
|
1
|
-
import { BuiltinPluginName, JsModule, 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 | ((m: JsModule) => boolean) | 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 | ((m: JsModule) => boolean) | undefined;
|
|
25
|
-
};
|
|
26
|
-
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "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.LazyCompilationPlugin, (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 { JsModule, RawRegexMatcher } from "@rspack/binding";
|
|
4
|
-
export default class LazyCompilationPlugin {
|
|
5
|
-
cacheable: boolean;
|
|
6
|
-
entries: boolean;
|
|
7
|
-
imports: boolean;
|
|
8
|
-
test?: RawRegexMatcher | ((m: JsModule) => boolean);
|
|
9
|
-
backend?: LazyCompilationDefaultBackendOptions;
|
|
10
|
-
constructor(cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegexMatcher | ((m: JsModule) => boolean), 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;
|
package/dist/util/source.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { JsCompatSource } from "@rspack/binding";
|
|
3
|
-
import { Source } from "webpack-sources";
|
|
4
|
-
declare class JsSource extends Source {
|
|
5
|
-
static __from_binding(source: JsCompatSource): Source;
|
|
6
|
-
static __to_binding(source: Source): {
|
|
7
|
-
source: Buffer;
|
|
8
|
-
isRaw: boolean;
|
|
9
|
-
isBuffer: boolean;
|
|
10
|
-
map?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
source: Buffer;
|
|
13
|
-
map: Buffer;
|
|
14
|
-
isRaw: boolean;
|
|
15
|
-
isBuffer: boolean;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export { JsSource };
|
package/dist/util/source.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsSource = void 0;
|
|
4
|
-
const webpack_sources_1 = require("webpack-sources");
|
|
5
|
-
const index_1 = require("./index");
|
|
6
|
-
class JsSource extends webpack_sources_1.Source {
|
|
7
|
-
static __from_binding(source) {
|
|
8
|
-
if (source.isRaw) {
|
|
9
|
-
return new webpack_sources_1.RawSource(
|
|
10
|
-
// @ts-expect-error: webpack-sources can accept buffer as source, see: https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/RawSource.js#L12
|
|
11
|
-
source.isBuffer ? source.source : source.source.toString("utf-8"));
|
|
12
|
-
}
|
|
13
|
-
if (!source.map) {
|
|
14
|
-
return new webpack_sources_1.RawSource(source.source.toString("utf-8"));
|
|
15
|
-
}
|
|
16
|
-
return new webpack_sources_1.CompatSource({
|
|
17
|
-
source() {
|
|
18
|
-
return source.source.toString("utf-8");
|
|
19
|
-
},
|
|
20
|
-
buffer() {
|
|
21
|
-
return source.source;
|
|
22
|
-
},
|
|
23
|
-
map(_) {
|
|
24
|
-
if (source.map) {
|
|
25
|
-
return JSON.parse(source.map.toString("utf-8"));
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
static __to_binding(source) {
|
|
32
|
-
var _a, _b, _c;
|
|
33
|
-
const sourceSource = source.source();
|
|
34
|
-
const isBuffer = Buffer.isBuffer(sourceSource);
|
|
35
|
-
if (source instanceof webpack_sources_1.RawSource) {
|
|
36
|
-
return {
|
|
37
|
-
source: source.buffer(),
|
|
38
|
-
isRaw: true,
|
|
39
|
-
isBuffer
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const buffer = (_b = (_a = source.buffer) === null || _a === void 0 ? void 0 : _a.call(source)) !== null && _b !== void 0 ? _b : (isBuffer
|
|
43
|
-
? sourceSource
|
|
44
|
-
: sourceSource instanceof ArrayBuffer
|
|
45
|
-
? arrayBufferToBuffer(sourceSource)
|
|
46
|
-
: Buffer.from(sourceSource));
|
|
47
|
-
const map = JSON.stringify((_c = source.map) === null || _c === void 0 ? void 0 : _c.call(source, {
|
|
48
|
-
columns: true
|
|
49
|
-
}));
|
|
50
|
-
return {
|
|
51
|
-
source: buffer,
|
|
52
|
-
map: (0, index_1.isNil)(map) ? map : Buffer.from(map),
|
|
53
|
-
isRaw: false,
|
|
54
|
-
isBuffer
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.JsSource = JsSource;
|
|
59
|
-
function arrayBufferToBuffer(ab) {
|
|
60
|
-
const buf = Buffer.alloc(ab.byteLength);
|
|
61
|
-
const view = new Uint8Array(ab);
|
|
62
|
-
for (let i = 0; i < buf.length; ++i) {
|
|
63
|
-
buf[i] = view[i];
|
|
64
|
-
}
|
|
65
|
-
return buf;
|
|
66
|
-
}
|