@rspack/core 2.0.8 → 2.1.0-beta.0

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.
@@ -113,6 +113,13 @@ interface JsMinifyOptions {
113
113
  safari10?: boolean;
114
114
  toplevel?: boolean;
115
115
  sourceMap?: boolean;
116
+ /**
117
+ * Serializable subset of terser-webpack-plugin's `extractComments`.
118
+ * `true` behaves like `'some'`.
119
+ */
120
+ extractComments?: boolean | "some" | "all" | {
121
+ regex: string;
122
+ };
116
123
  outputPath?: string;
117
124
  inlineSourcesContent?: boolean;
118
125
  }
@@ -654,7 +661,7 @@ interface JscConfig {
654
661
  };
655
662
  }
656
663
  type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "esnext";
657
- type ParserConfig = TsParserConfig | EsParserConfig;
664
+ type ParserConfig = TsParserConfig | EsParserConfig | FlowParserConfig;
658
665
  interface TsParserConfig {
659
666
  syntax: "typescript";
660
667
  /**
@@ -670,6 +677,37 @@ interface TsParserConfig {
670
677
  */
671
678
  dynamicImport?: boolean;
672
679
  }
680
+ interface FlowParserConfig {
681
+ syntax: "flow";
682
+ /**
683
+ * Defaults to `false`.
684
+ */
685
+ jsx?: boolean;
686
+ /**
687
+ * Defaults to `false`.
688
+ */
689
+ all?: boolean;
690
+ /**
691
+ * Defaults to `false`.
692
+ */
693
+ requireDirective?: boolean;
694
+ /**
695
+ * Defaults to `false`.
696
+ */
697
+ enums?: boolean;
698
+ /**
699
+ * Defaults to `false`.
700
+ */
701
+ decorators?: boolean;
702
+ /**
703
+ * Defaults to `false`.
704
+ */
705
+ components?: boolean;
706
+ /**
707
+ * Defaults to `false`.
708
+ */
709
+ patternMatching?: boolean;
710
+ }
673
711
  interface EsParserConfig {
674
712
  syntax: "ecmascript";
675
713
  /**
@@ -765,6 +803,7 @@ interface TransformConfig {
765
803
  * Effective only if `syntax` supports ƒ.
766
804
  */
767
805
  react?: ReactConfig;
806
+ reactCompiler?: boolean | ReactCompilerOptions;
768
807
  constModules?: ConstModulesConfig;
769
808
  /**
770
809
  * Defaults to null, which skips optimizer pass.
@@ -793,6 +832,92 @@ interface TransformConfig {
793
832
  verbatimModuleSyntax?: boolean;
794
833
  tsEnumIsMutable?: boolean;
795
834
  }
835
+ interface ReactCompilerOptions {
836
+ /**
837
+ * Which functions to compile.
838
+ *
839
+ * Defaults to `"infer"`.
840
+ */
841
+ compilationMode?: "infer" | "syntax" | "annotation" | "all";
842
+ /**
843
+ * What to do when a function cannot be compiled.
844
+ *
845
+ * Defaults to `"none"`.
846
+ */
847
+ panicThreshold?: "none" | "critical_errors" | "all_errors";
848
+ /**
849
+ * React runtime version target.
850
+ *
851
+ * Defaults to `"19"`.
852
+ */
853
+ target?: "17" | "18" | "19";
854
+ /**
855
+ * Analyze and report diagnostics only; emit no transformed code.
856
+ *
857
+ * Defaults to `false`.
858
+ */
859
+ noEmit?: boolean;
860
+ /**
861
+ * Defaults to `"client"`.
862
+ */
863
+ outputMode?: "client" | "ssr" | "lint";
864
+ /**
865
+ * Compile even functions marked with opt-out directives.
866
+ *
867
+ * Defaults to `false`.
868
+ */
869
+ ignoreUseNoForget?: boolean;
870
+ /**
871
+ * Treat Flow suppression comments as opt-outs.
872
+ *
873
+ * Defaults to `true`.
874
+ */
875
+ flowSuppressions?: boolean;
876
+ /**
877
+ * Enable react-native-reanimated support.
878
+ *
879
+ * Defaults to `false`.
880
+ */
881
+ enableReanimated?: boolean;
882
+ /**
883
+ * Development mode.
884
+ *
885
+ * Defaults to `false`.
886
+ */
887
+ isDev?: boolean;
888
+ /**
889
+ * ESLint rules whose suppressions opt a function out of compilation.
890
+ */
891
+ eslintSuppressionRules?: string[];
892
+ /**
893
+ * Extra directives that opt a function out of compilation.
894
+ */
895
+ customOptOutDirectives?: string[];
896
+ /**
897
+ * Emit a gated version of each compiled function.
898
+ */
899
+ gating?: ReactCompilerGatingConfig;
900
+ /**
901
+ * Dynamically-gated compilation.
902
+ */
903
+ dynamicGating?: ReactCompilerDynamicGatingConfig;
904
+ }
905
+ interface ReactCompilerGatingConfig {
906
+ /**
907
+ * Module the gating import comes from.
908
+ */
909
+ source: string;
910
+ /**
911
+ * Imported specifier used as the gate.
912
+ */
913
+ importSpecifierName: string;
914
+ }
915
+ interface ReactCompilerDynamicGatingConfig {
916
+ /**
917
+ * Module the gating import comes from.
918
+ */
919
+ source: string;
920
+ }
796
921
  interface ReactConfig {
797
922
  /**
798
923
  * Replace the function used when compiling JSX expressions.
@@ -1123,6 +1248,10 @@ interface Output {
1123
1248
  * Sourcemap (**not** base64 encoded)
1124
1249
  */
1125
1250
  map?: string;
1251
+ /**
1252
+ * Extracted comments collected during minification.
1253
+ */
1254
+ extractedComments?: string[];
1126
1255
  }
