@rsbuild/core 2.0.0-beta.0 → 2.0.0-beta.10

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.
Files changed (134) hide show
  1. package/compiled/chokidar/index.d.ts +197 -29
  2. package/compiled/chokidar/package.json +1 -1
  3. package/compiled/connect-next/index.d.ts +56 -0
  4. package/compiled/connect-next/license +26 -0
  5. package/compiled/connect-next/package.json +1 -0
  6. package/compiled/cors/index.d.ts +56 -0
  7. package/compiled/cors/license +22 -0
  8. package/compiled/cors/package.json +1 -0
  9. package/compiled/css-loader/index.js +2 -2
  10. package/compiled/css-loader/package.json +1 -1
  11. package/compiled/html-rspack-plugin/index.d.ts +102 -1
  12. package/compiled/html-rspack-plugin/index.js +863 -20
  13. package/compiled/html-rspack-plugin/package.json +1 -1
  14. package/compiled/http-proxy-middleware/index.d.ts +268 -43
  15. package/compiled/http-proxy-middleware/package.json +1 -1
  16. package/compiled/jiti/LICENSE +21 -0
  17. package/compiled/jiti/README.md +243 -0
  18. package/compiled/jiti/dist/babel.cjs +46699 -0
  19. package/compiled/jiti/dist/jiti.cjs +4842 -0
  20. package/compiled/jiti/lib/jiti-cli.mjs +19 -0
  21. package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
  22. package/compiled/jiti/lib/jiti-native.mjs +76 -0
  23. package/compiled/jiti/lib/jiti-register.d.mts +1 -0
  24. package/compiled/jiti/lib/jiti-register.mjs +2 -0
  25. package/compiled/jiti/lib/jiti.cjs +24 -0
  26. package/compiled/jiti/lib/jiti.d.cts +8 -0
  27. package/compiled/jiti/lib/jiti.d.mts +8 -0
  28. package/compiled/jiti/lib/jiti.mjs +23 -0
  29. package/compiled/jiti/lib/types.d.ts +363 -0
  30. package/compiled/jiti/package.json +133 -0
  31. package/compiled/postcss/index.js +1 -1
  32. package/compiled/postcss/lib/at-rule.d.ts +1 -1
  33. package/compiled/postcss/lib/comment.d.ts +1 -1
  34. package/compiled/postcss/lib/container.d.ts +1 -1
  35. package/compiled/postcss/lib/css-syntax-error.d.ts +1 -1
  36. package/compiled/postcss/lib/declaration.d.ts +1 -1
  37. package/compiled/postcss/lib/document.d.ts +1 -1
  38. package/compiled/postcss/lib/input.d.ts +1 -1
  39. package/compiled/postcss/lib/lazy-result.d.ts +1 -1
  40. package/compiled/postcss/lib/no-work-result.d.ts +1 -1
  41. package/compiled/postcss/lib/node.d.ts +1 -1
  42. package/compiled/postcss/lib/previous-map.d.ts +1 -1
  43. package/compiled/postcss/lib/processor.d.ts +1 -1
  44. package/compiled/postcss/lib/result.d.ts +1 -1
  45. package/compiled/postcss/lib/root.d.ts +1 -1
  46. package/compiled/postcss/lib/rule.d.ts +1 -1
  47. package/compiled/postcss/lib/stringifier.d.ts +1 -1
  48. package/compiled/postcss/lib/warning.d.ts +1 -1
  49. package/compiled/postcss/package.json +1 -1
  50. package/compiled/postcss-loader/index.js +10 -9
  51. package/compiled/postcss-loader/package.json +1 -1
  52. package/compiled/rslog/index.d.ts +33 -2
  53. package/compiled/rslog/package.json +1 -1
  54. package/compiled/rspack-chain/package.json +1 -1
  55. package/compiled/rspack-chain/types/index.d.ts +0 -5
  56. package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
  57. package/compiled/rspack-manifest-plugin/license +21 -0
  58. package/compiled/rspack-manifest-plugin/package.json +1 -0
  59. package/compiled/style-loader/index.js +37 -94
  60. package/compiled/style-loader/package.json +1 -1
  61. package/dist/{131.js → 958.js} +1706 -1655
  62. package/dist/chokidar.js +59 -57
  63. package/dist/client/hmr.js +3 -3
  64. package/dist/client/overlay.js +2 -2
  65. package/dist/connect-next.js +268 -0
  66. package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
  67. package/dist/cors.js +2 -2
  68. package/dist/http-proxy-middleware.js +2985 -0
  69. package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
  70. package/dist/index.js +1 -1
  71. package/dist/launch-editor-middleware.js +96 -16
  72. package/dist/manifest-plugin.js +543 -21
  73. package/dist/memfs.js +241 -776
  74. package/dist/{710.js → mrmime.js} +2 -1
  75. package/dist/open.js +32 -28
  76. package/dist/range-parser.js +2 -2
  77. package/dist/remapping.js +2 -2
  78. package/dist/rslib-runtime.js +4 -4
  79. package/dist/sirv.js +14 -14
  80. package/dist/src.js +510 -0
  81. package/dist/tinyglobby.js +114 -69
  82. package/dist/transformLoader.mjs +38 -1
  83. package/dist/transformRawLoader.mjs +1 -1
  84. package/dist/ws.js +1549 -0
  85. package/dist-types/createContext.d.ts +3 -2
  86. package/dist-types/helpers/format.d.ts +2 -1
  87. package/dist-types/helpers/fs.d.ts +2 -1
  88. package/dist-types/helpers/index.d.ts +1 -1
  89. package/dist-types/helpers/stats.d.ts +4 -3
  90. package/dist-types/helpers/vendors.d.ts +0 -2
  91. package/dist-types/hooks.d.ts +3 -3
  92. package/dist-types/index.d.ts +4 -3
  93. package/dist-types/initPlugins.d.ts +2 -1
  94. package/dist-types/logger.d.ts +9 -3
  95. package/dist-types/pluginManager.d.ts +2 -1
  96. package/dist-types/restart.d.ts +4 -2
  97. package/dist-types/server/assets-middleware/index.d.ts +3 -2
  98. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +2 -1
  99. package/dist-types/server/cliShortcuts.d.ts +4 -1
  100. package/dist-types/server/devMiddlewares.d.ts +4 -6
  101. package/dist-types/server/devServer.d.ts +8 -42
  102. package/dist-types/server/helper.d.ts +50 -16
  103. package/dist-types/server/historyApiFallback.d.ts +2 -1
  104. package/dist-types/server/middlewares.d.ts +5 -3
  105. package/dist-types/server/open.d.ts +4 -2
  106. package/dist-types/server/previewServer.d.ts +4 -0
  107. package/dist-types/server/proxy.d.ts +3 -2
  108. package/dist-types/server/runner/asModule.d.ts +1 -1
  109. package/dist-types/server/serverSetup.d.ts +2 -0
  110. package/dist-types/server/socketServer.d.ts +4 -1
  111. package/dist-types/server/watchFiles.d.ts +1 -1
  112. package/dist-types/types/config.d.ts +123 -25
  113. package/dist-types/types/context.d.ts +3 -0
  114. package/dist-types/types/hooks.d.ts +17 -15
  115. package/dist-types/types/plugin.d.ts +14 -11
  116. package/dist-types/types/rsbuild.d.ts +11 -4
  117. package/dist-types/types/thirdParty.d.ts +15 -6
  118. package/package.json +23 -26
  119. package/compiled/chokidar/handler.d.ts +0 -90
  120. package/compiled/http-proxy-middleware/index.js +0 -5284
  121. package/compiled/ws/index.d.ts +0 -437
  122. package/compiled/ws/index.js +0 -3166
  123. package/compiled/ws/license +0 -20
  124. package/compiled/ws/package.json +0 -1
  125. package/dist/397.js +0 -11
  126. package/dist/7.js +0 -1
  127. package/dist/743.js +0 -7
  128. package/dist/88.js +0 -40
  129. package/dist/connect.js +0 -581
  130. package/dist-types/server/prodServer.d.ts +0 -24
  131. /package/compiled/html-rspack-plugin/{loader.js → htmlLoader.js} +0 -0
  132. /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
  133. /package/dist/client/{59.js → 797.js} +0 -0
  134. /package/dist/{31.js → trace-mapping.js} +0 -0
