@rspack/core 1.0.0-alpha.2 → 1.0.0-alpha.4
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/compiled/browserslist/index.js +17 -17
- package/compiled/enhanced-resolve/index.js +107 -107
- package/compiled/graceful-fs/index.js +8 -8
- package/compiled/json-parse-even-better-errors/index.js +2 -2
- package/compiled/neo-async/index.js +2 -2
- package/compiled/watchpack/index.js +15 -15
- package/compiled/webpack-sources/index.js +76 -76
- package/compiled/zod/index.js +30 -30
- package/compiled/zod-validation-error/index.js +6 -6
- package/dist/ChunkGraph.d.ts +1 -1
- package/dist/Compilation.d.ts +9 -9
- package/dist/Compilation.js +27 -24
- package/dist/Compiler.d.ts +6 -6
- package/dist/Compiler.js +5 -6
- package/dist/ContextModuleFactory.d.ts +1 -1
- package/dist/ErrorHelpers.d.ts +16 -7
- package/dist/ErrorHelpers.js +34 -33
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/FileSystem.d.ts +2 -2
- package/dist/Module.d.ts +5 -5
- package/dist/Module.js +3 -6
- package/dist/MultiCompiler.d.ts +3 -3
- package/dist/MultiCompiler.js +1 -1
- package/dist/MultiStats.d.ts +2 -2
- package/dist/MultiWatching.d.ts +2 -2
- package/dist/NormalModule.d.ts +1 -1
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/Resolver.d.ts +19 -0
- package/dist/Resolver.js +39 -0
- package/dist/ResolverFactory.d.ts +12 -46
- package/dist/ResolverFactory.js +55 -120
- package/dist/RspackError.d.ts +1 -1
- package/dist/RuntimeGlobals.d.ts +1 -1
- package/dist/RuntimeGlobals.js +3 -3
- package/dist/Stats.d.ts +2 -2
- package/dist/Stats.js +4 -4
- package/dist/Template.js +2 -2
- package/dist/Watching.d.ts +3 -3
- package/dist/builtin-loader/swc/index.d.ts +0 -2
- package/dist/builtin-loader/swc/index.js +1 -3
- package/dist/builtin-loader/swc/pluginImport.d.ts +17 -1
- package/dist/builtin-loader/swc/react.d.ts +11 -1
- package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/BannerPlugin.d.ts +25 -4
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +4 -4
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +4 -4
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DefinePlugin.d.ts +10 -4
- package/dist/builtin-plugin/DefinePlugin.js +42 -8
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +5 -5
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EntryPlugin.d.ts +5 -5
- package/dist/builtin-plugin/EntryPlugin.js +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +4 -4
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -5
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +22 -6
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +3 -3
- package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +19 -4
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +4 -4
- package/dist/builtin-plugin/IgnorePlugin.d.ts +4 -4
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +4 -4
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -4
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +4 -4
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ProgressPlugin.d.ts +4 -4
- package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +4 -4
- package/dist/builtin-plugin/RuntimePlugin.d.ts +3 -3
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +3 -3
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +9 -4
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +3 -3
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +12 -4
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +4 -4
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +3 -3
- package/dist/builtin-plugin/WorkerPlugin.d.ts +3 -3
- package/dist/builtin-plugin/WorkerPlugin.js +5 -1
- package/dist/builtin-plugin/base.d.ts +6 -6
- package/dist/builtin-plugin/base.js +4 -4
- package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/loader.js +15 -5
- package/dist/builtin-plugin/css-extract/utils.d.ts +1 -1
- package/dist/builtin-plugin/index.d.ts +1 -7
- package/dist/builtin-plugin/index.js +3 -17
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +11 -17
- package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +2 -2
- package/dist/config/adapter.d.ts +5 -4
- package/dist/config/adapter.js +23 -11
- package/dist/config/adapterRuleUse.d.ts +7 -7
- package/dist/config/adapterRuleUse.js +1 -1
- package/dist/config/browserslistTargetHandler.js +1 -1
- package/dist/config/defaults.d.ts +1 -1
- package/dist/config/defaults.js +4 -3
- package/dist/config/zod.d.ts +491 -384
- package/dist/config/zod.js +44 -42
- package/dist/container/ContainerPlugin.d.ts +3 -3
- package/dist/container/ContainerReferencePlugin.d.ts +4 -4
- package/dist/container/ModuleFederationPlugin.d.ts +2 -2
- package/dist/container/ModuleFederationPlugin.js +2 -2
- package/dist/container/ModuleFederationPluginV1.d.ts +5 -5
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
- package/dist/container/default.runtime.js +1 -1
- package/dist/lib/EntryOptionPlugin.d.ts +2 -2
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +2 -2
- package/dist/loader-runner/index.d.ts +2 -2
- package/dist/loader-runner/index.js +38 -51
- package/dist/loader-runner/loadLoader.js +1 -1
- package/dist/logging/runtime.js +1 -1
- package/dist/node/NodeTemplatePlugin.d.ts +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +1 -1
- package/dist/rspack.d.ts +3 -3
- package/dist/rspack.js +1 -1
- package/dist/rspackOptionsApply.d.ts +1 -1
- package/dist/rspackOptionsApply.js +1 -19
- package/dist/sharing/ConsumeSharedPlugin.d.ts +2 -2
- package/dist/sharing/ConsumeSharedPlugin.js +1 -1
- package/dist/sharing/ProvideSharedPlugin.d.ts +2 -2
- package/dist/sharing/SharePlugin.d.ts +1 -1
- package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
- package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
- package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
- package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/dist/stats/StatsFactory.d.ts +2 -2
- package/dist/stats/statsFactoryUtils.d.ts +16 -1
- package/dist/util/SplitChunkSize.d.ts +1 -1
- package/dist/util/bindingVersionCheck.js +1 -1
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/identifier.d.ts +65 -62
- package/dist/util/identifier.js +30 -55
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +4 -2
- package/dist/util/validate.d.ts +1 -1
- package/package.json +7 -34
|
@@ -56,8 +56,8 @@ function getRawExtractCommentsOptions(extractComments) {
|
|
|
56
56
|
}
|
|
57
57
|
exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => {
|
|
58
58
|
let compress = options?.compress ?? true;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const mangle = options?.mangle ?? true;
|
|
60
|
+
const format = {
|
|
61
61
|
comments: false,
|
|
62
62
|
...options?.format
|
|
63
63
|
};
|
|
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
|
|
|
2
2
|
export declare const WarnCaseSensitiveModulesPlugin: {
|
|
3
3
|
new (): {
|
|
4
4
|
name: BuiltinPluginName;
|
|
5
|
-
|
|
6
|
-
affectedHooks: "
|
|
7
|
-
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
5
|
+
_args: [];
|
|
6
|
+
affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
|
+
raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
8
8
|
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
|
|
|
2
2
|
export declare const WebWorkerTemplatePlugin: {
|
|
3
3
|
new (): {
|
|
4
4
|
name: BuiltinPluginName;
|
|
5
|
-
|
|
6
|
-
affectedHooks: "
|
|
7
|
-
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
5
|
+
_args: [];
|
|
6
|
+
affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
|
+
raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
8
8
|
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
|
|
2
|
-
import { Compiler } from "../Compiler";
|
|
3
|
-
import { ChunkLoading, OutputModule, WasmLoading, WorkerPublicPath } from "../config";
|
|
1
|
+
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
import type { Compiler } from "../Compiler";
|
|
3
|
+
import type { ChunkLoading, OutputModule, WasmLoading, WorkerPublicPath } from "../config";
|
|
4
4
|
import { RspackBuiltinPlugin } from "./base";
|
|
5
5
|
export declare class WorkerPlugin extends RspackBuiltinPlugin {
|
|
6
6
|
private chunkLoading;
|
|
@@ -6,7 +6,11 @@ const EnableChunkLoadingPlugin_1 = require("./EnableChunkLoadingPlugin");
|
|
|
6
6
|
const EnableWasmLoadingPlugin_1 = require("./EnableWasmLoadingPlugin");
|
|
7
7
|
const base_1 = require("./base");
|
|
8
8
|
class WorkerPlugin extends base_1.RspackBuiltinPlugin {
|
|
9
|
-
constructor(chunkLoading, wasmLoading,
|
|
9
|
+
constructor(chunkLoading, wasmLoading,
|
|
10
|
+
// @ts-expect-error not implemented
|
|
11
|
+
module,
|
|
12
|
+
// @ts-expect-error not implemented
|
|
13
|
+
workerPublicPath) {
|
|
10
14
|
super();
|
|
11
15
|
this.chunkLoading = chunkLoading;
|
|
12
16
|
this.wasmLoading = wasmLoading;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as binding from "@rspack/binding";
|
|
2
|
-
import { Compiler, RspackPluginInstance } from "..";
|
|
1
|
+
import type * as binding from "@rspack/binding";
|
|
2
|
+
import type { Compiler, RspackPluginInstance } from "..";
|
|
3
3
|
type AffectedHooks = keyof Compiler["hooks"];
|
|
4
4
|
export declare const HOOKS_CAN_NOT_INHERENT_FROM_PARENT: string[];
|
|
5
5
|
export declare function canInherentFromParent(affectedHooks?: AffectedHooks): boolean;
|
|
@@ -10,12 +10,12 @@ export declare abstract class RspackBuiltinPlugin implements RspackPluginInstanc
|
|
|
10
10
|
apply(compiler: Compiler): void;
|
|
11
11
|
}
|
|
12
12
|
export declare function createBuiltinPlugin<R>(name: binding.BuiltinPluginName, options: R): binding.BuiltinPlugin;
|
|
13
|
-
export declare function create<T extends any[], R>(name: binding.BuiltinPluginName, resolve: (...args: T) => R, affectedHooks?: AffectedHooks): {
|
|
13
|
+
export declare function create<T extends any[], R>(name: binding.BuiltinPluginName, resolve: (this: Compiler, ...args: T) => R, affectedHooks?: AffectedHooks): {
|
|
14
14
|
new (...args: T): {
|
|
15
15
|
name: binding.BuiltinPluginName;
|
|
16
|
-
|
|
17
|
-
affectedHooks: "
|
|
18
|
-
raw(): binding.BuiltinPlugin;
|
|
16
|
+
_args: T;
|
|
17
|
+
affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
18
|
+
raw(compiler: Compiler): binding.BuiltinPlugin;
|
|
19
19
|
apply(compiler: Compiler): void;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -22,7 +22,7 @@ function canInherentFromParent(affectedHooks) {
|
|
|
22
22
|
exports.canInherentFromParent = canInherentFromParent;
|
|
23
23
|
class RspackBuiltinPlugin {
|
|
24
24
|
apply(compiler) {
|
|
25
|
-
|
|
25
|
+
const raw = this.raw(compiler);
|
|
26
26
|
if (raw) {
|
|
27
27
|
raw.canInherentFromParent = canInherentFromParent(this.affectedHooks);
|
|
28
28
|
compiler.__internal__registerBuiltinPlugin(raw);
|
|
@@ -46,10 +46,10 @@ affectedHooks) {
|
|
|
46
46
|
super();
|
|
47
47
|
this.name = name;
|
|
48
48
|
this.affectedHooks = affectedHooks;
|
|
49
|
-
this.
|
|
49
|
+
this._args = args;
|
|
50
50
|
}
|
|
51
|
-
raw() {
|
|
52
|
-
return createBuiltinPlugin(name, this.
|
|
51
|
+
raw(compiler) {
|
|
52
|
+
return createBuiltinPlugin(name, resolve.apply(compiler, this._args));
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
// Make the plugin class name consistent with webpack
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RawCssExtractPluginOption } from "@rspack/binding";
|
|
2
|
-
import { Compiler } from "../..";
|
|
2
|
+
import type { Compiler } from "../..";
|
|
3
3
|
export * from "./loader";
|
|
4
4
|
export type { CssExtractRspackLoaderOptions } from "./loader";
|
|
5
5
|
export interface CssExtractRspackPluginOptions {
|
|
@@ -34,7 +34,12 @@ const loader = function loader(content) {
|
|
|
34
34
|
if (this._compiler &&
|
|
35
35
|
this._compiler.options &&
|
|
36
36
|
this._compiler.options.experiments &&
|
|
37
|
-
this._compiler.options.experiments.css
|
|
37
|
+
this._compiler.options.experiments.css &&
|
|
38
|
+
this._module &&
|
|
39
|
+
(this._module.type === "css" ||
|
|
40
|
+
this._module.type === "css/auto" ||
|
|
41
|
+
this._module.type === "css/global" ||
|
|
42
|
+
this._module.type === "css/module")) {
|
|
38
43
|
return content;
|
|
39
44
|
}
|
|
40
45
|
};
|
|
@@ -42,8 +47,13 @@ const pitch = function (request, _, data) {
|
|
|
42
47
|
if (this._compiler &&
|
|
43
48
|
this._compiler.options &&
|
|
44
49
|
this._compiler.options.experiments &&
|
|
45
|
-
this._compiler.options.experiments.css
|
|
46
|
-
|
|
50
|
+
this._compiler.options.experiments.css &&
|
|
51
|
+
this._module &&
|
|
52
|
+
(this._module.type === "css" ||
|
|
53
|
+
this._module.type === "css/auto" ||
|
|
54
|
+
this._module.type === "css/global" ||
|
|
55
|
+
this._module.type === "css/module")) {
|
|
56
|
+
const e = new Error(`use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`);
|
|
47
57
|
e.stack = undefined;
|
|
48
58
|
this.emitWarning(e);
|
|
49
59
|
return;
|
|
@@ -107,8 +117,8 @@ const pitch = function (request, _, data) {
|
|
|
107
117
|
const identifierCountMap = new Map();
|
|
108
118
|
dependencies = exports
|
|
109
119
|
.map(([id, content, media, sourceMap, supports, layer]) => {
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
const identifier = id;
|
|
121
|
+
const context = this.rootContext;
|
|
112
122
|
const count = identifierCountMap.get(identifier) || 0;
|
|
113
123
|
identifierCountMap.set(identifier, count + 1);
|
|
114
124
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoaderContext } from "../..";
|
|
1
|
+
import type { LoaderContext } from "../..";
|
|
2
2
|
export declare function isAbsolutePath(str: string): boolean;
|
|
3
3
|
export declare function isRelativePath(str: string): boolean;
|
|
4
4
|
export declare function stringifyRequest(loaderContext: LoaderContext, request: string): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { RspackBuiltinPlugin } from "./base";
|
|
1
2
|
export * from "./APIPlugin";
|
|
2
3
|
export * from "./ArrayPushCallbackChunkFormatPlugin";
|
|
3
4
|
export * from "./AssetModulesPlugin";
|
|
4
5
|
export * from "./AsyncWebAssemblyModulesPlugin";
|
|
5
6
|
export * from "./BannerPlugin";
|
|
6
|
-
export { RspackBuiltinPlugin } from "./base";
|
|
7
7
|
export * from "./BundlerInfoRspackPlugin";
|
|
8
8
|
export * from "./ChunkPrefetchPreloadPlugin";
|
|
9
9
|
export * from "./CommonJsChunkFormatPlugin";
|
|
@@ -63,9 +63,3 @@ export * from "./WarnCaseSensitiveModulesPlugin";
|
|
|
63
63
|
export * from "./WebWorkerTemplatePlugin";
|
|
64
64
|
export * from "./WorkerPlugin";
|
|
65
65
|
export * from "./FetchCompileAsyncWasmPlugin";
|
|
66
|
-
import { RawBuiltins } from "@rspack/binding";
|
|
67
|
-
import { RspackOptionsNormalized } from "..";
|
|
68
|
-
export interface Builtins {
|
|
69
|
-
treeShaking?: boolean | "module";
|
|
70
|
-
}
|
|
71
|
-
export declare function deprecated_resolveBuiltins(builtins: Builtins, options: RspackOptionsNormalized): RawBuiltins;
|
|
@@ -14,14 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.RspackBuiltinPlugin = void 0;
|
|
18
|
+
var base_1 = require("./base");
|
|
19
|
+
Object.defineProperty(exports, "RspackBuiltinPlugin", { enumerable: true, get: function () { return base_1.RspackBuiltinPlugin; } });
|
|
18
20
|
__exportStar(require("./APIPlugin"), exports);
|
|
19
21
|
__exportStar(require("./ArrayPushCallbackChunkFormatPlugin"), exports);
|
|
20
22
|
__exportStar(require("./AssetModulesPlugin"), exports);
|
|
21
23
|
__exportStar(require("./AsyncWebAssemblyModulesPlugin"), exports);
|
|
22
24
|
__exportStar(require("./BannerPlugin"), exports);
|
|
23
|
-
var base_1 = require("./base");
|
|
24
|
-
Object.defineProperty(exports, "RspackBuiltinPlugin", { enumerable: true, get: function () { return base_1.RspackBuiltinPlugin; } });
|
|
25
25
|
__exportStar(require("./BundlerInfoRspackPlugin"), exports);
|
|
26
26
|
__exportStar(require("./ChunkPrefetchPreloadPlugin"), exports);
|
|
27
27
|
__exportStar(require("./CommonJsChunkFormatPlugin"), exports);
|
|
@@ -81,17 +81,3 @@ __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
|
|
|
81
81
|
__exportStar(require("./WebWorkerTemplatePlugin"), exports);
|
|
82
82
|
__exportStar(require("./WorkerPlugin"), exports);
|
|
83
83
|
__exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
|
|
84
|
-
function resolveTreeShaking(treeShaking, production) {
|
|
85
|
-
return treeShaking !== undefined
|
|
86
|
-
? treeShaking.toString()
|
|
87
|
-
: production
|
|
88
|
-
? "true"
|
|
89
|
-
: "false";
|
|
90
|
-
}
|
|
91
|
-
function deprecated_resolveBuiltins(builtins, options) {
|
|
92
|
-
const production = options.mode === "production" || !options.mode;
|
|
93
|
-
return {
|
|
94
|
-
treeShaking: resolveTreeShaking(builtins.treeShaking, production)
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
exports.deprecated_resolveBuiltins = deprecated_resolveBuiltins;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuiltinPluginName, JsModule, RawRegex } from "@rspack/binding";
|
|
1
|
+
import { BuiltinPluginName, type JsModule, type RawRegex } from "@rspack/binding";
|
|
2
2
|
export declare const BuiltinLazyCompilationPlugin: {
|
|
3
3
|
new (module: (args: {
|
|
4
4
|
module: string;
|
|
@@ -9,22 +9,16 @@ export declare const BuiltinLazyCompilationPlugin: {
|
|
|
9
9
|
client: string;
|
|
10
10
|
}, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegex | ((m: JsModule) => boolean) | undefined): {
|
|
11
11
|
name: BuiltinPluginName;
|
|
12
|
-
|
|
13
|
-
module:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
imports: boolean;
|
|
23
|
-
entries: boolean;
|
|
24
|
-
test: RawRegex | ((m: JsModule) => boolean) | undefined;
|
|
25
|
-
};
|
|
26
|
-
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;
|
|
27
|
-
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
12
|
+
_args: [module: (args: {
|
|
13
|
+
module: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}) => {
|
|
16
|
+
active: boolean;
|
|
17
|
+
data: string;
|
|
18
|
+
client: string;
|
|
19
|
+
}, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegex | ((m: JsModule) => boolean) | undefined];
|
|
20
|
+
affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
21
|
+
raw(compiler: import("../../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
28
22
|
apply(compiler: import("../../Compiler").Compiler): void;
|
|
29
23
|
};
|
|
30
24
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { JsModule, RawRegex } from "@rspack/binding";
|
|
1
|
+
import type { JsModule, RawRegex } from "@rspack/binding";
|
|
2
2
|
import type { Compiler } from "../..";
|
|
3
|
-
import { LazyCompilationDefaultBackendOptions } from "./backend";
|
|
3
|
+
import { type LazyCompilationDefaultBackendOptions } from "./backend";
|
|
4
4
|
export default class LazyCompilationPlugin {
|
|
5
5
|
cacheable: boolean;
|
|
6
6
|
entries: boolean;
|
package/dist/config/adapter.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { RawLibraryOptions, RawOptions } from "@rspack/binding";
|
|
2
|
-
import { Compiler } from "../Compiler";
|
|
3
|
-
import { LoaderContext, LoaderDefinition, LoaderDefinitionFunction } from "./adapterRuleUse";
|
|
4
|
-
import { RspackOptionsNormalized } from "./normalization";
|
|
5
|
-
import { ChunkLoading, LibraryOptions } from "./zod";
|
|
2
|
+
import type { Compiler } from "../Compiler";
|
|
3
|
+
import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction } from "./adapterRuleUse";
|
|
4
|
+
import type { RspackOptionsNormalized } from "./normalization";
|
|
5
|
+
import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
|
|
6
6
|
export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
|
|
7
7
|
export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
|
|
8
|
+
export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];
|
|
8
9
|
export declare function getRawLibrary(library: LibraryOptions): RawLibraryOptions;
|
|
9
10
|
export declare function getRawChunkLoading(chunkLoading: ChunkLoading): string;
|
package/dist/config/adapter.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawOptions = void 0;
|
|
6
|
+
exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawResolve = exports.getRawOptions = void 0;
|
|
7
7
|
const assert_1 = __importDefault(require("assert"));
|
|
8
8
|
const Stats_1 = require("../Stats");
|
|
9
9
|
const util_1 = require("../util");
|
|
@@ -106,6 +106,7 @@ function getRawResolve(resolve) {
|
|
|
106
106
|
byDependency: getRawResolveByDependency(resolve.byDependency)
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
exports.getRawResolve = getRawResolve;
|
|
109
110
|
function getRawCrossOriginLoading(crossOriginLoading) {
|
|
110
111
|
if (typeof crossOriginLoading === "boolean") {
|
|
111
112
|
return { type: "bool", boolPayload: crossOriginLoading };
|
|
@@ -261,7 +262,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
261
262
|
}
|
|
262
263
|
let funcUse;
|
|
263
264
|
if (typeof rule.use === "function") {
|
|
264
|
-
|
|
265
|
+
const use = rule.use;
|
|
265
266
|
funcUse = (rawContext) => {
|
|
266
267
|
const context = {
|
|
267
268
|
...rawContext,
|
|
@@ -271,7 +272,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
271
272
|
return (0, adapterRuleUse_1.createRawModuleRuleUses)(uses ?? [], `${path}.use`, options);
|
|
272
273
|
};
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
const rawModuleRule = {
|
|
275
276
|
test: rule.test ? getRawRuleSetCondition(rule.test) : undefined,
|
|
276
277
|
include: rule.include ? getRawRuleSetCondition(rule.include) : undefined,
|
|
277
278
|
exclude: rule.exclude ? getRawRuleSetCondition(rule.exclude) : undefined,
|
|
@@ -325,7 +326,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
325
326
|
delete rawModuleRule.resource;
|
|
326
327
|
delete rawModuleRule.resourceQuery;
|
|
327
328
|
delete rawModuleRule.resourceFragment;
|
|
328
|
-
rawModuleRule.rspackResource = getRawRuleSetCondition(
|
|
329
|
+
rawModuleRule.rspackResource = getRawRuleSetCondition(resourceQueryFragment => {
|
|
329
330
|
const { path, query, fragment } = (0, identifier_1.parseResource)(resourceQueryFragment);
|
|
330
331
|
if (rule.test && !tryMatch(path, rule.test)) {
|
|
331
332
|
return false;
|
|
@@ -391,10 +392,14 @@ function getRawRuleSetLogicalConditions(logical) {
|
|
|
391
392
|
};
|
|
392
393
|
}
|
|
393
394
|
function getRawParserOptionsByModuleType(parser) {
|
|
394
|
-
return Object.fromEntries(Object.entries(parser)
|
|
395
|
+
return Object.fromEntries(Object.entries(parser)
|
|
396
|
+
.map(([k, v]) => [k, getRawParserOptions(v, k)])
|
|
397
|
+
.filter(([k, v]) => v !== undefined));
|
|
395
398
|
}
|
|
396
399
|
function getRawGeneratorOptionsByModuleType(parser) {
|
|
397
|
-
return Object.fromEntries(Object.entries(parser)
|
|
400
|
+
return Object.fromEntries(Object.entries(parser)
|
|
401
|
+
.map(([k, v]) => [k, getRawGeneratorOptions(v, k)])
|
|
402
|
+
.filter(([k, v]) => v !== undefined));
|
|
398
403
|
}
|
|
399
404
|
function getRawParserOptions(parser, type) {
|
|
400
405
|
if (type === "asset") {
|
|
@@ -404,10 +409,8 @@ function getRawParserOptions(parser, type) {
|
|
|
404
409
|
};
|
|
405
410
|
}
|
|
406
411
|
else if (type === "javascript") {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
javascript: getRawJavascriptParserOptions(parser)
|
|
410
|
-
};
|
|
412
|
+
// Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
|
|
413
|
+
return;
|
|
411
414
|
}
|
|
412
415
|
else if (type === "javascript/auto") {
|
|
413
416
|
return {
|
|
@@ -469,7 +472,8 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
469
472
|
? "false"
|
|
470
473
|
: parser.reexportExportsPresence,
|
|
471
474
|
strictExportPresence: parser.strictExportPresence ?? false,
|
|
472
|
-
worker: getRawJavascriptParserOptionsWorker(parser.worker)
|
|
475
|
+
worker: getRawJavascriptParserOptionsWorker(parser.worker),
|
|
476
|
+
overrideStrict: parser.overrideStrict
|
|
473
477
|
};
|
|
474
478
|
}
|
|
475
479
|
function getRawJavascriptParserOptionsWorker(worker) {
|
|
@@ -545,6 +549,14 @@ function getRawGeneratorOptions(generator, type) {
|
|
|
545
549
|
cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
|
|
546
550
|
};
|
|
547
551
|
}
|
|
552
|
+
if ([
|
|
553
|
+
"javascript",
|
|
554
|
+
"javascript/auto",
|
|
555
|
+
"javascript/dynamic",
|
|
556
|
+
"javascript/esm"
|
|
557
|
+
].includes(type)) {
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
548
560
|
throw new Error(`unreachable: unknow module type: ${type}`);
|
|
549
561
|
}
|
|
550
562
|
function getRawAssetGeneratorOptions(options) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { JsAssetInfo, RawModuleRuleUse, RawOptions } from "@rspack/binding";
|
|
3
|
-
import { ResolveRequest } from "../../compiled/enhanced-resolve";
|
|
4
|
-
import { Compiler } from "../Compiler";
|
|
5
|
-
import { Logger } from "../logging/Logger";
|
|
3
|
+
import type { ResolveRequest } from "../../compiled/enhanced-resolve";
|
|
4
|
+
import type { Compiler } from "../Compiler";
|
|
5
|
+
import type { Logger } from "../logging/Logger";
|
|
6
6
|
import Hash = require("../util/hash");
|
|
7
|
-
import { Compilation } from "../Compilation";
|
|
8
|
-
import { Module } from "../Module";
|
|
9
|
-
import { LoaderObject } from "../loader-runner";
|
|
10
|
-
import { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
|
|
7
|
+
import type { Compilation } from "../Compilation";
|
|
8
|
+
import type { Module } from "../Module";
|
|
9
|
+
import { type LoaderObject } from "../loader-runner";
|
|
10
|
+
import type { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
|
|
11
11
|
export declare const BUILTIN_LOADER_PREFIX = "builtin:";
|
|
12
12
|
export interface ComposeJsUseOptions {
|
|
13
13
|
devtool: RawOptions["devtool"];
|
|
@@ -15,7 +15,7 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
15
15
|
exports.createRawModuleRuleUses = createRawModuleRuleUses;
|
|
16
16
|
const getSwcLoaderOptions = (o, options) => {
|
|
17
17
|
if (o && typeof o === "object" && o.rspackExperiments) {
|
|
18
|
-
|
|
18
|
+
const expr = o.rspackExperiments;
|
|
19
19
|
if (expr.import || expr.pluginImport) {
|
|
20
20
|
expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
|
|
21
21
|
}
|
|
@@ -83,7 +83,7 @@ const resolve = browsers => {
|
|
|
83
83
|
const [parsedMajor, parserMinor] =
|
|
84
84
|
// safari TP supports all features for normal safari
|
|
85
85
|
parsedVersion === "TP"
|
|
86
|
-
? [
|
|
86
|
+
? [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
|
|
87
87
|
: parsedVersion.includes("-")
|
|
88
88
|
? parsedVersion.split("-")[0].split(".")
|
|
89
89
|
: parsedVersion.split(".");
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
import { RspackOptionsNormalized } from "./normalization";
|
|
10
|
+
import type { RspackOptionsNormalized } from "./normalization";
|
|
11
11
|
export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => void;
|
|
12
12
|
export declare const applyRspackOptionsBaseDefaults: (options: RspackOptionsNormalized) => void;
|
package/dist/config/defaults.js
CHANGED
|
@@ -30,7 +30,7 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
30
30
|
});
|
|
31
31
|
const { mode, target } = options;
|
|
32
32
|
(0, assert_1.default)(!(0, util_1.isNil)(target));
|
|
33
|
-
|
|
33
|
+
const targetProperties = target === false
|
|
34
34
|
? false
|
|
35
35
|
: typeof target === "string"
|
|
36
36
|
? (0, target_1.getTargetProperties)(target, options.context)
|
|
@@ -151,6 +151,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
|
|
|
151
151
|
D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
|
|
152
152
|
D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
|
|
153
153
|
D(parserOptions, "worker", fallback?.worker ?? ["..."]);
|
|
154
|
+
D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
|
|
154
155
|
};
|
|
155
156
|
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
156
157
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
@@ -726,8 +727,8 @@ const applyOptimizationDefaults = (optimization, { production, development, css
|
|
|
726
727
|
F(splitChunks, "minSize", () => (production ? 20000 : 10000));
|
|
727
728
|
// F(splitChunks, "minRemainingSize", () => (development ? 0 : undefined));
|
|
728
729
|
// F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000));
|
|
729
|
-
F(splitChunks, "maxAsyncRequests", () =>
|
|
730
|
-
F(splitChunks, "maxInitialRequests", () =>
|
|
730
|
+
F(splitChunks, "maxAsyncRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
|
|
731
|
+
F(splitChunks, "maxInitialRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
|
|
731
732
|
D(splitChunks, "automaticNameDelimiter", "-");
|
|
732
733
|
const { cacheGroups } = splitChunks;
|
|
733
734
|
if (cacheGroups) {
|