@rspack/core 0.7.0-canary-c216972-20240528031643 → 0.7.0-canary-7e3a2e5-20240529004417
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/config/adapterRuleUse.d.ts +2 -1
- package/dist/config/defaults.js +26 -0
- package/dist/config/normalization.d.ts +2 -1
- package/dist/config/normalization.js +1 -0
- package/dist/config/zod.d.ts +5 -0
- package/dist/config/zod.js +2 -0
- package/dist/loader-runner/index.js +1 -0
- package/package.json +4 -4
|
@@ -5,7 +5,7 @@ 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
|
-
import { Mode, Resolve, RuleSetUseItem } from "./zod";
|
|
8
|
+
import { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
|
|
9
9
|
export interface ComposeJsUseOptions {
|
|
10
10
|
devtool: RawOptions["devtool"];
|
|
11
11
|
context: RawOptions["context"];
|
|
@@ -76,6 +76,7 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
76
76
|
*/
|
|
77
77
|
loaders: LoaderObject[];
|
|
78
78
|
mode?: Mode;
|
|
79
|
+
target?: Target;
|
|
79
80
|
hot?: boolean;
|
|
80
81
|
/**
|
|
81
82
|
* @param schema To provide the best performance, Rspack does not perform the schema validation. If your loader requires schema validation, please call scheme-utils or zod on your own.
|
package/dist/config/defaults.js
CHANGED
|
@@ -82,6 +82,10 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
82
82
|
: "var";
|
|
83
83
|
});
|
|
84
84
|
applyNodeDefaults(options.node, { targetProperties });
|
|
85
|
+
applyLoaderDefaults(options.loader, {
|
|
86
|
+
targetProperties,
|
|
87
|
+
environment: options.output.environment
|
|
88
|
+
});
|
|
85
89
|
F(options, "performance", () => production &&
|
|
86
90
|
targetProperties &&
|
|
87
91
|
(targetProperties.browser || targetProperties.browser === null)
|
|
@@ -600,6 +604,28 @@ const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) =
|
|
|
600
604
|
targetProperties.electron &&
|
|
601
605
|
targetProperties.electronRenderer);
|
|
602
606
|
};
|
|
607
|
+
const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
|
|
608
|
+
F(loader, "target", () => {
|
|
609
|
+
if (targetProperties) {
|
|
610
|
+
if (targetProperties.electron) {
|
|
611
|
+
if (targetProperties.electronMain)
|
|
612
|
+
return "electron-main";
|
|
613
|
+
if (targetProperties.electronPreload)
|
|
614
|
+
return "electron-preload";
|
|
615
|
+
if (targetProperties.electronRenderer)
|
|
616
|
+
return "electron-renderer";
|
|
617
|
+
return "electron";
|
|
618
|
+
}
|
|
619
|
+
if (targetProperties.nwjs)
|
|
620
|
+
return "nwjs";
|
|
621
|
+
if (targetProperties.node)
|
|
622
|
+
return "node";
|
|
623
|
+
if (targetProperties.web)
|
|
624
|
+
return "web";
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
D(loader, "environment", environment);
|
|
628
|
+
};
|
|
603
629
|
const applyNodeDefaults = (node, { targetProperties }) => {
|
|
604
630
|
if (node === false)
|
|
605
631
|
return;
|
|
@@ -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, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LazyCompilationOptions, 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, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Loader, 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";
|
|
12
12
|
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
|
|
13
13
|
export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
|
|
14
14
|
export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
|
|
@@ -110,6 +110,7 @@ export interface RspackOptionsNormalized {
|
|
|
110
110
|
infrastructureLogging: InfrastructureLogging;
|
|
111
111
|
devtool?: DevTool;
|
|
112
112
|
node: Node;
|
|
113
|
+
loader: Loader;
|
|
113
114
|
snapshot: SnapshotOptions;
|
|
114
115
|
cache?: CacheOptions;
|
|
115
116
|
stats: StatsValue;
|
|
@@ -144,6 +144,7 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
144
144
|
node: nestedConfig(config.node, node => node && {
|
|
145
145
|
...node
|
|
146
146
|
}),
|
|
147
|
+
loader: cloneObject(config.loader),
|
|
147
148
|
snapshot: nestedConfig(config.snapshot, _snapshot => ({})),
|
|
148
149
|
cache: optionalNestedConfig(config.cache, cache => cache),
|
|
149
150
|
stats: nestedConfig(config.stats, stats => {
|
package/dist/config/zod.d.ts
CHANGED
|
@@ -3747,6 +3747,8 @@ declare const node: z.ZodUnion<[z.ZodLiteral<false>, z.ZodObject<{
|
|
|
3747
3747
|
global?: boolean | "warn" | undefined;
|
|
3748
3748
|
}>]>;
|
|
3749
3749
|
export type Node = z.infer<typeof node>;
|
|
3750
|
+
declare const loader: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
3751
|
+
export type Loader = z.infer<typeof loader>;
|
|
3750
3752
|
declare const snapshotOptions: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
3751
3753
|
export type SnapshotOptions = z.infer<typeof snapshotOptions>;
|
|
3752
3754
|
declare const cacheOptions: z.ZodBoolean;
|
|
@@ -5538,6 +5540,7 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
5538
5540
|
__filename?: boolean | "warn-mock" | "mock" | "eval-only" | undefined;
|
|
5539
5541
|
global?: boolean | "warn" | undefined;
|
|
5540
5542
|
}>]>>;
|
|
5543
|
+
loader: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
5541
5544
|
ignoreWarnings: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodType<Error, z.ZodTypeDef, Error>, z.ZodType<Compilation, z.ZodTypeDef, Compilation>], z.ZodUnknown>, z.ZodBoolean>]>, "many">>;
|
|
5542
5545
|
watchOptions: z.ZodOptional<z.ZodObject<{
|
|
5543
5546
|
aggregateTimeout: z.ZodOptional<z.ZodNumber>;
|
|
@@ -6872,6 +6875,7 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
6872
6875
|
__filename?: boolean | "warn-mock" | "mock" | "eval-only" | undefined;
|
|
6873
6876
|
global?: boolean | "warn" | undefined;
|
|
6874
6877
|
} | undefined;
|
|
6878
|
+
loader?: Record<string, any> | undefined;
|
|
6875
6879
|
ignoreWarnings?: (RegExp | ((args_0: Error, args_1: Compilation, ...args_2: unknown[]) => boolean))[] | undefined;
|
|
6876
6880
|
watchOptions?: {
|
|
6877
6881
|
aggregateTimeout?: number | undefined;
|
|
@@ -7304,6 +7308,7 @@ export declare const rspackOptions: z.ZodObject<{
|
|
|
7304
7308
|
__filename?: boolean | "warn-mock" | "mock" | "eval-only" | undefined;
|
|
7305
7309
|
global?: boolean | "warn" | undefined;
|
|
7306
7310
|
} | undefined;
|
|
7311
|
+
loader?: Record<string, any> | undefined;
|
|
7307
7312
|
ignoreWarnings?: (RegExp | ((args_0: Error, args_1: Compilation, ...args_2: unknown[]) => boolean))[] | undefined;
|
|
7308
7313
|
watchOptions?: {
|
|
7309
7314
|
aggregateTimeout?: number | undefined;
|
package/dist/config/zod.js
CHANGED
|
@@ -585,6 +585,7 @@ const nodeOptions = zod_1.z.strictObject({
|
|
|
585
585
|
global: zod_1.z.boolean().or(zod_1.z.literal("warn")).optional()
|
|
586
586
|
});
|
|
587
587
|
const node = zod_1.z.literal(false).or(nodeOptions);
|
|
588
|
+
const loader = zod_1.z.record(zod_1.z.string(), zod_1.z.any());
|
|
588
589
|
//#endregion
|
|
589
590
|
//#region Snapshot
|
|
590
591
|
const snapshotOptions = zod_1.z.strictObject({});
|
|
@@ -828,6 +829,7 @@ exports.rspackOptions = zod_1.z.strictObject({
|
|
|
828
829
|
context: context.optional(),
|
|
829
830
|
devtool: devTool.optional(),
|
|
830
831
|
node: node.optional(),
|
|
832
|
+
loader: loader.optional(),
|
|
831
833
|
ignoreWarnings: ignoreWarnings.optional(),
|
|
832
834
|
watchOptions: watchOptions.optional(),
|
|
833
835
|
watch: watch.optional(),
|
|
@@ -339,6 +339,7 @@ async function runLoaders(compiler, rawContext) {
|
|
|
339
339
|
? (0, adapterRuleUse_1.isUseSourceMap)(compiler.options.devtool)
|
|
340
340
|
: false;
|
|
341
341
|
loaderContext.mode = compiler.options.mode;
|
|
342
|
+
Object.assign(loaderContext, compiler.options.loader);
|
|
342
343
|
const getResolveContext = () => {
|
|
343
344
|
// FIXME: resolve's fileDependencies will includes lots of dir, '/', etc
|
|
344
345
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.7.0-canary-
|
|
3
|
+
"version": "0.7.0-canary-7e3a2e5-20240529004417",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -72,15 +72,15 @@
|
|
|
72
72
|
"watchpack": "^2.4.0",
|
|
73
73
|
"zod": "^3.21.4",
|
|
74
74
|
"zod-validation-error": "1.3.1",
|
|
75
|
-
"@rspack/core": "0.7.0-canary-
|
|
76
|
-
"@rspack/plugin-minify": "^0.7.0-canary-
|
|
75
|
+
"@rspack/core": "0.7.0-canary-7e3a2e5-20240529004417",
|
|
76
|
+
"@rspack/plugin-minify": "^0.7.0-canary-7e3a2e5-20240529004417"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@module-federation/runtime-tools": "0.1.6",
|
|
80
80
|
"caniuse-lite": "^1.0.30001616",
|
|
81
81
|
"tapable": "2.2.1",
|
|
82
82
|
"webpack-sources": "3.2.3",
|
|
83
|
-
"@rspack/binding": "0.7.0-canary-
|
|
83
|
+
"@rspack/binding": "0.7.0-canary-7e3a2e5-20240529004417"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@swc/helpers": ">=0.5.1"
|