@@ -1 +1 @@
1
- {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.1.6","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.1.7","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
-
3
2
  import * as http from 'http';
4
3
  import events from 'events';
5
4
  import * as net from 'net';
@@ -253,52 +252,125 @@ declare namespace Server {
253
252
  * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
254
253
  */
255
254
 
256
- interface Request extends http.IncomingMessage {
255
+ type NextFunction<T = (err?: any) => void> = T;
256
+ interface RequestHandler<TReq = http.IncomingMessage, TRes = http.ServerResponse, TNext = NextFunction> {
257
+ (req: TReq, res: TRes, next?: TNext): Promise<void>;
258
+ upgrade: (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
257
259
  }
258
- interface Response extends http.ServerResponse {
260
+ type Filter<TReq = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean);
261
+ interface Plugin<TReq = http.IncomingMessage, TRes = http.ServerResponse> {
262
+ (proxyServer: Server<TReq, TRes>, options: Options<TReq, TRes>): void;
259
263
  }
260
- interface RequestHandler {
261
- (req: Request, res: Response, next?: (err?: any) => void): void | Promise<void>;
262
- upgrade?: (req: Request, socket: net.Socket, head: any) => void;
264
+ interface OnProxyEvent<TReq = http.IncomingMessage, TRes = http.ServerResponse> {
265
+ error?: Server.ErrorCallback<Error, TReq, TRes>;
266
+ proxyReq?: Server.ProxyReqCallback<http.ClientRequest, TReq, TRes>;
267
+ proxyReqWs?: Server.ProxyReqWsCallback<http.ClientRequest, TReq>;
268
+ proxyRes?: Server.ProxyResCallback<TReq, TRes>;
269
+ open?: Server.OpenCallback;
270
+ close?: Server.CloseCallback<TReq>;
271
+ start?: Server.StartCallback<TReq, TRes>;
272
+ end?: Server.EndCallback<TReq, TRes>;
273
+ econnreset?: Server.EconnresetCallback<Error, TReq, TRes>;
263
274
  }
264
- declare type Filter = string | string[] | ((pathname: string, req: Request) => boolean);
265
- interface Options extends Server.ServerOptions {
275
+ type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
276
+ interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse> extends Server.ServerOptions {
277
+ /**
278
+ * Narrow down requests to proxy or not.
279
+ * Filter on {@link http.IncomingMessage.url `pathname`} which is relative to the proxy's "mounting" point in the server.
280
+ * Or use the {@link http.IncomingMessage `req`} object for more complex filtering.
281
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathFilter.md
282
+ * @since v3.0.0
283
+ */
284
+ pathFilter?: Filter<TReq>;
285
+ /**
286
+ * Modify request paths before requests are send to the target.
287
+ * @example
288
+ * ```js
289
+ * createProxyMiddleware({
290
+ * pathRewrite: {
291
+ * '^/api/old-path': '/api/new-path', // rewrite path
292
+ * }
293
+ * });
294
+ * ```
295
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
296
+ */
266
297
  pathRewrite?: {
267
298
  [regexp: string]: string;
268
- } | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
299
+ } | ((path: string, req: TReq) => string | undefined) | ((path: string, req: TReq) => Promise<string>);
300
+ /**
301
+ * Access the internal http-proxy server instance to customize behavior
302
+ *
303
+ * @example
304
+ * ```js
305
+ * createProxyMiddleware({
306
+ * plugins: [(proxyServer, options) => {
307
+ * proxyServer.on('error', (error, req, res) => {
308
+ * console.error(error);
309
+ * });
310
+ * }]
311
+ * });
312
+ * ```
313
+ * @link https://github.com/chimurai/http-proxy-middleware#plugins-array
314
+ * @since v3.0.0
315
+ */
316
+ plugins?: Plugin<TReq, TRes>[];
317
+ /**
318
+ * Eject pre-configured plugins.
319
+ * NOTE: register your own error handlers to prevent server from crashing.
320
+ *
321
+ * @link https://github.com/chimurai/http-proxy-middleware#ejectplugins-boolean-default-false
322
+ * @since v3.0.0
323
+ */
324
+ ejectPlugins?: boolean;
325
+ /**
326
+ * Listen to http-proxy events
327
+ * @see {@link OnProxyEvent} for available events
328
+ * @example
329
+ * ```js
330
+ * createProxyMiddleware({
331
+ * on: {
332
+ * error: (error, req, res, target) => {
333
+ * console.error(error);
334
+ * }
335
+ * }
336
+ * });
337
+ * ```
338
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md
339
+ * @since v3.0.0
340
+ */
341
+ on?: OnProxyEvent<TReq, TRes>;
342
+ /**
343
+ * Dynamically set the {@link Options.target `options.target`}.
344
+ * @example
345
+ * ```js
346
+ * createProxyMiddleware({
347
+ * router: async (req) => {
348
+ * return 'http://127:0.0.1:3000';
349
+ * }
350
+ * });
351
+ * ```
352
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
353
+ */
269
354
  router?: {
270
355
  [hostOrPath: string]: Server.ServerOptions['target'];
271
- } | ((req: Request) => Server.ServerOptions['target']) | ((req: Request) => Promise<Server.ServerOptions['target']>);
272
- logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
273
- logProvider?: LogProviderCallback;
274
- onError?: OnErrorCallback;
275
- onProxyRes?: OnProxyResCallback;
276
- onProxyReq?: OnProxyReqCallback;
277
- onProxyReqWs?: OnProxyReqWsCallback;
278
- onOpen?: OnOpenCallback;
279
- onClose?: OnCloseCallback;
280
- }
281
- interface LogProvider {
282
- log: Logger;
283
- debug?: Logger;
284
- info?: Logger;
285
- warn?: Logger;
286
- error?: Logger;
356
+ } | ((req: TReq) => Server.ServerOptions['target']) | ((req: TReq) => Promise<Server.ServerOptions['target']>);
357
+ /**
358
+ * Log information from http-proxy-middleware
359
+ * @example
360
+ * ```js
361
+ * createProxyMiddleware({
362
+ * logger: console
363
+ * });
364
+ * ```
365
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
366
+ * @since v3.0.0
367
+ */
368
+ logger?: Logger | any;
287
369
  }
288
- declare type Logger = (...args: any[]) => void;
289
- declare type LogProviderCallback = (provider: LogProvider) => LogProvider;
290
- /**
291
- * Use types based on the events listeners from http-proxy
292
- * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/51504fd999031b7f025220fab279f1b2155cbaff/types/http-proxy/index.d.ts
293
- */
294
- declare type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
295
- declare type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
296
- declare type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: Server.ServerOptions) => void;
297
- declare type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: Server.ServerOptions, head: any) => void;
298
- declare type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
299
- declare type OnOpenCallback = (proxySocket: net.Socket) => void;
300
370
 
301
- declare type Interceptor = (buffer: Buffer, proxyRes: http.IncomingMessage, req: http.IncomingMessage, res: http.ServerResponse) => Promise<Buffer | string>;
371
+ declare function createProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse, TNext = NextFunction>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext>;
372
+
373
+ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buffer: Buffer, proxyRes: TReq, req: TReq, res: TRes) => Promise<Buffer | string>;
302
374
  /**
303
375
  * Intercept responses from upstream.
304
376
  * Automatically decompress (deflate, gzip, brotli).
@@ -306,14 +378,167 @@ declare type Interceptor = (buffer: Buffer, proxyRes: http.IncomingMessage, req:
306
378
  *
307
379
  * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())
308
380
  */
309
- declare function responseInterceptor(interceptor: Interceptor): (proxyRes: http.IncomingMessage, req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
381
+ declare function responseInterceptor<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(interceptor: Interceptor<TReq, TRes>): (proxyRes: TReq, req: TReq, res: TRes) => Promise<void>;
310
382
 
383
+ type BodyParserLikeRequest = http.IncomingMessage & {
384
+ body?: any;
385
+ };
311
386
  /**
312
387
  * Fix proxied body if bodyParser is involved.
313
388
  */
314
- declare function fixRequestBody(proxyReq: http.ClientRequest, req: http.IncomingMessage): void;
389
+ declare function fixRequestBody<TReq extends BodyParserLikeRequest = BodyParserLikeRequest>(proxyReq: http.ClientRequest, req: TReq): void;
390
+
391
+ /**
392
+ * Subscribe to {@link https://www.npmjs.com/package/http-proxy#listening-for-proxy-events http-proxy error events} to prevent server from crashing.
393
+ * Errors are logged with {@link https://www.npmjs.com/package/debug debug} library.
394
+ */
395
+ declare const debugProxyErrorsPlugin: Plugin;
396
+
397
+ declare const errorResponsePlugin: Plugin;
398
+
399
+ declare const loggerPlugin: Plugin;
400
+
401
+ /**
402
+ * Implements option.on object to subscribe to http-proxy events.
403
+ *
404
+ * @example
405
+ * ```js
406
+ * createProxyMiddleware({
407
+ * on: {
408
+ * error: (error, req, res, target) => {},
409
+ * proxyReq: (proxyReq, req, res, options) => {},
410
+ * proxyReqWs: (proxyReq, req, socket, options) => {},
411
+ * proxyRes: (proxyRes, req, res) => {},
412
+ * open: (proxySocket) => {},
413
+ * close: (proxyRes, proxySocket, proxyHead) => {},
414
+ * start: (req, res, target) => {},
415
+ * end: (req, res, proxyRes) => {},
416
+ * econnreset: (error, req, res, target) => {},
417
+ * }
418
+ * });
419
+ * ```
420
+ */
421
+ declare const proxyEventsPlugin: Plugin;
422
+
423
+ /**
424
+ * @deprecated
425
+ *
426
+ * Will be removed in a future version.
427
+ */
428
+ interface LegacyOptions<TReq = http.IncomingMessage, TRes = http.ServerResponse> extends Options<TReq, TRes> {
429
+ /**
430
+ * @deprecated
431
+ * Use `on.error` instead.
432
+ *
433
+ * @example
434
+ * ```js
435
+ * {
436
+ * on: {
437
+ * error: () => {}
438
+ * }
439
+ * ```
440
+ */
441
+ onError?: (...args: any[]) => void;
442
+ /**
443
+ * @deprecated
444
+ * Use `on.proxyRes` instead.
445
+ *
446
+ * @example
447
+ * ```js
448
+ * {
449
+ * on: {
450
+ * proxyRes: () => {}
451
+ * }
452
+ * ```
453
+ */
454
+ onProxyRes?: (...args: any[]) => void;
455
+ /**
456
+ * @deprecated
457
+ * Use `on.proxyReq` instead.
458
+ *
459
+ * @example
460
+ * ```js
461
+ * {
462
+ * on: {
463
+ * proxyReq: () => {}
464
+ * }
465
+ * ```
466
+ */
467
+ onProxyReq?: (...args: any[]) => void;
468
+ /**
469
+ * @deprecated
470
+ * Use `on.proxyReqWs` instead.
471
+ *
472
+ * @example
473
+ * ```js
474
+ * {
475
+ * on: {
476
+ * proxyReqWs: () => {}
477
+ * }
478
+ * ```
479
+ */
480
+ onProxyReqWs?: (...args: any[]) => void;
481
+ /**
482
+ * @deprecated
483
+ * Use `on.open` instead.
484
+ *
485
+ * @example
486
+ * ```js
487
+ * {
488
+ * on: {
489
+ * open: () => {}
490
+ * }
491
+ * ```
492
+ */
493
+ onOpen?: (...args: any[]) => void;
494
+ /**
495
+ * @deprecated
496
+ * Use `on.close` instead.
497
+ *
498
+ * @example
499
+ * ```js
500
+ * {
501
+ * on: {
502
+ * close: () => {}
503
+ * }
504
+ * ```
505
+ */
506
+ onClose?: (...args: any[]) => void;
507
+ /**
508
+ * @deprecated
509
+ * Use `logger` instead.
510
+ *
511
+ * @example
512
+ * ```js
513
+ * {
514
+ * logger: console
515
+ * }
516
+ * ```
517
+ */
518
+ logProvider?: any;
519
+ /**
520
+ * @deprecated
521
+ * Use `logger` instead.
522
+ *
523
+ * @example
524
+ * ```js
525
+ * {
526
+ * logger: console
527
+ * }
528
+ * ```
529
+ */
530
+ logLevel?: any;
531
+ }
315
532
 
316
- declare function createProxyMiddleware(context: Filter | Options, options?: Options): RequestHandler;
533
+ /**
534
+ * @deprecated
535
+ * This function is deprecated and will be removed in a future version.
536
+ *
537
+ * Use {@link createProxyMiddleware} instead.
538
+ */
539
+ declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(shortHand: string): RequestHandler<TReq, TRes>;
540
+ declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
541
+ declare function legacyCreateProxyMiddleware<TReq = http.IncomingMessage, TRes = http.ServerResponse>(legacyContext: Filter<TReq>, legacyOptions: LegacyOptions<TReq, TRes>): RequestHandler<TReq, TRes>;
317
542
 
318
- export { createProxyMiddleware, fixRequestBody, responseInterceptor };
319
- export type { Filter, Options, RequestHandler };
543
+ export { createProxyMiddleware, debugProxyErrorsPlugin, errorResponsePlugin, fixRequestBody, legacyCreateProxyMiddleware, loggerPlugin, proxyEventsPlugin, responseInterceptor };
544
+ export type { Filter, LegacyOptions, Options, Plugin, RequestHandler };
@@ -1 +1 @@
1
- {"name":"http-proxy-middleware","author":"Steven Chim","version":"2.0.9","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"3.0.5","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,243 @@
1
+ # jiti
2
+
3
+ <!-- automd:badges color=F0DB4F bundlephobia -->
4
+
5
+ [![npm version](https://img.shields.io/npm/v/jiti?color=F0DB4F)](https://npmjs.com/package/jiti)
6
+ [![npm downloads](https://img.shields.io/npm/dm/jiti?color=F0DB4F)](https://npmjs.com/package/jiti)
7
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/jiti?color=F0DB4F)](https://bundlephobia.com/package/jiti)
8
+
9
+ <!-- /automd -->
10
+
11
+ > This is the active development branch. Check out [jiti/v1](https://github.com/unjs/jiti/tree/v1) for legacy v1 docs and code.
12
+
13
+ ## 🌟 Used in
14
+
15
+ [Docusaurus](https://docusaurus.io/), [ESLint](https://github.com/eslint/eslint), [FormKit](https://formkit.com/), [Histoire](https://histoire.dev/), [Knip](https://knip.dev/), [Nitro](https://nitro.unjs.io/), [Nuxt](https://nuxt.com/), [PostCSS loader](https://github.com/webpack-contrib/postcss-loader), [Rsbuild](https://rsbuild.dev/), [Size Limit](https://github.com/ai/size-limit), [Slidev](https://sli.dev/), [Tailwindcss](https://tailwindcss.com/), [Tokenami](https://github.com/tokenami/tokenami), [UnoCSS](https://unocss.dev/), [WXT](https://wxt.dev/), [Winglang](https://www.winglang.io/), [Graphql code generator](https://the-guild.dev/graphql/codegen), [Lingui](https://lingui.dev/), [Scaffdog](https://scaff.dog/), [Storybook](https://storybook.js.org), [...UnJS ecosystem](https://unjs.io/), [...60M+ npm monthly downloads](https://npm.chart.dev/jiti), [...6M+ public repositories](https://github.com/unjs/jiti/network/dependents).
16
+
17
+ ## ✅ Features
18
+
19
+ - Seamless TypeScript and ESM syntax support for Node.js
20
+ - Seamless interoperability between ESM and CommonJS
21
+ - Asynchronous API to replace `import()`
22
+ - Synchronous API to replace `require()` (deprecated)
23
+ - Super slim and zero dependency
24
+ - Custom resolve aliases
25
+ - Smart syntax detection to avoid extra transforms
26
+ - Node.js native `require.cache` integration
27
+ - Filesystem transpile with hard disk caches
28
+ - ESM Loader support
29
+ - JSX support (opt-in)
30
+
31
+ > [!IMPORTANT]
32
+ > To enhance compatibility, jiti `>=2.1` enabled [`interopDefault`](#interopdefault) using a new Proxy method. If you migrated to `2.0.0` earlier, this might have caused behavior changes. In case of any issues during the upgrade, please [report](https://github.com/unjs/jiti/issues) so we can investigate to solve them. 🙏🏼
33
+
34
+ ## 💡 Usage
35
+
36
+ ### CLI
37
+
38
+ You can use `jiti` CLI to quickly run any script with TypeScript and native ESM support!
39
+
40
+ ```bash
41
+ npx jiti ./index.ts
42
+ ```
43
+
44
+ ### Programmatic
45
+
46
+ Initialize a jiti instance:
47
+
48
+ ```js
49
+ // ESM
50
+ import { createJiti } from "jiti";
51
+ const jiti = createJiti(import.meta.url);
52
+
53
+ // CommonJS (deprecated)
54
+ const { createJiti } = require("jiti");
55
+ const jiti = createJiti(__filename);
56
+ ```
57
+
58
+ Import (async) and resolve with ESM compatibility:
59
+
60
+ ```js
61
+ // jiti.import(id) is similar to import(id)
62
+ const mod = await jiti.import("./path/to/file.ts");
63
+
64
+ // jiti.esmResolve(id) is similar to import.meta.resolve(id)
65
+ const resolvedPath = jiti.esmResolve("./src");
66
+ ```
67
+
68
+ If you need the default export of module, you can use `jiti.import(id, { default: true })` as shortcut to `mod?.default ?? mod`.
69
+
70
+ ```js
71
+ // shortcut to mod?.default ?? mod
72
+ const modDefault = await jiti.import("./path/to/file.ts", { default: true });
73
+ ```
74
+
75
+ CommonJS (sync & deprecated):
76
+
77
+ ```js
78
+ // jiti() is similar to require(id)
79
+ const mod = jiti("./path/to/file.ts");
80
+
81
+ // jiti.resolve() is similar to require.resolve(id)
82
+ const resolvedPath = jiti.resolve("./src");
83
+ ```
84
+
85
+ You can also pass options as the second argument:
86
+
87
+ ```js
88
+ const jiti = createJiti(import.meta.url, { debug: true });
89
+ ```
90
+
91
+ ### Register global ESM loader
92
+
93
+ You can globally register jiti using [global hooks](https://nodejs.org/api/module.html#initialize). (Important: Requires Node.js > 20)
94
+
95
+ ```js
96
+ import "jiti/register";
97
+ ```
98
+
99
+ Or:
100
+
101
+ ```bash
102
+ node --import jiti/register index.ts
103
+ ```
104
+
105
+ ## 🎈 `jiti/native`
106
+
107
+ You can alias `jiti` to `jiti/native` to directly depend on runtime's [`import.meta.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) and dynamic [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) support. This allows easing up the ecosystem transition to runtime native support by giving the same API of jiti.
108
+
109
+ ## ⚙️ Options
110
+
111
+ ### `debug`
112
+
113
+ - Type: Boolean
114
+ - Default: `false`
115
+ - Environment variable: `JITI_DEBUG`
116
+
117
+ Enable verbose logging. You can use `JITI_DEBUG=1 <your command>` to enable it.
118
+
119
+ ### `fsCache`
120
+
121
+ - Type: Boolean | String
122
+ - Default: `true`
123
+ - Environment variable: `JITI_FS_CACHE`
124
+
125
+ Filesystem source cache (enabled by default)
126
+
127
+ By default (when is `true`), jiti uses `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
128
+
129
+ **Note:** It is recommended that this option be enabled for better performance.
130
+
131
+ ### `rebuildFsCache`
132
+
133
+ - Type: Boolean
134
+ - Default: `false`
135
+ - Environment variable: `JITI_REBUILD_FS_CACHE`
136
+
137
+ Rebuild filesystem source cache created by `fsCache`.
138
+
139
+ ### `moduleCache`
140
+
141
+ - Type: String
142
+ - Default: `true`
143
+ - Environment variable: `JITI_MODULE_CACHE`
144
+
145
+ Runtime module cache (enabled by default).
146
+
147
+ Disabling allows editing code and importing the same module multiple times.
148
+
149
+ When enabled, jiti integrates with Node.js native CommonJS cache-store.
150
+
151
+ ### `transform`
152
+
153
+ - Type: Function
154
+ - Default: Babel (lazy loaded)
155
+
156
+ Transform function. See [src/babel](./src/babel.ts) for more details
157
+
158
+ ### `sourceMaps`
159
+
160
+ - Type: Boolean
161
+ - Default `false`
162
+ - Environment variable: `JITI_SOURCE_MAPS`
163
+
164
+ Add inline source map to transformed source for better debugging.
165
+
166
+ ### `interopDefault`
167
+
168
+ - Type: Boolean
169
+ - Default: `true`
170
+ - Environment variable: `JITI_INTEROP_DEFAULT`
171
+
172
+ Jiti combines module exports with the `default` export using an internal Proxy to improve compatibility with mixed CJS/ESM usage. You can check the current implementation [here](https://github.com/unjs/jiti/blob/main/src/utils.ts#L105).
173
+
174
+ ### `alias`
175
+
176
+ - Type: Object
177
+ - Default: -
178
+ - Environment variable: `JITI_ALIAS`
179
+
180
+ You can also pass an object to the environment variable for inline config. Example: `JITI_ALIAS='{"~/*": "./src/*"}' jiti ...`.
181
+
182
+ Custom alias map used to resolve IDs.
183
+
184
+ ### `nativeModules`
185
+
186
+ - Type: Array
187
+ - Default: ['typescript']
188
+ - Environment variable: `JITI_NATIVE_MODULES`
189
+
190
+ List of modules (within `node_modules`) to always use native `require()` for them.
191
+
192
+ ### `transformModules`
193
+
194
+ - Type: Array
195
+ - Default: []
196
+ - Environment variable: `JITI_TRANSFORM_MODULES`
197
+
198
+ List of modules (within `node_modules`) to transform them regardless of syntax.
199
+
200
+ ### `importMeta`
201
+
202
+ Parent module's [`import.meta`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta) context to use for ESM resolution. (only used for `jiti/native` import).
203
+
204
+ ### `tryNative`
205
+
206
+ - Type: Boolean
207
+ - Default: Enabled if bun is detected
208
+ - Environment variable: `JITI_TRY_NATIVE`
209
+
210
+ Try to use native require and import without jiti transformations first.
211
+
212
+ ### `jsx`
213
+
214
+ - Type: Boolean | {options}
215
+ - Default: `false`
216
+ - Environment Variable: `JITI_JSX`
217
+
218
+ Enable JSX support using [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/babel-plugin-transform-react-jsx).
219
+
220
+ See [`test/fixtures/jsx`](./test/fixtures/jsx) for framework integration examples.
221
+
222
+ ## Development
223
+
224
+ - Clone this repository
225
+ - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
226
+ - Install dependencies using `pnpm install`
227
+ - Run `pnpm dev`
228
+ - Run `pnpm jiti ./test/path/to/file.ts`
229
+
230
+ ## License
231
+
232
+ <!-- automd:contributors license=MIT author="pi0" -->
233
+
234
+ Published under the [MIT](https://github.com/unjs/jiti/blob/main/LICENSE) license.
235
+ Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/jiti/graphs/contributors) 💛
236
+ <br><br>
237
+ <a href="https://github.com/unjs/jiti/graphs/contributors">
238
+ <img src="https://contrib.rocks/image?repo=unjs/jiti" />
239
+ </a>
240
+
241
+ <!-- /automd -->
242
+
243
+ <!-- automd:with-automd -->