@rspack/core 0.7.3-canary-a741c8d-20240611125339 → 0.7.3
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/config/adapter.js +6 -7
- package/dist/config/adapterRuleUse.d.ts +3 -39
- package/dist/config/adapterRuleUse.js +14 -7
- package/dist/config/zod.d.ts +302 -302
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- 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/stats/DefaultStatsFactoryPlugin.js +15 -1
- package/dist/stats/DefaultStatsPresetPlugin.js +2 -2
- package/dist/util/index.d.ts +1 -1
- package/module.d.ts +244 -0
- package/package.json +8 -6
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
|
}));
|
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")
|
|
@@ -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
|
}
|