Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

8
node_modules/@rspack/core/dist/config/adapter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { type RawOptions } from "@rspack/binding";
import type { Compiler } from "../Compiler";
import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction, type PitchLoaderDefinitionFunction } from "./adapterRuleUse";
import type { RspackOptionsNormalized } from "./normalization";
import type { Resolve } from "./types";
export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction, PitchLoaderDefinitionFunction };
export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];

View File

@@ -0,0 +1,391 @@
import type { AssetInfo, RawModuleRuleUse, RawOptions } from "@rspack/binding";
import type { Compilation } from "../Compilation";
import type { Compiler } from "../Compiler";
import { type LoaderObject } from "../loader-runner";
import type { Logger } from "../logging/Logger";
import type { Module } from "../Module";
import type { ResolveRequest } from "../Resolver";
import type Hash from "../util/hash";
import type { RspackOptionsNormalized } from "./normalization";
import type { Mode, PublicPath, Resolve, RuleSetUseItem, Target } from "./types";
export declare const BUILTIN_LOADER_PREFIX = "builtin:";
export interface ComposeJsUseOptions {
context: RawOptions["context"];
mode: RawOptions["mode"];
experiments: RawOptions["experiments"];
compiler: Compiler;
}
export interface RawSourceMap {
/**
* The version of the source map format, always 3
*/
version: number;
/**
* A list of original sources used by the mappings field
*/
sources: string[];
/**
* A string with the encoded mapping data
*/
mappings: string;
/**
* The filename of the generated code that this source map is associated with
*/
file: string;
/**
* An optional source root string, used for relocating source files on a server
* or removing repeated values in the sources entry.
*/
sourceRoot?: string;
/**
* An array containing the actual content of the original source files
*/
sourcesContent?: string[];
/**
* A list of symbol names which may be used by the mappings field.
*/
names: string[];
/**
* A unique identifier for debugging purposes
*/
debugId?: string;
/**
* An array of indices into the sources array, indicating which sources
* should be ignored by debuggers
*/
ignoreList?: number[];
}
export interface AdditionalData {
[index: string]: any;
}
export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => void;
export type ErrorWithDetails = Error & {
details?: string;
};
export type ResolveCallback = (err: null | ErrorWithDetails, res?: string | false, req?: ResolveRequest) => void;
export interface DiagnosticLocation {
/** Text for highlighting the location */
text?: string;
/** 1-based line */
line: number;
/** 0-based column in bytes */
column: number;
/** Length in bytes */
length: number;
}
export interface Diagnostic {
message: string;
help?: string;
sourceCode?: string;
/**
* Location to the source code.
* If `sourceCode` is not provided, location will be omitted.
*/
location?: DiagnosticLocation;
/**
* Optional filename to show.
* If provided, it becomes the `StatsError.file` value in stats.
*/
file?: string;
severity: "error" | "warning";
}
export interface LoaderExperiments {
emitDiagnostic(diagnostic: Diagnostic): void;
}
export interface ImportModuleOptions {
/**
* Specify a layer in which this module is placed/compiled
*/
layer?: string;
/**
* The public path used for the built modules
*/
publicPath?: PublicPath;
/**
* Target base uri
*/
baseUri?: string;
}
export interface LoaderContext<OptionsType = {}> {
/**
* The version number of the loader API. Currently 2.
* This is useful for providing backwards compatibility. Using the version you can specify
* custom logic or fallbacks for breaking changes.
*/
version: 2;
/**
* The path string of the current module.
* @example `'/abc/resource.js?query#hash'`.
*/
resource: string;
/**
* The path string of the current module, excluding the query and fragment parameters.
* @example `'/abc/resource.js?query#hash'` in `'/abc/resource.js'`.
*/
resourcePath: string;
/**
* The query parameter for the path string of the current module.
* @example `'?query'` in `'/abc/resource.js?query#hash'`.
*/
resourceQuery: string;
/**
* The fragment parameter of the current module's path string.
* @example `'#hash'` in `'/abc/resource.js?query#hash'`.
*/
resourceFragment: string;
/**
* Tells Rspack that this loader will be called asynchronously. Returns `this.callback`.
*/
async(): LoaderContextCallback;
/**
* A function that can be called synchronously or asynchronously in order to return multiple
* results. The expected arguments are:
*
* 1. The first parameter must be `Error` or `null`, which marks the current module as a
* compilation failure.
* 2. The second argument is a `string` or `Buffer`, which indicates the contents of the file
* after the module has been processed by the loader.
* 3. The third parameter is a source map that can be processed by the loader.
* 4. The fourth parameter is ignored by Rspack and can be anything (e.g. some metadata).
*/
callback: LoaderContextCallback;
/**
* A function that sets the cacheable flag.
* By default, the processing results of the loader are marked as cacheable.
* Calling this method and passing `false` turns off the loader's ability to
* cache processing results.
*/
cacheable(cacheable?: boolean): void;
/**
* Tells if source map should be generated. Since generating source maps can be an expensive task,
* you should check if source maps are actually requested.
*/
sourceMap: boolean;
/**
* The base path configured in Rspack config via `context`.
*/
rootContext: string;
/**
* The directory path of the currently processed module, which changes with the
* location of each processed module.
* For example, if the loader is processing `/project/src/components/Button.js`,
* then the value of `this.context` would be `/project/src/components`.
*/
context: string | null;
/**
* The index in the loaders array of the current loader.
*/
loaderIndex: number;
remainingRequest: string;
currentRequest: string;
previousRequest: string;
/**
* The module specifier string after being resolved.
* For example, if a `resource.js` is processed by `loader1.js` and `loader2.js`, the value of
* `this.request` will be `/path/to/loader1.js!/path/to/loader2.js!/path/to/resource.js`.
*/
request: string;
/**
* An array of all the loaders. It is writeable in the pitch phase.
* loaders = [{request: string, path: string, query: string, module: function}]
*
* In the example:
* [
* { request: "/abc/loader1.js?xyz",
* path: "/abc/loader1.js",
* query: "?xyz",
* module: [Function]
* },
* { request: "/abc/node_modules/loader2/index.js",
* path: "/abc/node_modules/loader2/index.js",
* query: "",
* module: [Function]
* }
* ]
*/
loaders: LoaderObject[];
/**
* The value of `mode` is read when Rspack is run.
* The possible values are: `'production'`, `'development'`, `'none'`
*/
mode?: Mode;
/**
* The current compilation target. Passed from `target` configuration options.
*/
target?: Target;
/**
* Whether HMR is enabled.
*/
hot?: boolean;
/**
* Get the options passed in by the loader's user.
* @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.
*/
getOptions(schema?: any): OptionsType;
/**
* Resolve a module specifier.
* @param context The absolute path to a directory. This directory is used as the starting
* location for resolving.
* @param request The module specifier to be resolved.
* @param callback A callback function that gives the resolved path.
*/
resolve(context: string, request: string, callback: (arg0: null | Error, arg1?: string | false, arg2?: ResolveRequest) => void): void;
/**
* Create a resolver like `this.resolve`.
*/
getResolve(options: Resolve): ((context: string, request: string, callback: ResolveCallback) => void) | ((context: string, request: string) => Promise<string | false | undefined>);
/**
* Get the logger of this compilation, through which messages can be logged.
*/
getLogger(name: string): Logger;
/**
* Emit an error. Unlike `throw` and `this.callback(err)` in the loader, it does not
* mark the current module as a compilation failure, it just adds an error to Rspack's
* Compilation and displays it on the command line at the end of this compilation.
*/
emitError(error: Error): void;
/**
* Emit a warning.
*/
emitWarning(warning: Error): void;
/**
* Emit a new file. This method allows you to create new files during the loader execution.
*/
emitFile(name: string, content: string | Buffer, sourceMap?: string, assetInfo?: AssetInfo): void;
/**
* Add a file as a dependency on the loader results so that any changes to them can be listened to.
* For example, `sass-loader`, `less-loader` use this trick to recompile when the imported style
* files change.
*/
addDependency(file: string): void;
/**
* Alias of `this.addDependency()`.
*/
dependency(file: string): void;
/**
* Add the directory as a dependency for the loader results so that any changes to the
* files in the directory can be listened to.
*/
addContextDependency(context: string): void;
/**
* Add a currently non-existent file as a dependency of the loader result, so that its
* creation and any changes can be listened. For example, when a new file is created at
* that path, it will trigger a rebuild.
*/
addMissingDependency(missing: string): void;
/**
* Removes all dependencies of the loader result.
*/
clearDependencies(): void;
getDependencies(): string[];
getContextDependencies(): string[];
getMissingDependencies(): string[];
addBuildDependency(file: string): void;
/**
* Compile and execute a module at the build time.
* This is an alternative lightweight solution for the child compiler.
* `importModule` will return a Promise if no callback is provided.
*
* @example
* ```ts
* const modulePath = path.resolve(__dirname, 'some-module.ts');
* const moduleExports = await this.importModule(modulePath, {
* // optional options
* });
* ```
*/
importModule<T = any>(request: string, options: ImportModuleOptions | undefined, callback: (err?: null | Error, exports?: T) => any): void;
importModule<T = any>(request: string, options?: ImportModuleOptions): Promise<T>;
/**
* Access to the `compilation` object's `inputFileSystem` property.
*/
fs: any;
/**
* This is an experimental API and maybe subject to change.
* @experimental
*/
experiments: LoaderExperiments;
/**
* Access to some utilities.
*/
utils: {
/**
* Return a new request string using absolute paths when possible.
*/
absolutify: (context: string, request: string) => string;
/**
* Return a new request string avoiding absolute paths when possible.
*/
contextify: (context: string, request: string) => string;
/**
* Return a new Hash object from provided hash function.
*/
createHash: (algorithm?: string) => Hash;
};
/**
* The value depends on the loader configuration:
* - If the current loader was configured with an options object, `this.query` will
* point to that object.
* - If the current loader has no options, but was invoked with a query string, this
* will be a string starting with `?`.
*/
query: string | OptionsType;
/**
* A data object shared between the pitch and the normal phase.
*/
data: unknown;
/**
* Access to the current Compiler object of Rspack.
*/
_compiler: Compiler;
/**
* Access to the current Compilation object of Rspack.
*/
_compilation: Compilation;
/**
* @deprecated Hacky access to the Module object being loaded.
*/
_module: Module;
/**
* Note: This is not a Rspack public API, maybe removed in future.
* Store some data from loader, and consume it from parser, it may be removed in the future
*
* @internal
*/
__internal__setParseMeta: (key: string, value: string) => void;
}
export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer | void>;
export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer | void>;
/**
* Defines a loader for Rspack.
* A loader is a transformer that converts various types of modules into Rspack
* supported types. By using different kinds of loaders, you can extend Rspack to
* process additional module types, including JSX, Markdown, Sass, Less, and more.
*
* @template OptionsType - The type of options that the loader accepts
* @template ContextAdditions - Additional properties to add to the loader context
*
* @example
* ```ts
* import type { LoaderDefinition } from '@rspack/core';
*
* type MyLoaderOptions = {
* foo: string;
* };
*
* const myLoader: LoaderDefinition<MyLoaderOptions> = function(source) {
* return someOperation(source);
* };
*
* export default myLoader;
* ```
*/
export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDefinitionFunction<OptionsType, ContextAdditions> & {
raw?: false;
pitch?: PitchLoaderDefinitionFunction;
};
export declare function createRawModuleRuleUses(uses: RuleSetUseItem | RuleSetUseItem[], path: string, options: ComposeJsUseOptions): RawModuleRuleUse[];
export declare function isUseSourceMap(devtool: RspackOptionsNormalized["devtool"]): boolean;
export declare function isUseSimpleSourceMap(devtool: RspackOptionsNormalized["devtool"]): boolean;

