@rspack/core 0.7.2 → 0.7.3-canary-607ec67-20240612123914
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/Compiler.js +1 -0
- package/dist/RuleSetCompiler.d.ts +1 -0
- package/dist/RuleSetCompiler.js +1 -0
- package/dist/builtin-loader/swc/index.d.ts +3 -1
- package/dist/builtin-loader/swc/index.js +3 -1
- package/dist/builtin-loader/swc/preact.d.ts +7 -0
- package/dist/builtin-loader/swc/preact.js +15 -0
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.js +5 -1
- package/dist/builtin-plugin/RSCClientEntryRspackPlugin.d.ts +10 -0
- package/dist/builtin-plugin/RSCClientEntryRspackPlugin.js +6 -0
- package/dist/builtin-plugin/RSCClientReferenceManifestRspackPlugin.d.ts +21 -0
- package/dist/builtin-plugin/RSCClientReferenceManifestRspackPlugin.js +60 -0
- package/dist/builtin-plugin/RSCProxyRspackPlugin.d.ts +12 -0
- package/dist/builtin-plugin/RSCProxyRspackPlugin.js +28 -0
- package/dist/builtin-plugin/index.d.ts +6 -0
- package/dist/builtin-plugin/index.js +6 -0
- package/dist/config/adapter.js +9 -9
- package/dist/config/adapterRuleUse.d.ts +3 -39
- package/dist/config/adapterRuleUse.js +14 -7
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/zod.d.ts +310 -302
- package/dist/config/zod.js +2 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +3 -0
- package/dist/exports.js +7 -0
- package/dist/loader-runner/index.d.ts +25 -2
- package/dist/loader-runner/index.js +333 -345
- package/dist/loader-runner/loadLoader.js +1 -53
- package/dist/util/index.d.ts +1 -1
- package/package.json +4 -4
package/dist/Compiler.js
CHANGED
|
@@ -564,6 +564,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
564
564
|
}
|
|
565
565
|
const options = this.options;
|
|
566
566
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
567
|
+
rawOptions.__references = Object.fromEntries(__classPrivateFieldGet(this, _Compiler_ruleSet, "f").builtinReferences.entries());
|
|
567
568
|
const instanceBinding = require("@rspack/binding");
|
|
568
569
|
__classPrivateFieldSet(this, _Compiler_registers, {
|
|
569
570
|
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
|
package/dist/RuleSetCompiler.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type { EmotionOptions } from "./emotion";
|
|
2
2
|
export { resolveEmotion } from "./emotion";
|
|
3
|
-
export type { PluginImportOptions } from "./pluginImport";
|
|
4
3
|
export { resolvePluginImport } from "./pluginImport";
|
|
4
|
+
export type { PluginImportOptions } from "./pluginImport";
|
|
5
5
|
export type { ReactOptions } from "./react";
|
|
6
6
|
export { resolveReact } from "./react";
|
|
7
|
+
export { resolvePreact } from "./preact";
|
|
8
|
+
export type { PreactOptions } from "./preact";
|
|
7
9
|
export type { RelayOptions } from "./relay";
|
|
8
10
|
export { resolveRelay } from "./relay";
|
|
9
11
|
export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./types";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveRelay = exports.resolveReact = exports.resolvePluginImport = exports.resolveEmotion = void 0;
|
|
3
|
+
exports.resolveRelay = exports.resolvePreact = exports.resolveReact = exports.resolvePluginImport = exports.resolveEmotion = void 0;
|
|
4
4
|
var emotion_1 = require("./emotion");
|
|
5
5
|
Object.defineProperty(exports, "resolveEmotion", { enumerable: true, get: function () { return emotion_1.resolveEmotion; } });
|
|
6
6
|
var pluginImport_1 = require("./pluginImport");
|
|
7
7
|
Object.defineProperty(exports, "resolvePluginImport", { enumerable: true, get: function () { return pluginImport_1.resolvePluginImport; } });
|
|
8
8
|
var react_1 = require("./react");
|
|
9
9
|
Object.defineProperty(exports, "resolveReact", { enumerable: true, get: function () { return react_1.resolveReact; } });
|
|
10
|
+
var preact_1 = require("./preact");
|
|
11
|
+
Object.defineProperty(exports, "resolvePreact", { enumerable: true, get: function () { return preact_1.resolvePreact; } });
|
|
10
12
|
var relay_1 = require("./relay");
|
|
11
13
|
Object.defineProperty(exports, "resolveRelay", { enumerable: true, get: function () { return relay_1.resolveRelay; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePreact = void 0;
|
|
4
|
+
function resolvePreact(preact) {
|
|
5
|
+
if (typeof preact === "object") {
|
|
6
|
+
return preact;
|
|
7
|
+
}
|
|
8
|
+
else if (preact === true) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.resolvePreact = resolvePreact;
|
|
@@ -4,7 +4,7 @@ export declare const ExternalsPlugin: {
|
|
|
4
4
|
context?: string | undefined;
|
|
5
5
|
dependencyType?: string | undefined;
|
|
6
6
|
request?: string | undefined;
|
|
7
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "
|
|
7
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "commonjs" | "umd" | "amd" | "promise" | "global" | "jsonp" | "import" | "commonjs2" | "var" | "module" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "system" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
8
8
|
context?: string | undefined;
|
|
9
9
|
dependencyType?: string | undefined;
|
|
10
10
|
request?: string | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const ExternalsPlugin: {
|
|
|
12
12
|
context?: string | undefined;
|
|
13
13
|
dependencyType?: string | undefined;
|
|
14
14
|
request?: string | undefined;
|
|
15
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "
|
|
15
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "commonjs" | "umd" | "amd" | "promise" | "global" | "jsonp" | "import" | "commonjs2" | "var" | "module" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "system" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
16
16
|
context?: string | undefined;
|
|
17
17
|
dependencyType?: string | undefined;
|
|
18
18
|
request?: string | undefined;
|
|
@@ -3,7 +3,7 @@ import { Compiler } from "../Compiler";
|
|
|
3
3
|
export declare const JsLoaderRspackPlugin: {
|
|
4
4
|
new (compiler: Compiler): {
|
|
5
5
|
name: BuiltinPluginName;
|
|
6
|
-
_options: (
|
|
6
|
+
_options: (context: import("@rspack/binding").JsLoaderContext) => Promise<import("@rspack/binding").JsLoaderContext>;
|
|
7
7
|
affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
8
8
|
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
9
9
|
apply(compiler: Compiler): void;
|
|
@@ -5,5 +5,9 @@ const binding_1 = require("@rspack/binding");
|
|
|
5
5
|
const base_1 = require("./base");
|
|
6
6
|
exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) => ({
|
|
7
7
|
prefix: progress.prefix ?? "",
|
|
8
|
-
profile: progress.profile ?? false
|
|
8
|
+
profile: progress.profile ?? false,
|
|
9
|
+
template: progress.template ??
|
|
10
|
+
"● {prefix:.bold} {bar:25.green/white.dim} ({percent}%) {wide_msg:.dim}",
|
|
11
|
+
tick: progress.tick,
|
|
12
|
+
progressChars: progress.progressChars ?? "━━"
|
|
9
13
|
}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
export declare const RSCClientEntryRspackPlugin: {
|
|
3
|
+
new (options: any): {
|
|
4
|
+
name: BuiltinPluginName;
|
|
5
|
+
_options: any;
|
|
6
|
+
affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
|
+
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
8
|
+
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RSCClientEntryRspackPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.RSCClientEntryRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RSCClientEntryRspackPlugin, options => options, "compilation");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RawRscClientReferenceManifestRspackPluginOptions } from "@rspack/binding";
|
|
2
|
+
import type { Compiler } from "../Compiler";
|
|
3
|
+
import type { RuleSetCondition } from "../config/zod";
|
|
4
|
+
import type { RspackBuiltinPlugin } from "./base";
|
|
5
|
+
interface ResolvedOptions {
|
|
6
|
+
routes: NonNullable<RawRscClientReferenceManifestRspackPluginOptions["routes"]>;
|
|
7
|
+
entry: Record<string, string>;
|
|
8
|
+
root: string;
|
|
9
|
+
}
|
|
10
|
+
interface Options extends Pick<RawRscClientReferenceManifestRspackPluginOptions, "routes"> {
|
|
11
|
+
exclude?: RuleSetCondition;
|
|
12
|
+
}
|
|
13
|
+
export declare class RSCClientReferenceManifestRspackPlugin {
|
|
14
|
+
plugin: RspackBuiltinPlugin;
|
|
15
|
+
options: Options;
|
|
16
|
+
resolvedOptions: ResolvedOptions;
|
|
17
|
+
constructor(options?: Options);
|
|
18
|
+
apply(compiler: Compiler): void;
|
|
19
|
+
resolveOptions(compiler: Compiler): ResolvedOptions;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RSCClientReferenceManifestRspackPlugin = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const binding_1 = require("@rspack/binding");
|
|
9
|
+
const base_1 = require("./base");
|
|
10
|
+
const RawRSCClientReferenceManifestRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RSCClientReferenceManifestRspackPlugin, () => { }, "compilation");
|
|
11
|
+
class RSCClientReferenceManifestRspackPlugin {
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.plugin = new RawRSCClientReferenceManifestRspackPlugin();
|
|
14
|
+
this.options = options;
|
|
15
|
+
this.resolvedOptions = {};
|
|
16
|
+
}
|
|
17
|
+
apply(compiler) {
|
|
18
|
+
this.plugin.apply(compiler);
|
|
19
|
+
this.resolvedOptions = this.resolveOptions(compiler);
|
|
20
|
+
if (!compiler.options.module.rules) {
|
|
21
|
+
compiler.options.module.rules = [];
|
|
22
|
+
}
|
|
23
|
+
compiler.options.module.rules.push({
|
|
24
|
+
test: [/\.(j|t|mj|cj)sx?$/i],
|
|
25
|
+
exclude: this.options.exclude ?? {
|
|
26
|
+
// Exclude libraries in node_modules ...
|
|
27
|
+
and: [/node_modules/]
|
|
28
|
+
},
|
|
29
|
+
use: [
|
|
30
|
+
{
|
|
31
|
+
loader: "builtin:rsc-client-entry-loader",
|
|
32
|
+
options: this.resolvedOptions
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
resolveOptions(compiler) {
|
|
38
|
+
const entry = Object.assign({}, compiler.options.entry);
|
|
39
|
+
const resolvedEntry = {};
|
|
40
|
+
const root = compiler.options.context ?? process.cwd();
|
|
41
|
+
// TODO: support dynamic entry
|
|
42
|
+
if (typeof entry === "object") {
|
|
43
|
+
for (let item of Object.keys(entry)) {
|
|
44
|
+
const imports = entry[item].import;
|
|
45
|
+
if (imports) {
|
|
46
|
+
resolvedEntry[item] = imports[0];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const resolvedRoutes = this.options.routes ?? [];
|
|
51
|
+
// TODO: config output
|
|
52
|
+
const output = path_1.default.resolve(root, "./dist/server");
|
|
53
|
+
return {
|
|
54
|
+
entry: resolvedEntry,
|
|
55
|
+
root: output,
|
|
56
|
+
routes: resolvedRoutes
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.RSCClientReferenceManifestRspackPlugin = RSCClientReferenceManifestRspackPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Compiler } from "../Compiler";
|
|
2
|
+
import type { RuleSetCondition } from "../config/zod";
|
|
3
|
+
interface Options {
|
|
4
|
+
clientProxy: string;
|
|
5
|
+
exclude?: RuleSetCondition;
|
|
6
|
+
}
|
|
7
|
+
export declare class RSCProxyRspackPlugin {
|
|
8
|
+
options: Options;
|
|
9
|
+
constructor(options: Options);
|
|
10
|
+
apply(compiler: Compiler): void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RSCProxyRspackPlugin = void 0;
|
|
4
|
+
class RSCProxyRspackPlugin {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
if (!compiler.options.module.rules) {
|
|
10
|
+
compiler.options.module.rules = [];
|
|
11
|
+
}
|
|
12
|
+
compiler.options.module.rules.push({
|
|
13
|
+
enforce: "post",
|
|
14
|
+
test: [/\.(j|t|mj|cj)sx?$/i],
|
|
15
|
+
exclude: this.options.exclude ?? {
|
|
16
|
+
// Exclude libraries in node_modules ...
|
|
17
|
+
and: [/node_modules/]
|
|
18
|
+
},
|
|
19
|
+
use: [
|
|
20
|
+
{
|
|
21
|
+
loader: "builtin:rsc-proxy-loader",
|
|
22
|
+
options: this.options
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.RSCProxyRspackPlugin = RSCProxyRspackPlugin;
|
|
@@ -8,6 +8,8 @@ export * from "./BundlerInfoRspackPlugin";
|
|
|
8
8
|
export * from "./ChunkPrefetchPreloadPlugin";
|
|
9
9
|
export * from "./CommonJsChunkFormatPlugin";
|
|
10
10
|
export * from "./CopyRspackPlugin";
|
|
11
|
+
export * from "./CopyRspackPlugin";
|
|
12
|
+
export * from "./css-extract";
|
|
11
13
|
export * from "./css-extract";
|
|
12
14
|
export * from "./CssModulesPlugin";
|
|
13
15
|
export * from "./DataUriPlugin";
|
|
@@ -34,6 +36,7 @@ export * from "./IgnorePlugin";
|
|
|
34
36
|
export * from "./InferAsyncModulesPlugin";
|
|
35
37
|
export * from "./JavascriptModulesPlugin";
|
|
36
38
|
export * from "./JsLoaderRspackPlugin";
|
|
39
|
+
export * from "./JsLoaderRspackPlugin";
|
|
37
40
|
export * from "./JsonModulesPlugin";
|
|
38
41
|
export * from "./lazy-compilation/plugin";
|
|
39
42
|
export * from "./LimitChunkCountPlugin";
|
|
@@ -50,6 +53,9 @@ export * from "./ProgressPlugin";
|
|
|
50
53
|
export * from "./ProvidePlugin";
|
|
51
54
|
export * from "./RealContentHashPlugin";
|
|
52
55
|
export * from "./RemoveEmptyChunksPlugin";
|
|
56
|
+
export * from "./RSCClientEntryRspackPlugin";
|
|
57
|
+
export * from "./RSCClientReferenceManifestRspackPlugin";
|
|
58
|
+
export * from "./RSCProxyRspackPlugin";
|
|
53
59
|
export * from "./RuntimeChunkPlugin";
|
|
54
60
|
export * from "./RuntimePlugin";
|
|
55
61
|
export * from "./SideEffectsFlagPlugin";
|
|
@@ -26,6 +26,8 @@ __exportStar(require("./BundlerInfoRspackPlugin"), exports);
|
|
|
26
26
|
__exportStar(require("./ChunkPrefetchPreloadPlugin"), exports);
|
|
27
27
|
__exportStar(require("./CommonJsChunkFormatPlugin"), exports);
|
|
28
28
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
29
|
+
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
30
|
+
__exportStar(require("./css-extract"), exports);
|
|
29
31
|
__exportStar(require("./css-extract"), exports);
|
|
30
32
|
__exportStar(require("./CssModulesPlugin"), exports);
|
|
31
33
|
__exportStar(require("./DataUriPlugin"), exports);
|
|
@@ -52,6 +54,7 @@ __exportStar(require("./IgnorePlugin"), exports);
|
|
|
52
54
|
__exportStar(require("./InferAsyncModulesPlugin"), exports);
|
|
53
55
|
__exportStar(require("./JavascriptModulesPlugin"), exports);
|
|
54
56
|
__exportStar(require("./JsLoaderRspackPlugin"), exports);
|
|
57
|
+
__exportStar(require("./JsLoaderRspackPlugin"), exports);
|
|
55
58
|
__exportStar(require("./JsonModulesPlugin"), exports);
|
|
56
59
|
__exportStar(require("./lazy-compilation/plugin"), exports);
|
|
57
60
|
__exportStar(require("./LimitChunkCountPlugin"), exports);
|
|
@@ -68,6 +71,9 @@ __exportStar(require("./ProgressPlugin"), exports);
|
|
|
68
71
|
__exportStar(require("./ProvidePlugin"), exports);
|
|
69
72
|
__exportStar(require("./RealContentHashPlugin"), exports);
|
|
70
73
|
__exportStar(require("./RemoveEmptyChunksPlugin"), exports);
|
|
74
|
+
__exportStar(require("./RSCClientEntryRspackPlugin"), exports);
|
|
75
|
+
__exportStar(require("./RSCClientReferenceManifestRspackPlugin"), exports);
|
|
76
|
+
__exportStar(require("./RSCProxyRspackPlugin"), exports);
|
|
71
77
|
__exportStar(require("./RuntimeChunkPlugin"), exports);
|
|
72
78
|
__exportStar(require("./RuntimePlugin"), exports);
|
|
73
79
|
__exportStar(require("./SideEffectsFlagPlugin"), exports);
|
package/dist/config/adapter.js
CHANGED
|
@@ -49,7 +49,8 @@ const getRawOptions = (options, compiler) => {
|
|
|
49
49
|
// SAFETY: applied default value in `applyRspackOptionsDefaults`.
|
|
50
50
|
profile: options.profile,
|
|
51
51
|
// SAFETY: applied default value in `applyRspackOptionsDefaults`.
|
|
52
|
-
bail: options.bail
|
|
52
|
+
bail: options.bail,
|
|
53
|
+
__references: {}
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
exports.getRawOptions = getRawOptions;
|
|
@@ -257,12 +258,13 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
257
258
|
}
|
|
258
259
|
let funcUse;
|
|
259
260
|
if (typeof rule.use === "function") {
|
|
261
|
+
let use = rule.use;
|
|
260
262
|
funcUse = (rawContext) => {
|
|
261
263
|
const context = {
|
|
262
264
|
...rawContext,
|
|
263
265
|
compiler: options.compiler
|
|
264
266
|
};
|
|
265
|
-
const uses =
|
|
267
|
+
const uses = use(context);
|
|
266
268
|
return (0, adapterRuleUse_1.createRawModuleRuleUses)(uses ?? [], `${path}.use`, options);
|
|
267
269
|
};
|
|
268
270
|
}
|
|
@@ -291,11 +293,8 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
291
293
|
mimetype: rule.mimetype ? getRawRuleSetCondition(rule.mimetype) : undefined,
|
|
292
294
|
sideEffects: rule.sideEffects,
|
|
293
295
|
use: typeof rule.use === "function"
|
|
294
|
-
?
|
|
295
|
-
: {
|
|
296
|
-
type: "array",
|
|
297
|
-
arrayUse: (0, adapterRuleUse_1.createRawModuleRuleUses)(rule.use ?? [], `${path}.use`, options)
|
|
298
|
-
},
|
|
296
|
+
? funcUse
|
|
297
|
+
: (0, adapterRuleUse_1.createRawModuleRuleUses)(rule.use ?? [], `${path}.use`, options),
|
|
299
298
|
type: rule.type,
|
|
300
299
|
parser: rule.parser
|
|
301
300
|
? getRawParserOptions(rule.parser, rule.type ?? "javascript/auto")
|
|
@@ -603,11 +602,12 @@ function getRawSnapshotOptions(_snapshot) {
|
|
|
603
602
|
return {};
|
|
604
603
|
}
|
|
605
604
|
function getRawExperiments(experiments) {
|
|
606
|
-
const { topLevelAwait, rspackFuture } = experiments;
|
|
605
|
+
const { topLevelAwait, rspackFuture, rsc = false } = experiments;
|
|
607
606
|
(0, assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture));
|
|
608
607
|
return {
|
|
609
608
|
topLevelAwait,
|
|
610
|
-
rspackFuture: getRawRspackFutureOptions(rspackFuture)
|
|
609
|
+
rspackFuture: getRawRspackFutureOptions(rspackFuture),
|
|
610
|
+
rsc
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
613
|
function getRawRspackFutureOptions(_future) {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { JsAssetInfo,
|
|
2
|
+
import type { JsAssetInfo, RawModuleRuleUse, RawOptions } from "@rspack/binding";
|
|
3
3
|
import { ResolveRequest } from "../../compiled/enhanced-resolve";
|
|
4
4
|
import { Compiler } from "../Compiler";
|
|
5
5
|
import { Logger } from "../logging/Logger";
|
|
6
6
|
import Hash = require("../util/hash");
|
|
7
7
|
import { Compilation } from "../Compilation";
|
|
8
8
|
import { Module } from "../Module";
|
|
9
|
+
import { LoaderObject } from "../loader-runner";
|
|
9
10
|
import { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
|
|
11
|
+
export declare const BUILTIN_LOADER_PREFIX = "builtin:";
|
|
10
12
|
export interface ComposeJsUseOptions {
|
|
11
13
|
devtool: RawOptions["devtool"];
|
|
12
14
|
context: RawOptions["context"];
|
|
@@ -26,20 +28,6 @@ export interface SourceMap {
|
|
|
26
28
|
export interface AdditionalData {
|
|
27
29
|
[index: string]: any;
|
|
28
30
|
}
|
|
29
|
-
export interface LoaderObject {
|
|
30
|
-
request: string;
|
|
31
|
-
path: string;
|
|
32
|
-
query: string;
|
|
33
|
-
fragment: string;
|
|
34
|
-
options: object | string | undefined;
|
|
35
|
-
ident: string;
|
|
36
|
-
normal: Function | undefined;
|
|
37
|
-
pitch: Function | undefined;
|
|
38
|
-
raw: boolean | undefined;
|
|
39
|
-
data: object | undefined;
|
|
40
|
-
pitchExecuted: boolean;
|
|
41
|
-
normalExecuted: boolean;
|
|
42
|
-
}
|
|
43
31
|
export interface LoaderContext<OptionsType = {}> {
|
|
44
32
|
version: 2;
|
|
45
33
|
resource: string;
|
|
@@ -113,30 +101,6 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
113
101
|
_compiler: Compiler;
|
|
114
102
|
_compilation: Compilation;
|
|
115
103
|
_module: Module;
|
|
116
|
-
/**
|
|
117
|
-
* Internal field for interoperability.
|
|
118
|
-
* Do not use this in anywhere else.
|
|
119
|
-
*
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
122
|
-
__internal__context: JsLoaderContext;
|
|
123
|
-
/**
|
|
124
|
-
* Internal field for interoperability.
|
|
125
|
-
* Do not use this in anywhere else.
|
|
126
|
-
*
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
__internal__pushNativeDiagnostics: (diagnostics: any) => void;
|
|
130
|
-
}
|
|
131
|
-
export interface LoaderResult {
|
|
132
|
-
cacheable: boolean;
|
|
133
|
-
content: string | Buffer;
|
|
134
|
-
sourceMap?: string | SourceMap;
|
|
135
|
-
additionalData?: AdditionalData;
|
|
136
|
-
fileDependencies: string[];
|
|
137
|
-
contextDependencies: string[];
|
|
138
|
-
missingDependencies: string[];
|
|
139
|
-
buildDependencies: string[];
|
|
140
104
|
}
|
|
141
105
|
export interface LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
|
|
142
106
|
(this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData): string | void | Buffer | Promise<string | Buffer>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUseSimpleSourceMap = exports.isUseSourceMap = exports.createRawModuleRuleUses = void 0;
|
|
3
|
+
exports.isUseSimpleSourceMap = exports.isUseSourceMap = exports.createRawModuleRuleUses = exports.BUILTIN_LOADER_PREFIX = void 0;
|
|
4
4
|
const builtin_loader_1 = require("../builtin-loader");
|
|
5
5
|
const loader_runner_1 = require("../loader-runner");
|
|
6
6
|
const util_1 = require("../util");
|
|
7
|
-
|
|
7
|
+
exports.BUILTIN_LOADER_PREFIX = "builtin:";
|
|
8
8
|
function createRawModuleRuleUses(uses, path, options) {
|
|
9
9
|
const normalizeRuleSetUseItem = (item) => typeof item === "string" ? { loader: item } : item;
|
|
10
10
|
const allUses = Array.isArray(uses)
|
|
@@ -30,11 +30,14 @@ const getSwcLoaderOptions = (o, options) => {
|
|
|
30
30
|
if (expr.react) {
|
|
31
31
|
expr.react = (0, builtin_loader_1.resolveReact)(expr.react);
|
|
32
32
|
}
|
|
33
|
+
if (expr.preact) {
|
|
34
|
+
expr.preact = (0, builtin_loader_1.resolvePreact)(expr.preact);
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
return o;
|
|
35
38
|
};
|
|
36
39
|
function getBuiltinLoaderOptions(identifier, o, options) {
|
|
37
|
-
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}swc-loader`)) {
|
|
40
|
+
if (identifier.startsWith(`${exports.BUILTIN_LOADER_PREFIX}swc-loader`)) {
|
|
38
41
|
return getSwcLoaderOptions(o, options);
|
|
39
42
|
}
|
|
40
43
|
return o;
|
|
@@ -44,18 +47,19 @@ function createRawModuleRuleUsesImpl(uses, path, options) {
|
|
|
44
47
|
return [];
|
|
45
48
|
}
|
|
46
49
|
return uses.map((use, index) => {
|
|
47
|
-
let o;
|
|
48
|
-
if (use.loader.startsWith(BUILTIN_LOADER_PREFIX)) {
|
|
50
|
+
let o, isBuiltin = false;
|
|
51
|
+
if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) {
|
|
49
52
|
o = getBuiltinLoaderOptions(use.loader, use.options, options);
|
|
50
53
|
o = (0, util_1.isNil)(o) ? undefined : typeof o === "string" ? o : JSON.stringify(o);
|
|
54
|
+
isBuiltin = true;
|
|
51
55
|
}
|
|
52
56
|
return {
|
|
53
|
-
loader: resolveStringifyLoaders(use, `${path}[${index}]`, options.compiler),
|
|
57
|
+
loader: resolveStringifyLoaders(use, `${path}[${index}]`, options.compiler, isBuiltin),
|
|
54
58
|
options: o
|
|
55
59
|
};
|
|
56
60
|
});
|
|
57
61
|
}
|
|
58
|
-
function resolveStringifyLoaders(use, path, compiler) {
|
|
62
|
+
function resolveStringifyLoaders(use, path, compiler, isBuiltin) {
|
|
59
63
|
const obj = (0, loader_runner_1.parsePathQueryFragment)(use.loader);
|
|
60
64
|
let ident = null;
|
|
61
65
|
if (use.options === null) {
|
|
@@ -76,6 +80,9 @@ function resolveStringifyLoaders(use, path, compiler) {
|
|
|
76
80
|
if (!ident)
|
|
77
81
|
ident = "[[missing ident]]";
|
|
78
82
|
compiler.__internal__ruleSet.references.set(ident, use.options);
|
|
83
|
+
if (isBuiltin) {
|
|
84
|
+
compiler.__internal__ruleSet.builtinReferences.set(ident, use.options);
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
return obj.path + obj.query + obj.fragment;
|
|
81
88
|
}
|
|
@@ -86,6 +86,7 @@ export interface ExperimentsNormalized {
|
|
|
86
86
|
css?: boolean;
|
|
87
87
|
futureDefaults?: boolean;
|
|
88
88
|
rspackFuture?: RspackFutureOptions;
|
|
89
|
+
rsc?: boolean;
|
|
89
90
|
}
|
|
90
91
|
export type IgnoreWarningsNormalized = ((warning: Error, compilation: Compilation) => boolean)[];
|
|
91
92
|
export type OptimizationRuntimeChunkNormalized = false | {
|