1127
1256
  interface MatchPattern {
1128
1257
  }
@@ -2137,4 +2266,4 @@ type WasmAnalysisOptions = {
2137
2266
  };
2138
2267
  type WasmPlugin = [wasmPackage: string, config: Record<string, any>];
2139
2268
 
2140
- export type { Accessibility, AmdConfig, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentOperator, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BaseModuleConfig, BigIntLiteral, BinaryExpression, BinaryOperator, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CallerOptions, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassMethodBase, ClassProperty, ClassPropertyBase, CommonJsConfig, ComputedPropName, ConditionalExpression, Config, ConstModulesConfig, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, EnvConfig, Es6Config, EsParserConfig, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, GlobalPassOption, HasDecorator, HasSpan, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, Invalid, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, JsFormatOptions, JsMinifyOptions, JscConfig, JscTarget, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, Literal, MatchPattern, MemberExpression, MetaProperty, MethodKind, MethodProperty, Module, ModuleConfig, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, Node, NodeNextConfig, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptimizerConfig, OptionalChainingCall, OptionalChainingExpression, Options, Output, Param, ParenthesisExpression, ParseOptions, ParserConfig, Pattern, Plugin, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, ReactConfig, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, Span, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, Swcrc, SwitchCase, SwitchStatement, SystemjsConfig, TaggedTemplateExpression, TemplateElement, TemplateLiteral, TerserCompressOptions, TerserEcmaVersion, TerserMangleOptions, TerserManglePropertiesOptions, ThisExpression, ThrowStatement, TransformConfig, TruePlusMinus, TryStatement, TsArrayType, TsAsExpression, TsCallSignatureDeclaration, TsConditionalType, TsConstAssertion, TsConstructSignatureDeclaration, TsConstructorType, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnOrConstructorType, TsFnParameter, TsFunctionType, TsGetterSignature, TsImportEqualsDeclaration, TsImportType, TsIndexSignature, TsIndexedAccessType, TsInferType, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsIntersectionType, TsKeywordType, TsKeywordTypeKind, TsLiteral, TsLiteralType, TsMappedType, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsOptionalType, TsParameterProperty, TsParameterPropertyParameter, TsParenthesizedType, TsParserConfig, TsPropertySignature, TsQualifiedName, TsRestType, TsSatisfiesExpression, TsSetterSignature, TsTemplateLiteralType, TsThisType, TsThisTypeOrIdent, TsTupleElement, TsTupleType, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeLiteral, TsTypeOperator, TsTypeOperatorOp, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeReference, TsUnionOrIntersectionType, TsUnionType, UmdConfig, UnaryExpression, UnaryOperator, UpdateExpression, UpdateOperator, VariableDeclaration, VariableDeclarationKind, VariableDeclarator, WasmAnalysisOptions, WasmPlugin, WhileStatement, WithStatement, YieldExpression };
2269
+ export type { Accessibility, AmdConfig, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentOperator, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BaseModuleConfig, BigIntLiteral, BinaryExpression, BinaryOperator, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CallerOptions, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassMethodBase, ClassProperty, ClassPropertyBase, CommonJsConfig, ComputedPropName, ConditionalExpression, Config, ConstModulesConfig, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, EnvConfig, Es6Config, EsParserConfig, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, FlowParserConfig, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, GlobalPassOption, HasDecorator, HasSpan, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, Invalid, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, JsFormatOptions, JsMinifyOptions, JscConfig, JscTarget, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, Literal, MatchPattern, MemberExpression, MetaProperty, MethodKind, MethodProperty, Module, ModuleConfig, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, Node, NodeNextConfig, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptimizerConfig, OptionalChainingCall, OptionalChainingExpression, Options, Output, Param, ParenthesisExpression, ParseOptions, ParserConfig, Pattern, Plugin, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, ReactCompilerDynamicGatingConfig, ReactCompilerGatingConfig, ReactCompilerOptions, ReactConfig, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, Span, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, Swcrc, SwitchCase, SwitchStatement, SystemjsConfig, TaggedTemplateExpression, TemplateElement, TemplateLiteral, TerserCompressOptions, TerserEcmaVersion, TerserMangleOptions, TerserManglePropertiesOptions, ThisExpression, ThrowStatement, TransformConfig, TruePlusMinus, TryStatement, TsArrayType, TsAsExpression, TsCallSignatureDeclaration, TsConditionalType, TsConstAssertion, TsConstructSignatureDeclaration, TsConstructorType, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnOrConstructorType, TsFnParameter, TsFunctionType, TsGetterSignature, TsImportEqualsDeclaration, TsImportType, TsIndexSignature, TsIndexedAccessType, TsInferType, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsIntersectionType, TsKeywordType, TsKeywordTypeKind, TsLiteral, TsLiteralType, TsMappedType, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsOptionalType, TsParameterProperty, TsParameterPropertyParameter, TsParenthesizedType, TsParserConfig, TsPropertySignature, TsQualifiedName, TsRestType, TsSatisfiesExpression, TsSetterSignature, TsTemplateLiteralType, TsThisType, TsThisTypeOrIdent, TsTupleElement, TsTupleType, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeLiteral, TsTypeOperator, TsTypeOperatorOp, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeReference, TsUnionOrIntersectionType, TsUnionType, UmdConfig, UnaryExpression, UnaryOperator, UpdateExpression, UpdateOperator, VariableDeclaration, VariableDeclarationKind, VariableDeclarator, WasmAnalysisOptions, WasmPlugin, WhileStatement, WithStatement, YieldExpression };
@@ -1 +1 @@
1
- {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.26","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.27","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
@@ -140,7 +140,10 @@ interface RequestHandler<TReq extends http.IncomingMessage = http.IncomingMessag
140
140
  (req: TReq, res: TRes, next?: TNext): Promise<void>;
141
141
  upgrade: (req: TReq, socket: net.Socket, head: Buffer) => void;
142
142
  }
143
- type Filter<TReq extends http.IncomingMessage = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean);
143
+ type Filter<TReq extends http.IncomingMessage = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean | string | RegExpMatchArray | null);
144
+ /**
145
+ * @see {@link https://github.com/chimurai/http-proxy-middleware/tree/master#defineplugin-helper `definePlugin()`} to define a http-proxy-middleware plugin.
146
+ */
144
147
  interface Plugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> {
145
148
  (proxyServer: ProxyServer<TReq, TRes>, options: Options<TReq, TRes>): void;
146
149
  }
@@ -156,9 +159,13 @@ interface OnProxyEvent<TReq extends http.IncomingMessage = http.IncomingMessage,
156
159
  econnreset?: (err: Error, req: TReq, res: TRes, target: string | Partial<URL>) => void;
157
160
  }
158
161
  type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
159
- type PathRewriteConfig<TReq extends http.IncomingMessage = http.IncomingMessage> = {
162
+ type PathRewriteConfig<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> = {
160
163
  [regexp: string]: string;
161
- } | ((path: string, req: TReq) => string | undefined) | ((path: string, req: TReq) => Promise<string>);
164
+ } | ((path: string, req: TReq,
165
+ /** `res` is undefined in WebSocket upgrade flows. */
166
+ res?: TRes | undefined, options?: Options<TReq, TRes>) => string | undefined) | ((path: string, req: TReq,
167
+ /** `res` is undefined in WebSocket upgrade flows. */
168
+ res?: TRes | undefined, options?: Options<TReq, TRes>) => Promise<string | undefined>);
162
169
  interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> extends ProxyServerOptions {
163
170
  /**
164
171
  * Narrow down requests to proxy or not.
@@ -178,9 +185,13 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
178
185
  * }
179
186
  * });
180
187
  * ```
188
+ * @since v0.15.0
189
+ * @since v0.21.0 - support `async` function
190
+ * @since v4.1.0 - `res` and `options` parameters added to custom function
191
+ *
181
192
  * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
182
193
  */
183
- pathRewrite?: PathRewriteConfig<TReq>;
194
+ pathRewrite?: PathRewriteConfig<TReq, TRes>;
184
195
  /**
185
196
  * Access the internal `httpxy` server instance to customize behavior
186
197
  *
@@ -225,17 +236,24 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
225
236
  on?: OnProxyEvent<TReq, TRes>;
226
237
  /**
227
238
  * Dynamically set the {@link Options.target `options.target`}.
239
+ *
228
240
  * @example
229
241
  * ```js
230
242
  * createProxyMiddleware({
231
- * router: async (req) => {
243
+ * router: async (req, res, options) => {
232
244
  * return 'http://127:0.0.1:3000';
233
245
  * }
234
246
  * });
235
247
  * ```
248
+ *
249
+ * @since v0.16.0
250
+ * @since v4.1.0 - `res` and `options` parameters added to router function signature
251
+ *
252
+ * NOTE: `res` is undefined in WebSocket upgrade flows.
253
+ *
236
254
  * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
237
255
  */
238
- router?: Record<string, ProxyServerOptions['target']> | ((req: TReq) => ProxyServerOptions['target']) | ((req: TReq) => Promise<ProxyServerOptions['target']>);
256
+ router?: Record<string, ProxyServerOptions['target']> | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => ProxyServerOptions['target']) | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => Promise<ProxyServerOptions['target']>);
239
257
  /**
240
258
  * Log information from http-proxy-middleware
241
259
  * @example
@@ -331,10 +349,26 @@ declare function createProxyMiddleware<TReq extends http.IncomingMessage = http.
331
349
  type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buffer: Buffer, proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<Buffer | string>;
332
350
  /**
333
351
  * Intercept responses from upstream.
334
- * Automatically decompress (deflate, gzip, brotli).
352
+ * Automatically decompress (deflate, gzip, brotli, zstd).
335
353
  * Give developer the opportunity to modify intercepted Buffer and http.ServerResponse
336
354
  *
337
355
  * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())
356
+ *
357
+ * @example
358
+ *
359
+ * ```ts
360
+ * createProxyMiddleware({
361
+ * target: 'http://example.com',
362
+ * selfHandleResponse: true, // MUST set selfHandleResponse=true
363
+ * on: {
364
+ * proxyRes: responseInterceptor(async (buffer, proxyRes, req, res) => {
365
+ * // modify intercepted buffer and return modified buffer
366
+ * const modifiedBuffer = Buffer.from(buffer.toString().replace(/Example/g, 'Demo'), 'utf8');
367
+ * return modifiedBuffer;
368
+ * }),
369
+ * }
370
+ * });
371
+ * ```
338
372
  */