View File

@@ -0,0 +1,15 @@
/**
* The following code is modified based on
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/browserslistTargetHandler.js
*
* MIT Licensed
* Author Sergey Melyukov @smelukov
* Copyright (c) JS Foundation and other contributors
* https://github.com/webpack/webpack/blob/main/LICENSE
*/
import type { ApiTargetProperties, EcmaTargetProperties, PlatformTargetProperties } from "./target";
/**
* @param browsers supported browsers list
* @returns target properties
*/
export declare const resolve: (browsers: string[]) => EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties;

4
node_modules/@rspack/core/dist/config/defaults.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { RspackOptionsNormalized } from "./normalization";
export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => void;
export declare const applyRspackOptionsBaseDefaults: (options: RspackOptionsNormalized) => void;
export declare const getPnpDefault: () => boolean;

314
node_modules/@rspack/core/dist/config/devServer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,314 @@
/**
* The following code is modified based on
* https://github.com/webpack/webpack-dev-server/blob/6045b1e9d63078fb24cac52eb361b7356944cddd/types/lib/Server.d.ts
*
* MIT Licensed
* Author Tobias Koppers @sokra
* Copyright (c) JS Foundation and other contributors
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
*/
import type * as http from "node:http";
import type * as net from "node:net";
import type * as stream from "node:stream";
import type * as url from "node:url";
import type { Compiler, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from "..";
type Logger = ReturnType<Compiler["getInfrastructureLogger"]>;
type MultiWatching = MultiCompiler["watch"];
type BasicServer = import("net").Server | import("tls").Server;
type ReadStream = import("fs").ReadStream;
type IncomingMessage = import("http").IncomingMessage;
type ServerResponse = import("http").ServerResponse;
type ServerOptions = import("https").ServerOptions & {
spdy?: {
plain?: boolean | undefined;
ssl?: boolean | undefined;
"x-forwarded-for"?: string | undefined;
protocol?: string | undefined;
protocols?: string[] | undefined;
};
};
type ResponseData = {
data: Buffer | ReadStream;
byteLength: number;
};
type ModifyResponseData<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, data: Buffer | ReadStream, byteLength: number) => ResponseData;
type Headers = {
key: string;
value: string;
}[] | Record<string, string | string[]>;
type OutputFileSystem = import("..").OutputFileSystem & {
statSync: import("fs").StatSyncFn;
readFileSync: typeof import("fs").readFileSync;
};
type RspackConfiguration = import("..").Configuration;
type Port = number | LiteralUnion<"auto", string>;
type HistoryContext = {
readonly match: RegExpMatchArray;
readonly parsedUrl: import("url").Url;
readonly request: any;
};
type RewriteTo = (context: HistoryContext) => string;
type Rewrite = {
readonly from: RegExp;
readonly to: string | RegExp | RewriteTo;
};
type HistoryApiFallbackOptions = {
readonly disableDotRule?: true | undefined;
readonly htmlAcceptHeaders?: readonly string[] | undefined;
readonly index?: string | undefined;
readonly logger?: typeof console.log | undefined;
readonly rewrites?: readonly Rewrite[] | undefined;
readonly verbose?: boolean | undefined;
};
type DevMiddlewareOptions<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = {
mimeTypes?: {
[key: string]: string;
} | undefined;
mimeTypeDefault?: string | undefined;
writeToDisk?: boolean | ((targetPath: string) => boolean) | undefined;
methods?: string[] | undefined;
headers?: any;
publicPath?: NonNullable<RspackConfiguration["output"]>["publicPath"];
stats?: RspackConfiguration["stats"];
serverSideRender?: boolean | undefined;
outputFileSystem?: OutputFileSystem | undefined;
index?: string | boolean | undefined;
modifyResponseData?: ModifyResponseData<RequestInternal, ResponseInternal> | undefined;
etag?: "strong" | "weak" | undefined;
lastModified?: boolean | undefined;
cacheControl?: string | number | boolean | {
maxAge?: number;
immutable?: boolean;
} | undefined;
cacheImmutable?: boolean | undefined;
};
type BasicApplication = any;
type BonjourServer = Record<string, any>;
type ChokidarWatchOptions = {
[key: string]: any;
};
type ServeIndexOptions = {
[key: string]: any;
};
type ServeStaticOptions = {
[key: string]: any;
};
type HttpProxyMiddlewareOptionsFilter = any;
type Request = IncomingMessage;
type Response = ServerResponse;
type WatchFiles = {
paths: string | string[];
options?: (ChokidarWatchOptions & {
aggregateTimeout?: number;
ignored?: ChokidarWatchOptions["ignored"];
poll?: number | boolean;
}) | undefined;
};
type Static = {
directory?: string | undefined;
publicPath?: string | string[] | undefined;
serveIndex?: boolean | ServeIndexOptions | undefined;
staticOptions?: ServeStaticOptions | undefined;
watch?: boolean | (ChokidarWatchOptions & {
aggregateTimeout?: number;
ignored?: ChokidarWatchOptions["ignored"];
poll?: number | boolean;
}) | undefined;
};
type ServerType<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = LiteralUnion<"http" | "https" | "spdy" | "http2", string> | ((arg0: ServerOptions, arg1: A) => S);
type ServerConfiguration<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = {
type?: ServerType<A, S> | undefined;
options?: ServerOptions | undefined;
};
type WebSocketServerConfiguration = {
type?: string | Function | undefined;
options?: Record<string, any> | undefined;
};
type NextFunction = (err?: any) => void;
type ProxyConfigArrayItem = {
path?: HttpProxyMiddlewareOptionsFilter;
context?: HttpProxyMiddlewareOptionsFilter;
} & {
bypass?: ByPass;
} & HttpProxyMiddlewareOptions;
type ByPass = (req: Request, res: Response, proxyConfig: ProxyConfigArrayItem) => any;
type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request, res?: Response, next?: NextFunction) => ProxyConfigArrayItem))[];
type Callback = (stats?: Stats | MultiStats) => any;
type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMessage, _ResponseInternal extends ServerResponse = ServerResponse> = {
state: boolean;
stats: Stats | MultiStats | undefined;
callbacks: Callback[];
options: any;
compiler: Compiler | MultiCompiler;
watching: Watching | MultiWatching | undefined;
logger: Logger;
outputFileSystem: OutputFileSystem;
};
type Server = any;
export type MiddlewareHandler<RequestInternal extends Request = Request, ResponseInternal extends Response = Response> = (req: RequestInternal, res: ResponseInternal, next: NextFunction) => void | Promise<void>;
type MiddlewareObject<RequestInternal extends Request = Request, ResponseInternal extends Response = Response> = {
name?: string;
path?: string;
middleware: MiddlewareHandler<RequestInternal, ResponseInternal>;
};
export type Middleware<RequestInternal extends Request = Request, ResponseInternal extends Response = Response> = MiddlewareObject<RequestInternal, ResponseInternal> | MiddlewareHandler<RequestInternal, ResponseInternal>;
type OpenApp = {
name?: string | undefined;
arguments?: string[] | undefined;
};
type Open = {
app?: string | string[] | OpenApp | undefined;
target?: string | string[] | undefined;
};
type OverlayMessageOptions = boolean | ((error: Error) => void);
type WebSocketURL = {
hostname?: string | undefined;
password?: string | undefined;
pathname?: string | undefined;
port?: string | number | undefined;
protocol?: string | undefined;
username?: string | undefined;
};
type ClientConfiguration = {
logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined;
overlay?: boolean | {
warnings?: OverlayMessageOptions;
errors?: OverlayMessageOptions;
runtimeErrors?: OverlayMessageOptions;
} | undefined;
progress?: boolean | undefined;
reconnect?: number | boolean | undefined;
webSocketTransport?: string | undefined;
webSocketURL?: string | WebSocketURL | undefined;
};
export type DevServerOptions<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = {
ipc?: string | boolean | undefined;
host?: string | undefined;
port?: Port | undefined;
hot?: boolean | "only" | undefined;
liveReload?: boolean | undefined;
devMiddleware?: DevMiddlewareOptions | undefined;
compress?: boolean | undefined;
allowedHosts?: string | string[] | undefined;
historyApiFallback?: boolean | HistoryApiFallbackOptions | undefined;
bonjour?: boolean | BonjourServer | undefined;
watchFiles?: string | string[] | WatchFiles | (string | WatchFiles)[] | undefined;
static?: string | boolean | Static | (string | Static)[] | undefined;
server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
app?: (() => Promise<A>) | undefined;
webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
proxy?: ProxyConfigArray | undefined;
open?: string | boolean | Open | (string | Open)[] | undefined;
setupExitSignals?: boolean | undefined;
client?: boolean | ClientConfiguration | undefined;
headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext | undefined) => Headers) | undefined;
onListening?: ((devServer: Server) => void) | undefined;
setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
};
interface HttpProxyMiddlewareOptions extends HttpProxyServerOptions {
pathRewrite?: {
[regexp: string]: string;
} | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
router?: {
[hostOrPath: string]: HttpProxyServerOptions["target"];
} | ((req: Request) => HttpProxyServerOptions["target"]) | ((req: Request) => Promise<HttpProxyServerOptions["target"]>);
logLevel?: "debug" | "info" | "warn" | "error" | "silent";
logProvider?: LogProviderCallback;
onError?: OnErrorCallback;
onProxyRes?: OnProxyResCallback;
onProxyReq?: OnProxyReqCallback;
onProxyReqWs?: OnProxyReqWsCallback;
onOpen?: OnOpenCallback;
onClose?: OnCloseCallback;
}
interface LogProvider {
log: Logger;
debug?: Logger;
info?: Logger;
warn?: Logger;
error?: Logger;
}
type LogProviderCallback = (provider: LogProvider) => LogProvider;
type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: HttpProxyServerOptions) => void;
type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: HttpProxyServerOptions, head: any) => void;
type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
type OnOpenCallback = (proxySocket: net.Socket) => void;
interface HttpProxyServerOptions {
/** URL string to be parsed with the url module. */
target?: HttpProxyTarget | undefined;
/** URL string to be parsed with the url module. */
forward?: HttpProxyTargetUrl | undefined;
/** Object to be passed to http(s).request. */
agent?: any;
/** Object to be passed to https.createServer(). */
ssl?: any;
/** If you want to proxy websockets. */
ws?: boolean | undefined;
/** Adds x- forward headers. */
xfwd?: boolean | undefined;
/** Verify SSL certificate. */
secure?: boolean | undefined;
/** Explicitly specify if we are proxying to another proxy. */
toProxy?: boolean | undefined;
/** Specify whether you want to prepend the target's path to the proxy path. */
prependPath?: boolean | undefined;
/** Specify whether you want to ignore the proxy path of the incoming request. */
ignorePath?: boolean | undefined;
/** Local interface string to bind for outgoing connections. */
localAddress?: string | undefined;
/** Changes the origin of the host header to the target URL. */
changeOrigin?: boolean | undefined;
/** specify whether you want to keep letter case of response header key */
preserveHeaderKeyCase?: boolean | undefined;
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
auth?: string | undefined;
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
hostRewrite?: string | undefined;
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
autoRewrite?: boolean | undefined;
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
protocolRewrite?: string | undefined;
/** rewrites domain of set-cookie headers. */
cookieDomainRewrite?: false | string | {
[oldDomain: string]: string;
} | undefined;
/** rewrites path of set-cookie headers. Default: false */
cookiePathRewrite?: false | string | {
[oldPath: string]: string;
} | undefined;
/** object with extra headers to be added to target requests. */
headers?: {
[header: string]: string;
} | undefined;
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
proxyTimeout?: number | undefined;
/** Timeout (in milliseconds) for incoming requests */
timeout?: number | undefined;
/** Specify whether you want to follow redirects. Default: false */
followRedirects?: boolean | undefined;
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
selfHandleResponse?: boolean | undefined;
/** Buffer */
buffer?: stream.Stream | undefined;
/** Explicitly set the method type of the ProxyReq */
method?: string | undefined;
}
interface HttpProxyTargetDetailed {
host: string;
port: number;
protocol?: string | undefined;
hostname?: string | undefined;
socketPath?: string | undefined;
key?: string | undefined;
passphrase?: string | undefined;
pfx?: Buffer | string | undefined;
cert?: string | undefined;
ca?: string | undefined;
ciphers?: string | undefined;
secureProtocol?: string | undefined;
}
type HttpProxyTarget = HttpProxyTargetUrl | HttpProxyTargetDetailed;
type HttpProxyTargetUrl = string | Partial<url.Url>;
export {};

