@rspack/core 0.6.5-canary-231c64e-20240515075232 → 0.6.5-canary-5042eed-20240515115707
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/base.js +1 -1
- 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 +50 -0
- package/dist/builtin-plugin/lazy-compilation/backend.js +139 -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 +13 -0
- package/dist/builtin-plugin/lazy-compilation/plugin.js +60 -0
- package/dist/config/adapter.js +6 -5
- package/dist/config/defaults.js +3 -1
- package/dist/config/normalization.d.ts +2 -3
- package/dist/config/normalization.js +2 -1
- package/dist/config/zod.d.ts +159 -16
- package/dist/config/zod.js +16 -15
- package/dist/rspackOptionsApply.js +20 -1
- package/package.json +4 -4
package/dist/Watching.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Watching {
|
|
|
24
24
|
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>): void;
|
|
25
25
|
close(callback?: () => void): void;
|
|
26
26
|
invalidate(callback?: Callback<Error, void>): void;
|
|
27
|
+
lazyCompilationInvalidate(files: Set<string>): void;
|
|
27
28
|
/**
|
|
28
29
|
* The reason why this is _done instead of #done, is that in Webpack,
|
|
29
30
|
* it will rewrite this function to another function
|
package/dist/Watching.js
CHANGED
|
@@ -160,6 +160,9 @@ class Watching {
|
|
|
160
160
|
this.onChange();
|
|
161
161
|
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
162
162
|
}
|
|
163
|
+
lazyCompilationInvalidate(files) {
|
|
164
|
+
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, new Map(), new Map(), files, new Set());
|
|
165
|
+
}
|
|
163
166
|
_done(error, compilation) {
|
|
164
167
|
this.running = false;
|
|
165
168
|
let stats = undefined;
|
|
@@ -38,7 +38,7 @@ function createBuiltinPlugin(name, options) {
|
|
|
38
38
|
}
|
|
39
39
|
exports.createBuiltinPlugin = createBuiltinPlugin;
|
|
40
40
|
function create(name, resolve,
|
|
41
|
-
// `affectedHooks` is used to inform `createChildCompile` about which builtin plugin can be
|
|
41
|
+
// `affectedHooks` is used to inform `createChildCompile` about which builtin plugin can be reserved.
|
|
42
42
|
// However, this has a drawback as it doesn't represent the actual condition but merely serves as an indicator.
|
|
43
43
|
affectedHooks) {
|
|
44
44
|
class Plugin extends RspackBuiltinPlugin {
|
|
@@ -58,6 +58,7 @@ export * from "./SwcJsMinimizerPlugin";
|
|
|
58
58
|
export * from "./WarnCaseSensitiveModulesPlugin";
|
|
59
59
|
export * from "./WebWorkerTemplatePlugin";
|
|
60
60
|
export * from "./WorkerPlugin";
|
|
61
|
+
export * from "./lazy-compilation/plugin";
|
|
61
62
|
import { RawBuiltins } from "@rspack/binding";
|
|
62
63
|
import { RspackOptionsNormalized } from "..";
|
|
63
64
|
export interface Builtins {
|
|
@@ -76,6 +76,7 @@ __exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
|
76
76
|
__exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
|
|
77
77
|
__exportStar(require("./WebWorkerTemplatePlugin"), exports);
|
|
78
78
|
__exportStar(require("./WorkerPlugin"), exports);
|
|
79
|
+
__exportStar(require("./lazy-compilation/plugin"), exports);
|
|
79
80
|
function resolveTreeShaking(treeShaking, production) {
|
|
80
81
|
return treeShaking !== undefined
|
|
81
82
|
? treeShaking.toString()
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
};
|
|
@@ -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.LazyCompilationPlugin, (module, cacheable, entries, imports, test) => ({ module, cacheable, imports, entries, test }), "thisCompilation");
|
|
@@ -0,0 +1,13 @@
|
|
|
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 };
|
|
@@ -0,0 +1,60 @@
|
|
|
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/config/adapter.js
CHANGED
|
@@ -566,14 +566,16 @@ function getRawAssetGeneratorDataUrl(dataUrl) {
|
|
|
566
566
|
function getRawCssGeneratorOptions(options) {
|
|
567
567
|
return {
|
|
568
568
|
exportsConvention: options.exportsConvention,
|
|
569
|
-
exportsOnly: options.exportsOnly
|
|
569
|
+
exportsOnly: options.exportsOnly,
|
|
570
|
+
esModule: options.esModule
|
|
570
571
|
};
|
|
571
572
|
}
|
|
572
573
|
function getRawCssAutoOrModuleGeneratorOptions(options) {
|
|
573
574
|
return {
|
|
574
575
|
localIdentName: options.localIdentName,
|
|
575
576
|
exportsConvention: options.exportsConvention,
|
|
576
|
-
exportsOnly: options.exportsOnly
|
|
577
|
+
exportsOnly: options.exportsOnly,
|
|
578
|
+
esModule: options.esModule
|
|
577
579
|
};
|
|
578
580
|
}
|
|
579
581
|
function getRawOptimization(optimization) {
|
|
@@ -615,10 +617,9 @@ function getRawSnapshotOptions(snapshot) {
|
|
|
615
617
|
};
|
|
616
618
|
}
|
|
617
619
|
function getRawExperiments(experiments) {
|
|
618
|
-
const {
|
|
619
|
-
(0, assert_1.default)(!(0, util_1.isNil)(
|
|
620
|
+
const { topLevelAwait, rspackFuture } = experiments;
|
|
621
|
+
(0, assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture));
|
|
620
622
|
return {
|
|
621
|
-
newSplitChunks,
|
|
622
623
|
topLevelAwait,
|
|
623
624
|
rspackFuture: getRawRspackFutureOptions(rspackFuture)
|
|
624
625
|
};
|
package/dist/config/defaults.js
CHANGED
|
@@ -121,7 +121,6 @@ const applyInfrastructureLoggingDefaults = (infrastructureLogging) => {
|
|
|
121
121
|
const applyExperimentsDefaults = (experiments, { cache }) => {
|
|
122
122
|
D(experiments, "lazyCompilation", false);
|
|
123
123
|
D(experiments, "asyncWebAssembly", false);
|
|
124
|
-
D(experiments, "newSplitChunks", true);
|
|
125
124
|
D(experiments, "css", true); // we not align with webpack about the default value for better DX
|
|
126
125
|
D(experiments, "topLevelAwait", true);
|
|
127
126
|
D(experiments, "rspackFuture", {});
|
|
@@ -198,16 +197,19 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
|
|
|
198
197
|
(0, assertNotNil_1.assertNotNill)(module.generator.css);
|
|
199
198
|
D(module.generator["css"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
200
199
|
D(module.generator["css"], "exportsConvention", "as-is");
|
|
200
|
+
D(module.generator["css"], "esModule", true);
|
|
201
201
|
F(module.generator, "css/auto", () => ({}));
|
|
202
202
|
(0, assertNotNil_1.assertNotNill)(module.generator["css/auto"]);
|
|
203
203
|
D(module.generator["css/auto"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
204
204
|
D(module.generator["css/auto"], "exportsConvention", "as-is");
|
|
205
205
|
D(module.generator["css/auto"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
206
|
+
D(module.generator["css/auto"], "esModule", true);
|
|
206
207
|
F(module.generator, "css/module", () => ({}));
|
|
207
208
|
(0, assertNotNil_1.assertNotNill)(module.generator["css/module"]);
|
|
208
209
|
D(module.generator["css/module"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
209
210
|
D(module.generator["css/module"], "exportsConvention", "as-is");
|
|
210
211
|
D(module.generator["css/module"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
212
|
+
D(module.generator["css/module"], "esModule", true);
|
|
211
213
|
}
|
|
212
214
|
A(module, "defaultRules", () => {
|
|
213
215
|
const esm = {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
10
|
import type { Compilation } from "../Compilation";
|
|
11
|
-
import type { AssetModuleFilename, Bail, Builtins, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LibraryOptions, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod";
|
|
11
|
+
import type { AssetModuleFilename, Bail, Builtins, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LibraryOptions, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath, LazyCompilationOptions } from "./zod";
|
|
12
12
|
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
|
|
13
13
|
export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
|
|
14
14
|
export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
|
|
@@ -78,10 +78,9 @@ export interface ModuleOptionsNormalized {
|
|
|
78
78
|
noParse?: NoParseOption;
|
|
79
79
|
}
|
|
80
80
|
export interface ExperimentsNormalized {
|
|
81
|
-
lazyCompilation?:
|
|
81
|
+
lazyCompilation?: false | LazyCompilationOptions;
|
|
82
82
|
asyncWebAssembly?: boolean;
|
|
83
83
|
outputModule?: boolean;
|
|
84
|
-
newSplitChunks?: boolean;
|
|
85
84
|
topLevelAwait?: boolean;
|
|
86
85
|
css?: boolean;
|
|
87
86
|
futureDefaults?: boolean;
|
|
@@ -190,7 +190,8 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
190
190
|
performance: config.performance,
|
|
191
191
|
plugins: nestedArray(config.plugins, p => [...p]),
|
|
192
192
|
experiments: nestedConfig(config.experiments, experiments => ({
|
|
193
|
-
...experiments
|
|
193
|
+
...experiments,
|
|
194
|
+
lazyCompilation: optionalNestedConfig(experiments.lazyCompilation, options => (options === true ? {} : options))
|
|
194
195
|
})),
|
|
195
196
|
watch: config.watch,
|
|
196
197
|
watchOptions: cloneObject(config.watchOptions),
|