339
373
  declare function responseInterceptor<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(interceptor: Interceptor<TReq, TRes>): (proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<void>;
340
374
 
@@ -343,9 +377,47 @@ type BodyParserLikeRequest = http.IncomingMessage & {
343
377
  };
344
378
  /**
345
379
  * Fix proxied body if bodyParser is involved.
380
+ *
381
+ * @example
382
+ * ```ts
383
+ * createProxyMiddleware({
384
+ * target: 'http://example.com',
385
+ * on: {
386
+ * proxyReq: fixRequestBody,
387
+ * }
388
+ * });
389
+ * ```
390
+ *
391
+ * Alternative solution without using `fixRequestBody()`: put `http-proxy-middleware` before `bodyParser` in the middleware stack.
392
+ *
393
+ * @see {@link https://github.com/chimurai/http-proxy-middleware/issues/40 Github issue #40 - POST request body is not proxied}
346
394
  */
347
395
  declare function fixRequestBody<TReq extends BodyParserLikeRequest = BodyParserLikeRequest>(proxyReq: http.ClientRequest, req: TReq): void;
348
396
 
397
+ /**
398
+ * Helper function to define a http-proxy-middleware plugin
399
+ * @see proxyServer {@link ProxyServer} - proxy server instance to which the plugin is being applied
400
+ * @see options {@link Options} - options object passed to `createProxyMiddleware`
401
+ *
402
+ * @example defining a plugin
403
+ * ```js
404
+ * export const myPlugin = definePlugin((proxyServer, options) => {
405
+ * // plugin implementation
406
+ * });
407
+ * ```
408
+ *
409
+ * @example using a plugin
410
+ * ```js
411
+ * createProxyMiddleware({
412
+ * target: 'http://example.com',
413
+ * plugins: [myPlugin],
414
+ * });
415
+ * ```
416
+ *
417
+ * @since 4.1.0
418
+ */
419
+ declare function definePlugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(fn: Plugin<TReq, TRes>): Plugin<TReq, TRes>;
420
+
349
421
  /**
350
422
  * Subscribe to {@link https://github.com/unjs/httpxy#events `httpxy` error events} to prevent server from crashing.
351
423
  * Errors are logged with {@link https://www.npmjs.com/package/debug debug} library.
@@ -378,5 +450,5 @@ declare const loggerPlugin: Plugin;
378
450
  */
379
451
  declare const proxyEventsPlugin: Plugin;
380
452
 
381
- export { createProxyMiddleware, debugProxyErrorsPlugin, errorResponsePlugin, fixRequestBody, loggerPlugin, proxyEventsPlugin, responseInterceptor };
453
+ export { createProxyMiddleware, debugProxyErrorsPlugin, definePlugin, errorResponsePlugin, fixRequestBody, loggerPlugin, proxyEventsPlugin, responseInterceptor };
382
454
  export type { Filter, Options, Plugin, RequestHandler };
@@ -1 +1 @@
1
- {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.0.0","license":"MIT","types":"index.d.ts","type":"module"}
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.1.0","license":"MIT","types":"index.d.ts","type":"module"}
@@ -9,6 +9,7 @@ export default class ModuleGraph {
9
9
  getModule(dependency: Dependency): Module | null;
10
10
  getResolvedModule(dependency: Dependency): Module | null;
11
11
  getUsedExports(module: Module, runtime: string | string[]): string[] | boolean | null;
12
+ getProvidedExports(module: Module): true | string[] | null;
12
13
  getParentModule(dependency: Dependency): Module | null;
13
14
  getIssuer(module: Module): Module | null;
14
15
  getExportsInfo(module: Module): ExportsInfo;
@@ -348,13 +348,14 @@ export declare const isReservedRuntimeGlobal: (r: string, compilerRuntimeGlobals
348
348
  export declare function renderModulePrefix(_compilerOptions: RspackOptionsNormalized): string;
349
349
  export declare enum RuntimeVariable {
350
350
  Require = 0,
351
- Modules = 1,
352
- ModuleCache = 2,
353
- Module = 3,
354
- Exports = 4,
355
- StartupExec = 5
351
+ Context = 1,
352
+ Modules = 2,
353
+ ModuleCache = 3,
354
+ Module = 4,
355
+ Exports = 5,
356
+ StartupExec = 6
356
357
  }
357
- export declare function renderRuntimeVariables(variable: RuntimeVariable, _compilerOptions?: RspackOptionsNormalized): string;
358
+ export declare function renderRuntimeVariables(variable: RuntimeVariable, compilerOptions?: RspackOptionsNormalized): string;
358
359
  export declare function createCompilerRuntimeGlobals(compilerOptions?: RspackOptionsNormalized): Record<keyof typeof RuntimeGlobals, string>;
359
360
  declare const DefaultRuntimeGlobals: Record<"amdDefine" | "amdOptions" | "asyncModule" | "asyncModuleExportSymbol" | "baseURI" | "chunkCallback" | "chunkName" | "compatGetDefaultExport" | "compileWasm" | "createFakeNamespaceObject" | "createScript" | "createScriptUrl" | "currentRemoteGetScope" | "definePropertyGetters" | "ensureChunk" | "ensureChunkHandlers" | "ensureChunkIncludeEntries" | "entryModuleId" | "exports" | "externalInstallChunk" | "getChunkCssFilename" | "getChunkScriptFilename" | "getChunkUpdateCssFilename" | "getChunkUpdateScriptFilename" | "getFullHash" | "getTrustedTypesPolicy" | "getUpdateManifestFilename" | "global" | "harmonyModuleDecorator" | "hasCssModules" | "hasFetchPriority" | "hasOwnProperty" | "hmrDownloadManifest" | "hmrDownloadUpdateHandlers" | "hmrInvalidateModuleHandlers" | "hmrModuleData" | "hmrRuntimeStatePrefix" | "initializeSharing" | "instantiateWasm" | "interceptModuleExecution" | "loadScript" | "makeDeferredNamespaceObject" | "makeDeferredNamespaceObjectSymbol" | "makeNamespaceObject" | "module" | "moduleCache" | "moduleFactories" | "moduleFactoriesAddOnly" | "moduleId" | "moduleLoaded" | "nodeModuleDecorator" | "onChunksLoaded" | "prefetchChunk" | "prefetchChunkHandlers" | "preloadChunk" | "preloadChunkHandlers" | "publicPath" | "relativeUrl" | "require" | "requireScope" | "returnExportsFromRuntime" | "rspackUniqueId" | "rspackVersion" | "runtimeId" | "scriptNonce" | "shareScopeMap" | "startup" | "startupChunkDependencies" | "startupEntrypoint" | "startupNoDefault" | "startupOnlyAfter" | "startupOnlyBefore" | "system" | "systemContext" | "thisAsExports" | "uncaughtErrorHandler" | "wasmInstances", string>;
360
361
  export { DefaultRuntimeGlobals as RuntimeGlobals };
@@ -13,6 +13,7 @@ export type RsdoctorPluginOptions = {
13
13
  module?: boolean;
14
14
  cheap?: boolean;
15
15
  };
16
+ exportUsageGraph?: boolean;
16
17
  };
17
18
  declare const RsdoctorPluginImpl: {
18
19
  new (c?: RsdoctorPluginOptions | undefined): {
@@ -1,7 +1,7 @@
1
1
  import type { AssetInfo, RawModuleRuleUse, RawOptions } from '@rspack/binding';
2
2
  import type { Compilation } from '../Compilation.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
- import { type LoaderObject } from '../loader-runner/index.js';
4
+ import type { LoaderObject } from '../loader-runner/index.js';
5
5
  import type { Logger } from '../logging/Logger.js';
6
6
  import type { Module } from '../Module.js';
7
7
  import type { ResolveRequest } from '../Resolver.js';
@@ -1,5 +1,5 @@
1
1
  import type { RspackOptionsNormalized } from './normalization.js';
2
- export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => false | {
2
+ export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized, compilerIndex?: number) => false | {
3
3
  platform: {
4
4
  web: boolean | null | undefined;
5
5
  browser: boolean | null | undefined;
@@ -10,7 +10,7 @@
10
10
  import type { HttpUriPluginOptions } from '../builtin-plugin/index.js';
11
11
  import type { Compilation } from '../Compilation.js';
12
12
  import type WebpackError from '../lib/WebpackError.js';
13
- import type { Amd, AssetModuleFilename, Bail, BundlerInfoOptions, 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, PublicPath, Resolve, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from './types.js';
13
+ import type { Amd, AssetModuleFilename, Bail, BundlerInfoOptions, 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, PublicPath, Resolve, RspackOptions, RuleSetRules, ScriptType, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from './types.js';
14
14
  export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
15
15
  export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
16
16
  export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
@@ -77,22 +77,25 @@ export interface ModuleOptionsNormalized {
77
77
  generator: GeneratorOptionsByModuleType;
78
78
  noParse?: NoParseOption;
79
79
  }
80
- export type CacheNormalized = boolean | {
80
+ export type CacheNormalized = false | {
81
81
  type: 'memory';
82
82
  } | {
83
83
  type: 'persistent';
84
84
  buildDependencies: string[];
85
- version: string;
85
+ version?: string;
86
86
  snapshot: {
87
- immutablePaths: (string | RegExp)[];
88
- unmanagedPaths: (string | RegExp)[];
89
- managedPaths: (string | RegExp)[];
87
+ immutablePaths?: (string | RegExp)[];
88
+ unmanagedPaths?: (string | RegExp)[];
89
+ managedPaths?: (string | RegExp)[];
90
90
  };
91
91
  storage: {
92
92
  type: 'filesystem';
93
- directory: string;
93
+ directory?: string;
94
+ maxAge?: number;
95
+ maxGenerations?: number;
94
96
  };
95
97
  portable?: boolean;
98
+ readonly?: boolean;
96
99
  };
97
100
  export interface ExperimentsNormalized {
98
101
  asyncWebAssembly?: boolean;
@@ -104,6 +107,7 @@ export interface ExperimentsNormalized {
104
107
  deferImport?: boolean;
105
108
  sourceImport?: boolean;
106
109
  pureFunctions?: boolean;
110
+ runtimeMode?: 'webpack' | 'rspack';
107
111
  }
108
112
  export type IgnoreWarningsNormalized = ((warning: WebpackError, compilation: Compilation) => boolean)[];
109
113
  export type OptimizationRuntimeChunkNormalized = false | {
@@ -129,7 +133,6 @@ export interface RspackOptionsNormalized {
129
133
  devtool?: DevTool;
130
134
  node: Node;
131
135
  loader: Loader;
132
- snapshot: SnapshotOptions;
133
136
  cache?: CacheNormalized;
134
137
  stats: StatsValue;
135
138
  optimization: Optimization;
@@ -932,6 +932,11 @@ export type JavascriptParserOptions = {
932
932
  * Enable magic comments for CommonJS require() expressions.
933
933
  */
934
934
  commonjsMagicComments?: boolean;
935
+ /**
936
+ * Enable or disable parsing `import { createRequire } from "module"` and evaluating createRequire().
937
+ * @default false
938
+ */
939
+ createRequire?: boolean | string;
935
940
  /** Whether to tolerant exportsPresence for type reexport */
936
941
  typeReexportsPresence?: 'no-tolerant' | 'tolerant' | 'tolerant-no-check';
937
942
  /** Whether to enable JSX parsing */
@@ -1342,7 +1347,6 @@ export type NodeOptions = {
1342
1347
  */
1343
1348
  export type Node = false | NodeOptions;
1344
1349
  export type Loader = Record<string, any>;
1345
- export type SnapshotOptions = {};
1346
1350
  /**
1347
1351
  * Snapshot options for determining which files have been modified.
1348
1352
  */
@@ -1371,9 +1375,21 @@ export type CacheStorageOptions = {
1371
1375
  type: 'filesystem';
1372
1376
  /**
1373
1377
  * Cache directory path.
1374
- * @default 'node_modules/.cache/rspack'
1378
+ * @default 'node_modules/.cache/rspack/<name>-<mode>-<compilerIndex>'
1375
1379
  */
1376
1380
  directory?: string;
1381
+ /**
1382
+ * Maximum age of unused filesystem cache in seconds. Must be an integer
1383
+ * between 0 and 4294967295.
1384
+ * @default 7 * 24 * 60 * 60
1385
+ */
1386
+ maxAge?: number;
1387
+ /**
1388
+ * Maximum number of filesystem cache generations to retain in the cache
1389
+ * directory. Must be an integer between 0 and 4294967295.
1390
+ * @default No generation count limit; maxAge cleanup still applies
1391
+ */
1392
+ maxGenerations?: number;
1377
1393
  };
1378
1394
  /**
1379
1395
  * Persistent cache options.
@@ -2302,6 +2318,12 @@ export type Experiments = {
2302
2318
  * @default false
2303
2319
  */
2304
2320
  pureFunctions?: boolean;
2321
+ /**
2322
+ * Select runtime proxy context behavior. `webpack` keeps the webpack startup hook,
2323
+ * while `rspack` uses `__rspack_context`.
2324
+ * @default "webpack"
2325
+ */
2326
+ runtimeMode?: 'webpack' | 'rspack';
2305
2327
  };
2306
2328
  export type Watch = boolean;
2307
2329
  /** Options for watch mode. */
@@ -2480,10 +2502,6 @@ export type RspackOptions = {
2480
2502
  * Options for the stats output.
2481
2503
  */
2482
2504
  stats?: StatsValue;
2483
- /**
2484
- * Options for snapshotting.
2485
- */
2486
- snapshot?: SnapshotOptions;
2487
2505
  /**
2488
2506
  * Optimization options.
2489
2507
  */