5
node_modules/@rspack/core/dist/config/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export * from "./adapter";
export type { RawSourceMap } from "./adapterRuleUse";
export * from "./defaults";
export * from "./normalization";
export type * from "./types";

View File

@@ -0,0 +1,169 @@
/**
* The following code is modified based on
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/normalization.js
*
* MIT Licensed
* Author Tobias Koppers @sokra
* Copyright (c) JS Foundation and other contributors
* https://github.com/webpack/webpack/blob/main/LICENSE
*/
import type { HttpUriPluginOptions } from "../builtin-plugin";
import type { Compilation } from "../Compilation";
import type WebpackError from "../lib/WebpackError";
import type { Amd, AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryDescription, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, ImportMetaName, Incremental, 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 "./types";
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
export interface EntryStaticNormalized {
[k: string]: EntryDescriptionNormalized;
}
export type EntryDescriptionNormalized = Pick<EntryDescription, "runtime" | "chunkLoading" | "asyncChunks" | "publicPath" | "baseUri" | "filename" | "library" | "layer"> & {
import?: string[];
dependOn?: string[];
};
export interface OutputNormalized {
path?: Path;
pathinfo?: boolean | "verbose";
clean?: Clean;
publicPath?: PublicPath;
filename?: Filename;
chunkFilename?: ChunkFilename;
crossOriginLoading?: CrossOriginLoading;
cssFilename?: CssFilename;
cssChunkFilename?: CssChunkFilename;
hotUpdateMainFilename?: HotUpdateMainFilename;
hotUpdateChunkFilename?: HotUpdateChunkFilename;
hotUpdateGlobal?: HotUpdateGlobal;
assetModuleFilename?: AssetModuleFilename;
uniqueName?: UniqueName;
chunkLoadingGlobal?: ChunkLoadingGlobal;
enabledLibraryTypes?: EnabledLibraryTypes;
library?: LibraryOptions;
module?: OutputModule;
strictModuleErrorHandling?: StrictModuleErrorHandling;
globalObject?: GlobalObject;
importFunctionName?: ImportFunctionName;
importMetaName?: ImportMetaName;
iife?: Iife;
wasmLoading?: WasmLoading;
enabledWasmLoadingTypes?: EnabledWasmLoadingTypes;
webassemblyModuleFilename?: WebassemblyModuleFilename;
chunkFormat?: string | false;
chunkLoading?: string | false;
enabledChunkLoadingTypes?: string[];
trustedTypes?: TrustedTypes;
sourceMapFilename?: SourceMapFilename;
hashDigest?: HashDigest;
hashDigestLength?: HashDigestLength;
hashFunction?: HashFunction;
hashSalt?: HashSalt;
asyncChunks?: boolean;
workerChunkLoading?: ChunkLoading;
workerWasmLoading?: WasmLoading;
workerPublicPath?: WorkerPublicPath;
scriptType?: ScriptType;
devtoolNamespace?: DevtoolNamespace;
devtoolModuleFilenameTemplate?: DevtoolModuleFilenameTemplate;
devtoolFallbackModuleFilenameTemplate?: DevtoolFallbackModuleFilenameTemplate;
environment?: Environment;
charset?: boolean;
chunkLoadTimeout?: number;
compareBeforeEmit?: boolean;
}
export interface ModuleOptionsNormalized {
defaultRules?: RuleSetRules;
rules: RuleSetRules;
parser: ParserOptionsByModuleType;
generator: GeneratorOptionsByModuleType;
noParse?: NoParseOption;
unsafeCache?: boolean | RegExp;
}
export type ExperimentCacheNormalized = boolean | {
type: "memory";
} | {
type: "persistent";
buildDependencies: string[];
version: string;
snapshot: {
immutablePaths: (string | RegExp)[];
unmanagedPaths: (string | RegExp)[];
managedPaths: (string | RegExp)[];
};
storage: {
type: "filesystem";
directory: string;
};
};
export interface ExperimentsNormalized {
cache?: ExperimentCacheNormalized;
/**
* @deprecated This option is deprecated and will be removed in future versions.
*
* Please use the Configuration top-level `lazyCompilation` option instead.
*/
lazyCompilation?: false | LazyCompilationOptions;
asyncWebAssembly?: boolean;
outputModule?: boolean;
topLevelAwait?: boolean;
css?: boolean;
/**
* @deprecated This option is deprecated, layers is enabled since v1.6.0
*/
layers?: boolean;
incremental?: false | Incremental;
/**
* @deprecated This option is deprecated, as it has a huge regression in some edge cases where the chunk graph has lots of cycles. We will improve performance of build_chunk_graph.
*/
parallelCodeSplitting?: boolean;
futureDefaults?: boolean;
rspackFuture?: RspackFutureOptions;
buildHttp?: HttpUriPluginOptions;
parallelLoader?: boolean;
useInputFileSystem?: false | RegExp[];
inlineConst?: boolean;
inlineEnum?: boolean;
typeReexportsPresence?: boolean;
lazyBarrel?: boolean;
nativeWatcher?: boolean;
deferImport?: boolean;
}
export type IgnoreWarningsNormalized = ((warning: WebpackError, compilation: Compilation) => boolean)[];
export type OptimizationRuntimeChunkNormalized = false | {
name: string | ((entrypoint: {
name: string;
}) => string);
};
export interface RspackOptionsNormalized {
name?: Name;
dependencies?: Dependencies;
context?: Context;
mode?: Mode;
entry: EntryNormalized;
output: OutputNormalized;
resolve: Resolve;
resolveLoader: Resolve;
module: ModuleOptionsNormalized;
target?: Target;
externals?: Externals;
externalsType?: ExternalsType;
externalsPresets: ExternalsPresets;
infrastructureLogging: InfrastructureLogging;
devtool?: DevTool;
node: Node;
loader: Loader;
snapshot: SnapshotOptions;
cache?: CacheOptions;
stats: StatsValue;
optimization: Optimization;
plugins: Plugins;
experiments: ExperimentsNormalized;
lazyCompilation?: false | LazyCompilationOptions;
watch?: Watch;
watchOptions: WatchOptions;
devServer?: DevServer;
ignoreWarnings?: IgnoreWarningsNormalized;
performance?: Performance;
profile?: Profile;
amd?: Amd;
bail?: Bail;
}

91
node_modules/@rspack/core/dist/config/target.d.ts generated vendored Normal file
View File

@@ -0,0 +1,91 @@
/**
* @param context the context directory
* @returns default target
*/
export declare const getDefaultTarget: (context: string) => "browserslist" | "web";
export type PlatformTargetProperties = {
/** web platform, importing of http(s) and std: is available */
web: boolean | null;
/** browser platform, running in a normal web browser */
browser: boolean | null;
/** (Web)Worker platform, running in a web/shared/service worker */
webworker: boolean | null;
/** node platform, require of node built-in modules is available */
node: boolean | null;
/** nwjs platform, require of legacy nw.gui is available */
nwjs: boolean | null;
/** electron platform, require of some electron built-in modules is available */
electron: boolean | null;
};
export type ElectronContextTargetProperties = {
/** in main context */
electronMain: boolean | null;
/** in preload context */
electronPreload: boolean | null;
/** in renderer context with node integration */
electronRenderer: boolean | null;
};
export type ApiTargetProperties = {
/** has require function available */
require: boolean | null;
/** has node.js built-in modules available */
nodeBuiltins: boolean | null;
/** node.js allows to use `node:` prefix for core modules */
nodePrefixForCoreModules: boolean | null;
/** has document available (allows script tags) */
document: boolean | null;
/** has importScripts available */
importScripts: boolean | null;
/** has importScripts available when creating a worker */
importScriptsInWorker: boolean | null;
/** has fetch function available for WebAssembly */
fetchWasm: boolean | null;
/** has global variable available */
global: boolean | null;
};
export type EcmaTargetProperties = {
/** has globalThis variable available */
globalThis: boolean | null;
/** big int literal syntax is available */
bigIntLiteral: boolean | null;
/** const and let variable declarations are available */
const: boolean | null;
/** method shorthand in object is available */
methodShorthand: boolean | null;
/** arrow functions are available */
arrowFunction: boolean | null;
/** for of iteration is available */
forOf: boolean | null;
/** destructuring is available */
destructuring: boolean | null;
/** async import() is available */
dynamicImport: boolean | null;
/** async import() is available when creating a worker */
dynamicImportInWorker: boolean | null;
/** ESM syntax is available (when in module) */
module: boolean | null;
/** optional chaining is available */
optionalChaining: boolean | null;
/** template literal is available */
templateLiteral: boolean | null;
/** async functions and await are available */
asyncFunction: boolean | null;
};
type Never<T> = {
[P in keyof T]?: never;
};
type Mix<A, B> = (A & Never<B>) | (Never<A> & B) | (A & B);
type TargetProperties = Mix<Mix<PlatformTargetProperties, ElectronContextTargetProperties>, Mix<ApiTargetProperties, EcmaTargetProperties>>;
/**
* @param target the target
* @param context the context directory
* @returns target properties
*/
export declare const getTargetProperties: (target: string, context: string) => TargetProperties;
/**
* @param targets the targets
* @param context the context directory
* @returns target properties
*/
export declare const getTargetsProperties: (targets: string[], context: string) => TargetProperties;
export {};

2403
node_modules/@rspack/core/dist/config/types.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff