@rspack/core 1.6.3 → 1.6.5

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.
@@ -78,7 +78,7 @@ declare class Watchpack extends EventEmitter {
78
78
  aggregatedChanges: Set<string>;
79
79
  aggregatedRemovals: Set<string>;
80
80
 
81
- aggregateTimeout: NodeJS.Timer;
81
+ aggregateTimeout: number;
82
82
  dirWatchers: Watcher[];
83
83
  fileWatchers: Watcher[];
84
84
  /** Last modified times for files by path */
@@ -14,6 +14,7 @@ export declare const RuntimePluginImpl: {
14
14
  };
15
15
  export type RuntimePluginHooks = {
16
16
  createScript: liteTapable.SyncWaterfallHook<[string, Chunk]>;
17
+ createLink: liteTapable.SyncWaterfallHook<[string, Chunk]>;
17
18
  linkPreload: liteTapable.SyncWaterfallHook<[string, Chunk]>;
18
19
  linkPrefetch: liteTapable.SyncWaterfallHook<[string, Chunk]>;
19
20
  };
@@ -7,6 +7,10 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
9
9
  */
10
+ import type * as http from "node:http";
11
+ import type * as net from "node:net";
12
+ import type * as stream from "node:stream";
13
+ import type * as url from "node:url";
10
14
  import type { Compiler, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from "..";
11
15
  type Logger = ReturnType<Compiler["getInfrastructureLogger"]>;
12
16
  type MultiWatching = MultiCompiler["watch"];
@@ -126,9 +130,7 @@ type ProxyConfigArrayItem = {
126
130
  context?: HttpProxyMiddlewareOptionsFilter;
127
131
  } & {
128
132
  bypass?: ByPass;
129
- } & {
130
- [key: string]: any;
131
- };
133
+ } & HttpProxyMiddlewareOptions;
132
134
  type ByPass = (req: Request, res: Response, proxyConfig: ProxyConfigArrayItem) => any;
133
135
  type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request, res?: Response, next?: NextFunction) => ProxyConfigArrayItem))[];
134
136
  type Callback = (stats?: Stats | MultiStats) => any;
@@ -203,4 +205,110 @@ export type DevServerOptions<A extends BasicApplication = BasicApplication, S ex
203
205
  onListening?: ((devServer: Server) => void) | undefined;
204
206
  setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
205
207
  };
208
+ interface HttpProxyMiddlewareOptions extends HttpProxyServerOptions {
209
+ pathRewrite?: {
210
+ [regexp: string]: string;
211
+ } | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
212
+ router?: {
213
+ [hostOrPath: string]: HttpProxyServerOptions["target"];
214
+ } | ((req: Request) => HttpProxyServerOptions["target"]) | ((req: Request) => Promise<HttpProxyServerOptions["target"]>);
215
+ logLevel?: "debug" | "info" | "warn" | "error" | "silent";
216
+ logProvider?: LogProviderCallback;
217
+ onError?: OnErrorCallback;
218
+ onProxyRes?: OnProxyResCallback;
219
+ onProxyReq?: OnProxyReqCallback;
220
+ onProxyReqWs?: OnProxyReqWsCallback;
221
+ onOpen?: OnOpenCallback;
222
+ onClose?: OnCloseCallback;
223
+ }
224
+ interface LogProvider {
225
+ log: Logger;
226
+ debug?: Logger;
227
+ info?: Logger;
228
+ warn?: Logger;
229
+ error?: Logger;
230
+ }
231
+ type LogProviderCallback = (provider: LogProvider) => LogProvider;
232
+ type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
233
+ type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
234
+ type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: HttpProxyServerOptions) => void;
235
+ type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: HttpProxyServerOptions, head: any) => void;
236
+ type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
237
+ type OnOpenCallback = (proxySocket: net.Socket) => void;
238
+ interface HttpProxyServerOptions {
239
+ /** URL string to be parsed with the url module. */
240
+ target?: HttpProxyTarget | undefined;
241
+ /** URL string to be parsed with the url module. */
242
+ forward?: HttpProxyTargetUrl | undefined;
243
+ /** Object to be passed to http(s).request. */
244
+ agent?: any;
245
+ /** Object to be passed to https.createServer(). */
246
+ ssl?: any;
247
+ /** If you want to proxy websockets. */
248
+ ws?: boolean | undefined;
249
+ /** Adds x- forward headers. */
250
+ xfwd?: boolean | undefined;
251
+ /** Verify SSL certificate. */
252
+ secure?: boolean | undefined;
253
+ /** Explicitly specify if we are proxying to another proxy. */
254
+ toProxy?: boolean | undefined;
255
+ /** Specify whether you want to prepend the target's path to the proxy path. */
256
+ prependPath?: boolean | undefined;
257
+ /** Specify whether you want to ignore the proxy path of the incoming request. */
258
+ ignorePath?: boolean | undefined;
259
+ /** Local interface string to bind for outgoing connections. */
260
+ localAddress?: string | undefined;
261
+ /** Changes the origin of the host header to the target URL. */
262
+ changeOrigin?: boolean | undefined;
263
+ /** specify whether you want to keep letter case of response header key */
264
+ preserveHeaderKeyCase?: boolean | undefined;
265
+ /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
266
+ auth?: string | undefined;
267
+ /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
268
+ hostRewrite?: string | undefined;
269
+ /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
270
+ autoRewrite?: boolean | undefined;
271
+ /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
272
+ protocolRewrite?: string | undefined;
273
+ /** rewrites domain of set-cookie headers. */
274
+ cookieDomainRewrite?: false | string | {
275
+ [oldDomain: string]: string;
276
+ } | undefined;
277
+ /** rewrites path of set-cookie headers. Default: false */
278
+ cookiePathRewrite?: false | string | {
279
+ [oldPath: string]: string;
280
+ } | undefined;
281
+ /** object with extra headers to be added to target requests. */
282
+ headers?: {
283
+ [header: string]: string;
284
+ } | undefined;
285
+ /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
286
+ proxyTimeout?: number | undefined;
287
+ /** Timeout (in milliseconds) for incoming requests */
288
+ timeout?: number | undefined;
289
+ /** Specify whether you want to follow redirects. Default: false */
290
+ followRedirects?: boolean | undefined;
291
+ /** 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 */
292
+ selfHandleResponse?: boolean | undefined;
293
+ /** Buffer */
294
+ buffer?: stream.Stream | undefined;
295
+ /** Explicitly set the method type of the ProxyReq */
296
+ method?: string | undefined;
297
+ }
298
+ interface HttpProxyTargetDetailed {
299
+ host: string;
300
+ port: number;
301
+ protocol?: string | undefined;
302
+ hostname?: string | undefined;
303
+ socketPath?: string | undefined;
304
+ key?: string | undefined;
305
+ passphrase?: string | undefined;
306
+ pfx?: Buffer | string | undefined;
307
+ cert?: string | undefined;
308
+ ca?: string | undefined;
309
+ ciphers?: string | undefined;
310
+ secureProtocol?: string | undefined;
311
+ }
312
+ type HttpProxyTarget = HttpProxyTargetUrl | HttpProxyTargetDetailed;
313
+ type HttpProxyTargetUrl = string | Partial<url.Url>;
206
314
  export {};
package/dist/index.js CHANGED
@@ -4555,6 +4555,10 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4555
4555
  "code",
4556
4556
  "chunk"
4557
4557
  ]),
4558
+ createLink: new lite_tapable_namespaceObject.SyncWaterfallHook([
4559
+ "code",
4560
+ "chunk"
4561
+ ]),
4558
4562
  linkPreload: new lite_tapable_namespaceObject.SyncWaterfallHook([
4559
4563
  "code",
4560
4564
  "chunk"
@@ -4641,7 +4645,7 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4641
4645
  return createBuiltinPlugin(this.name, rawOptions);
4642
4646
  }
4643
4647
  }
4644
- let SubresourceIntegrityPlugin_PLUGIN_NAME = "SubresourceIntegrityPlugin", NATIVE_HTML_PLUGIN = "HtmlRspackPlugin", NativeSubresourceIntegrityPlugin = base_create(binding_.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
4648
+ let SubresourceIntegrityPlugin_PLUGIN_NAME = "SubresourceIntegrityPlugin", NATIVE_HTML_PLUGIN = "HtmlRspackPlugin", HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
4645
4649
  let htmlPlugin = "Disabled";
4646
4650
  return options.htmlPlugin === NATIVE_HTML_PLUGIN ? htmlPlugin = "Native" : "string" == typeof options.htmlPlugin && (htmlPlugin = "JavaScript"), {
4647
4651
  hashFuncNames: options.hashFuncNames,
@@ -4702,7 +4706,23 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4702
4706
  }
4703
4707
  }(tag);
4704
4708
  if (!tagSrc) return;
4705
- let src = (0, external_node_path_namespaceObject.relative)(publicPath, decodeURIComponent(tagSrc));
4709
+ let isUrlSrc = !1;
4710
+ try {
4711
+ let url = new URL(tagSrc);
4712
+ isUrlSrc = "http:" === url.protocol || "https:" === url.protocol;
4713
+ } catch (_) {
4714
+ isUrlSrc = tagSrc.startsWith("//");
4715
+ }
4716
+ let src = "";
4717
+ if (isUrlSrc) {
4718
+ if (!publicPath) return;
4719
+ let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ""), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, "");
4720
+ if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
4721
+ {
4722
+ let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`, publicPathWithScheme = protocolRelativePublicPath.startsWith("//") ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath;
4723
+ src = (0, external_node_path_namespaceObject.relative)(publicPathWithScheme, decodeURIComponent(tagSrcWithScheme));
4724
+ }
4725
+ } else src = (0, external_node_path_namespaceObject.relative)(publicPath, decodeURIComponent(tagSrc));
4706
4726
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
4707
4727
  let { createHash } = __webpack_require__("node:crypto");
4708
4728
  return hashFuncNames.map((hashFuncName)=>`${hashFuncName}-${createHash(hashFuncName).update("string" == typeof source ? Buffer.from(source, "utf-8") : source).digest("base64")}`).join(" ");
@@ -5732,7 +5752,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5732
5752
  }, applyExperimentsDefaults = (experiments, { development })=>{
5733
5753
  F(experiments, "cache", ()=>development), D(experiments, "futureDefaults", !1), D(experiments, "lazyCompilation", !1), D(experiments, "asyncWebAssembly", experiments.futureDefaults), D(experiments, "css", !!experiments.futureDefaults || void 0), D(experiments, "topLevelAwait", !0), D(experiments, "deferImport", !1), D(experiments, "buildHttp", void 0), experiments.buildHttp && "object" == typeof experiments.buildHttp && D(experiments.buildHttp, "upgrade", !1), D(experiments, "incremental", {}), "object" == typeof experiments.incremental && (D(experiments.incremental, "silent", !0), D(experiments.incremental, "make", !0), D(experiments.incremental, "inferAsyncModules", !0), D(experiments.incremental, "providedExports", !0), D(experiments.incremental, "dependenciesDiagnostics", !0), D(experiments.incremental, "sideEffects", !0), D(experiments.incremental, "buildChunkGraph", !1), D(experiments.incremental, "moduleIds", !0), D(experiments.incremental, "chunkIds", !0), D(experiments.incremental, "modulesHashes", !0), D(experiments.incremental, "modulesCodegen", !0), D(experiments.incremental, "modulesRuntimeRequirements", !0), D(experiments.incremental, "chunksRuntimeRequirements", !0), D(experiments.incremental, "chunksHashes", !0), D(experiments.incremental, "chunksRender", !0), D(experiments.incremental, "emitAssets", !0)), D(experiments, "rspackFuture", {}), D(experiments, "parallelCodeSplitting", !1), D(experiments, "parallelLoader", !1), D(experiments, "useInputFileSystem", !1), D(experiments, "inlineConst", !1), D(experiments, "inlineEnum", !1), D(experiments, "typeReexportsPresence", !1), D(experiments, "lazyBarrel", !0);
5734
5754
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5735
- "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.3"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5755
+ "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.5"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5736
5756
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, usedExports, inlineConst, deferImport })=>{
5737
5757
  if (assertNotNill(module1.parser), assertNotNill(module1.generator), cache ? D(module1, "unsafeCache", /[\\/]node_modules[\\/]/) : D(module1, "unsafeCache", !1), F(module1.parser, "asset", ()=>({})), assertNotNill(module1.parser.asset), F(module1.parser.asset, "dataUrlCondition", ()=>({})), "object" == typeof module1.parser.asset.dataUrlCondition && D(module1.parser.asset.dataUrlCondition, "maxSize", 8096), F(module1.parser, "javascript", ()=>({})), assertNotNill(module1.parser.javascript), ((parserOptions, { usedExports, inlineConst, deferImport })=>{
5738
5758
  D(parserOptions, "dynamicImportMode", "lazy"), D(parserOptions, "dynamicImportPrefetch", !1), D(parserOptions, "dynamicImportPreload", !1), D(parserOptions, "url", !0), D(parserOptions, "exprContextCritical", !0), D(parserOptions, "unknownContextCritical", !0), D(parserOptions, "wrappedContextCritical", !1), D(parserOptions, "wrappedContextRegExp", /.*/), D(parserOptions, "strictExportPresence", !1), D(parserOptions, "requireAsExpression", !0), D(parserOptions, "requireDynamic", !0), D(parserOptions, "requireResolve", !0), D(parserOptions, "commonjs", !0), D(parserOptions, "importDynamic", !0), D(parserOptions, "worker", [
@@ -7382,7 +7402,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7382
7402
  });
7383
7403
  }
7384
7404
  }
7385
- let CORE_VERSION = "1.6.3", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7405
+ let CORE_VERSION = "1.6.5", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7386
7406
 
7387
7407
  Help:
7388
7408
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -8498,6 +8518,13 @@ Help:
8498
8518
  return queried.call(data.code, data.chunk);
8499
8519
  };
8500
8520
  }),
8521
+ registerRuntimePluginCreateLinkTaps: createTap5(binding_default().RegisterJsTapKind.RuntimePluginCreateLink, function() {
8522
+ return RuntimePlugin.getCompilationHooks(getCompiler6().__internal__get_compilation()).createLink;
8523
+ }, function(queried) {
8524
+ return function(data) {
8525
+ return queried.call(data.code, data.chunk);
8526
+ };
8527
+ }),
8501
8528
  registerRuntimePluginLinkPreloadTaps: createTap5(binding_default().RegisterJsTapKind.RuntimePluginLinkPreload, function() {
8502
8529
  return RuntimePlugin.getCompilationHooks(getCompiler6().__internal__get_compilation()).linkPreload;
8503
8530
  }, function(queried) {
@@ -8675,7 +8702,7 @@ Help:
8675
8702
  obj.children = this.stats.map((stat, idx)=>{
8676
8703
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8677
8704
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8678
- }), childOptions.version && (obj.rspackVersion = "1.6.3", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8705
+ }), childOptions.version && (obj.rspackVersion = "1.6.5", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8679
8706
  let mapError = (j, obj)=>({
8680
8707
  ...obj,
8681
8708
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9574,7 +9601,7 @@ Help:
9574
9601
  object.hash = context.getStatsCompilation(compilation).hash;
9575
9602
  },
9576
9603
  version: (object)=>{
9577
- object.version = "5.75.0", object.rspackVersion = "1.6.3";
9604
+ object.version = "5.75.0", object.rspackVersion = "1.6.5";
9578
9605
  },
9579
9606
  env: (object, _compilation, _context, { _env })=>{
9580
9607
  object.env = _env;
@@ -11793,7 +11820,7 @@ Help:
11793
11820
  let _options = JSON.stringify(options || {});
11794
11821
  return binding_default().transform(source, _options);
11795
11822
  }
11796
- let exports_rspackVersion = "1.6.3", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
11823
+ let exports_rspackVersion = "1.6.5", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
11797
11824
  getNormalizedRspackOptions: getNormalizedRspackOptions,
11798
11825
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
11799
11826
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -40,10 +40,10 @@
40
40
  "@ast-grep/napi": "^0.39.9",
41
41
  "@napi-rs/wasm-runtime": "1.0.7",
42
42
  "@rsbuild/plugin-node-polyfill": "^1.4.2",
43
- "@rslib/core": "0.17.1",
43
+ "@rslib/core": "0.18.1",
44
44
  "@swc/types": "0.1.25",
45
45
  "@types/node": "^20.19.25",
46
- "@types/watchpack": "^2.4.4",
46
+ "@types/watchpack": "^2.4.5",
47
47
  "browserslist-load-config": "^1.0.1",
48
48
  "enhanced-resolve": "5.18.3",
49
49
  "glob-to-regexp": "^0.4.1",
@@ -58,7 +58,7 @@
58
58
  "dependencies": {
59
59
  "@module-federation/runtime-tools": "0.21.4",
60
60
  "@rspack/lite-tapable": "1.1.0",
61
- "@rspack/binding": "1.6.3"
61
+ "@rspack/binding": "1.6.5"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@swc/helpers": ">=0.5.1"