@rsbuild/core 2.0.11 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/756.js CHANGED
@@ -3483,7 +3483,7 @@ function createPublicContext(context) {
3483
3483
  async function createContext(options, userConfig, logger) {
3484
3484
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3485
3485
  return {
3486
- version: "2.0.11",
3486
+ version: "2.0.13",
3487
3487
  rootPath,
3488
3488
  distPath: '',
3489
3489
  cachePath,
@@ -4355,6 +4355,450 @@ function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefi
4355
4355
  rawPublicVars
4356
4356
  };
4357
4357
  }
4358
+ let mimes = {
4359
+ "3g2": "video/3gpp2",
4360
+ "3gp": "video/3gpp",
4361
+ "3gpp": "video/3gpp",
4362
+ "3mf": "model/3mf",
4363
+ aac: "audio/aac",
4364
+ ac: "application/pkix-attr-cert",
4365
+ adp: "audio/adpcm",
4366
+ adts: "audio/aac",
4367
+ ai: "application/postscript",
4368
+ aml: "application/automationml-aml+xml",
4369
+ amlx: "application/automationml-amlx+zip",
4370
+ amr: "audio/amr",
4371
+ apng: "image/apng",
4372
+ appcache: "text/cache-manifest",
4373
+ appinstaller: "application/appinstaller",
4374
+ appx: "application/appx",
4375
+ appxbundle: "application/appxbundle",
4376
+ asc: "application/pgp-keys",
4377
+ atom: "application/atom+xml",
4378
+ atomcat: "application/atomcat+xml",
4379
+ atomdeleted: "application/atomdeleted+xml",
4380
+ atomsvc: "application/atomsvc+xml",
4381
+ au: "audio/basic",
4382
+ avci: "image/avci",
4383
+ avcs: "image/avcs",
4384
+ avif: "image/avif",
4385
+ aw: "application/applixware",
4386
+ bdoc: "application/bdoc",
4387
+ bin: "application/octet-stream",
4388
+ bmp: "image/bmp",
4389
+ bpk: "application/octet-stream",
4390
+ btf: "image/prs.btif",
4391
+ btif: "image/prs.btif",
4392
+ buffer: "application/octet-stream",
4393
+ ccxml: "application/ccxml+xml",
4394
+ cdfx: "application/cdfx+xml",
4395
+ cdmia: "application/cdmi-capability",
4396
+ cdmic: "application/cdmi-container",
4397
+ cdmid: "application/cdmi-domain",
4398
+ cdmio: "application/cdmi-object",
4399
+ cdmiq: "application/cdmi-queue",
4400
+ cer: "application/pkix-cert",
4401
+ cgm: "image/cgm",
4402
+ cjs: "application/node",
4403
+ class: "application/java-vm",
4404
+ coffee: "text/coffeescript",
4405
+ conf: "text/plain",
4406
+ cpl: "application/cpl+xml",
4407
+ cpt: "application/mac-compactpro",
4408
+ crl: "application/pkix-crl",
4409
+ css: "text/css",
4410
+ csv: "text/csv",
4411
+ cu: "application/cu-seeme",
4412
+ cwl: "application/cwl",
4413
+ cww: "application/prs.cww",
4414
+ davmount: "application/davmount+xml",
4415
+ dbk: "application/docbook+xml",
4416
+ deb: "application/octet-stream",
4417
+ def: "text/plain",
4418
+ deploy: "application/octet-stream",
4419
+ dib: "image/bmp",
4420
+ "disposition-notification": "message/disposition-notification",
4421
+ dist: "application/octet-stream",
4422
+ distz: "application/octet-stream",
4423
+ dll: "application/octet-stream",
4424
+ dmg: "application/octet-stream",
4425
+ dms: "application/octet-stream",
4426
+ doc: "application/msword",
4427
+ dot: "application/msword",
4428
+ dpx: "image/dpx",
4429
+ drle: "image/dicom-rle",
4430
+ dsc: "text/prs.lines.tag",
4431
+ dssc: "application/dssc+der",
4432
+ dtd: "application/xml-dtd",
4433
+ dump: "application/octet-stream",
4434
+ dwd: "application/atsc-dwd+xml",
4435
+ ear: "application/java-archive",
4436
+ ecma: "application/ecmascript",
4437
+ elc: "application/octet-stream",
4438
+ emf: "image/emf",
4439
+ eml: "message/rfc822",
4440
+ emma: "application/emma+xml",
4441
+ emotionml: "application/emotionml+xml",
4442
+ eps: "application/postscript",
4443
+ epub: "application/epub+zip",
4444
+ exe: "application/octet-stream",
4445
+ exi: "application/exi",
4446
+ exp: "application/express",
4447
+ exr: "image/aces",
4448
+ ez: "application/andrew-inset",
4449
+ fdf: "application/fdf",
4450
+ fdt: "application/fdt+xml",
4451
+ fits: "image/fits",
4452
+ g3: "image/g3fax",
4453
+ gbr: "application/rpki-ghostbusters",
4454
+ geojson: "application/geo+json",
4455
+ gif: "image/gif",
4456
+ glb: "model/gltf-binary",
4457
+ gltf: "model/gltf+json",
4458
+ gml: "application/gml+xml",
4459
+ gpx: "application/gpx+xml",
4460
+ gram: "application/srgs",
4461
+ grxml: "application/srgs+xml",
4462
+ gxf: "application/gxf",
4463
+ gz: "application/gzip",
4464
+ h261: "video/h261",
4465
+ h263: "video/h263",
4466
+ h264: "video/h264",
4467
+ heic: "image/heic",
4468
+ heics: "image/heic-sequence",
4469
+ heif: "image/heif",
4470
+ heifs: "image/heif-sequence",
4471
+ hej2: "image/hej2k",
4472
+ held: "application/atsc-held+xml",
4473
+ hjson: "application/hjson",
4474
+ hlp: "application/winhlp",
4475
+ hqx: "application/mac-binhex40",
4476
+ hsj2: "image/hsj2",
4477
+ htm: "text/html",
4478
+ html: "text/html",
4479
+ ics: "text/calendar",
4480
+ ief: "image/ief",
4481
+ ifb: "text/calendar",
4482
+ iges: "model/iges",
4483
+ igs: "model/iges",
4484
+ img: "application/octet-stream",
4485
+ in: "text/plain",
4486
+ ini: "text/plain",
4487
+ ink: "application/inkml+xml",
4488
+ inkml: "application/inkml+xml",
4489
+ ipfix: "application/ipfix",
4490
+ iso: "application/octet-stream",
4491
+ its: "application/its+xml",
4492
+ jade: "text/jade",
4493
+ jar: "application/java-archive",
4494
+ jhc: "image/jphc",
4495
+ jls: "image/jls",
4496
+ jp2: "image/jp2",
4497
+ jpe: "image/jpeg",
4498
+ jpeg: "image/jpeg",
4499
+ jpf: "image/jpx",
4500
+ jpg: "image/jpeg",
4501
+ jpg2: "image/jp2",
4502
+ jpgm: "image/jpm",
4503
+ jpgv: "video/jpeg",
4504
+ jph: "image/jph",
4505
+ jpm: "image/jpm",
4506
+ jpx: "image/jpx",
4507
+ js: "text/javascript",
4508
+ json: "application/json",
4509
+ json5: "application/json5",
4510
+ jsonld: "application/ld+json",
4511
+ jsonml: "application/jsonml+json",
4512
+ jsx: "text/jsx",
4513
+ jt: "model/jt",
4514
+ jxl: "image/jxl",
4515
+ jxr: "image/jxr",
4516
+ jxra: "image/jxra",
4517
+ jxrs: "image/jxrs",
4518
+ jxs: "image/jxs",
4519
+ jxsc: "image/jxsc",
4520
+ jxsi: "image/jxsi",
4521
+ jxss: "image/jxss",
4522
+ kar: "audio/midi",
4523
+ ktx: "image/ktx",
4524
+ ktx2: "image/ktx2",
4525
+ less: "text/less",
4526
+ lgr: "application/lgr+xml",
4527
+ list: "text/plain",
4528
+ litcoffee: "text/coffeescript",
4529
+ log: "text/plain",
4530
+ lostxml: "application/lost+xml",
4531
+ lrf: "application/octet-stream",
4532
+ m1v: "video/mpeg",
4533
+ m21: "application/mp21",
4534
+ m2a: "audio/mpeg",
4535
+ m2t: "video/mp2t",
4536
+ m2ts: "video/mp2t",
4537
+ m2v: "video/mpeg",
4538
+ m3a: "audio/mpeg",
4539
+ m4a: "audio/mp4",
4540
+ m4p: "application/mp4",
4541
+ m4s: "video/iso.segment",
4542
+ ma: "application/mathematica",
4543
+ mads: "application/mads+xml",
4544
+ maei: "application/mmt-aei+xml",
4545
+ man: "text/troff",
4546
+ manifest: "text/cache-manifest",
4547
+ map: "application/json",
4548
+ mar: "application/octet-stream",
4549
+ markdown: "text/markdown",
4550
+ mathml: "application/mathml+xml",
4551
+ mb: "application/mathematica",
4552
+ mbox: "application/mbox",
4553
+ md: "text/markdown",
4554
+ mdx: "text/mdx",
4555
+ me: "text/troff",
4556
+ mesh: "model/mesh",
4557
+ meta4: "application/metalink4+xml",
4558
+ metalink: "application/metalink+xml",
4559
+ mets: "application/mets+xml",
4560
+ mft: "application/rpki-manifest",
4561
+ mid: "audio/midi",
4562
+ midi: "audio/midi",
4563
+ mime: "message/rfc822",
4564
+ mj2: "video/mj2",
4565
+ mjp2: "video/mj2",
4566
+ mjs: "text/javascript",
4567
+ mml: "text/mathml",
4568
+ mods: "application/mods+xml",
4569
+ mov: "video/quicktime",
4570
+ mp2: "audio/mpeg",
4571
+ mp21: "application/mp21",
4572
+ mp2a: "audio/mpeg",
4573
+ mp3: "audio/mpeg",
4574
+ mp4: "video/mp4",
4575
+ mp4a: "audio/mp4",
4576
+ mp4s: "application/mp4",
4577
+ mp4v: "video/mp4",
4578
+ mpd: "application/dash+xml",
4579
+ mpe: "video/mpeg",
4580
+ mpeg: "video/mpeg",
4581
+ mpf: "application/media-policy-dataset+xml",
4582
+ mpg: "video/mpeg",
4583
+ mpg4: "video/mp4",
4584
+ mpga: "audio/mpeg",
4585
+ mpp: "application/dash-patch+xml",
4586
+ mrc: "application/marc",
4587
+ mrcx: "application/marcxml+xml",
4588
+ ms: "text/troff",
4589
+ mscml: "application/mediaservercontrol+xml",
4590
+ msh: "model/mesh",
4591
+ msi: "application/octet-stream",
4592
+ msix: "application/msix",
4593
+ msixbundle: "application/msixbundle",
4594
+ msm: "application/octet-stream",
4595
+ msp: "application/octet-stream",
4596
+ mtl: "model/mtl",
4597
+ mts: "video/mp2t",
4598
+ musd: "application/mmt-usd+xml",
4599
+ mxf: "application/mxf",
4600
+ mxmf: "audio/mobile-xmf",
4601
+ mxml: "application/xv+xml",
4602
+ n3: "text/n3",
4603
+ nb: "application/mathematica",
4604
+ nq: "application/n-quads",
4605
+ nt: "application/n-triples",
4606
+ obj: "model/obj",
4607
+ oda: "application/oda",
4608
+ oga: "audio/ogg",
4609
+ ogg: "audio/ogg",
4610
+ ogv: "video/ogg",
4611
+ ogx: "application/ogg",
4612
+ omdoc: "application/omdoc+xml",
4613
+ onepkg: "application/onenote",
4614
+ onetmp: "application/onenote",
4615
+ onetoc: "application/onenote",
4616
+ onetoc2: "application/onenote",
4617
+ opf: "application/oebps-package+xml",
4618
+ opus: "audio/ogg",
4619
+ otf: "font/otf",
4620
+ owl: "application/rdf+xml",
4621
+ oxps: "application/oxps",
4622
+ p10: "application/pkcs10",
4623
+ p7c: "application/pkcs7-mime",
4624
+ p7m: "application/pkcs7-mime",
4625
+ p7s: "application/pkcs7-signature",
4626
+ p8: "application/pkcs8",
4627
+ pdf: "application/pdf",
4628
+ pfr: "application/font-tdpfr",
4629
+ pgp: "application/pgp-encrypted",
4630
+ pkg: "application/octet-stream",
4631
+ pki: "application/pkixcmp",
4632
+ pkipath: "application/pkix-pkipath",
4633
+ pls: "application/pls+xml",
4634
+ png: "image/png",
4635
+ prc: "model/prc",
4636
+ prf: "application/pics-rules",
4637
+ provx: "application/provenance+xml",
4638
+ ps: "application/postscript",
4639
+ pskcxml: "application/pskc+xml",
4640
+ pti: "image/prs.pti",
4641
+ qt: "video/quicktime",
4642
+ raml: "application/raml+yaml",
4643
+ rapd: "application/route-apd+xml",
4644
+ rdf: "application/rdf+xml",
4645
+ relo: "application/p2p-overlay+xml",
4646
+ rif: "application/reginfo+xml",
4647
+ rl: "application/resource-lists+xml",
4648
+ rld: "application/resource-lists-diff+xml",
4649
+ rmi: "audio/midi",
4650
+ rnc: "application/relax-ng-compact-syntax",
4651
+ rng: "application/xml",
4652
+ roa: "application/rpki-roa",
4653
+ roff: "text/troff",
4654
+ rq: "application/sparql-query",
4655
+ rs: "application/rls-services+xml",
4656
+ rsat: "application/atsc-rsat+xml",
4657
+ rsd: "application/rsd+xml",
4658
+ rsheet: "application/urc-ressheet+xml",
4659
+ rss: "application/rss+xml",
4660
+ rtf: "text/rtf",
4661
+ rtx: "text/richtext",
4662
+ rusd: "application/route-usd+xml",
4663
+ s3m: "audio/s3m",
4664
+ sbml: "application/sbml+xml",
4665
+ scq: "application/scvp-cv-request",
4666
+ scs: "application/scvp-cv-response",
4667
+ sdp: "application/sdp",
4668
+ senmlx: "application/senml+xml",
4669
+ sensmlx: "application/sensml+xml",
4670
+ ser: "application/java-serialized-object",
4671
+ setpay: "application/set-payment-initiation",
4672
+ setreg: "application/set-registration-initiation",
4673
+ sgi: "image/sgi",
4674
+ sgm: "text/sgml",
4675
+ sgml: "text/sgml",
4676
+ shex: "text/shex",
4677
+ shf: "application/shf+xml",
4678
+ shtml: "text/html",
4679
+ sieve: "application/sieve",
4680
+ sig: "application/pgp-signature",
4681
+ sil: "audio/silk",
4682
+ silo: "model/mesh",
4683
+ siv: "application/sieve",
4684
+ slim: "text/slim",
4685
+ slm: "text/slim",
4686
+ sls: "application/route-s-tsid+xml",
4687
+ smi: "application/smil+xml",
4688
+ smil: "application/smil+xml",
4689
+ snd: "audio/basic",
4690
+ so: "application/octet-stream",
4691
+ spdx: "text/spdx",
4692
+ spp: "application/scvp-vp-response",
4693
+ spq: "application/scvp-vp-request",
4694
+ spx: "audio/ogg",
4695
+ sql: "application/sql",
4696
+ sru: "application/sru+xml",
4697
+ srx: "application/sparql-results+xml",
4698
+ ssdl: "application/ssdl+xml",
4699
+ ssml: "application/ssml+xml",
4700
+ stk: "application/hyperstudio",
4701
+ stl: "model/stl",
4702
+ stpx: "model/step+xml",
4703
+ stpxz: "model/step-xml+zip",
4704
+ stpz: "model/step+zip",
4705
+ styl: "text/stylus",
4706
+ stylus: "text/stylus",
4707
+ svg: "image/svg+xml",
4708
+ svgz: "image/svg+xml",
4709
+ swidtag: "application/swid+xml",
4710
+ t: "text/troff",
4711
+ t38: "image/t38",
4712
+ td: "application/urc-targetdesc+xml",
4713
+ tei: "application/tei+xml",
4714
+ teicorpus: "application/tei+xml",
4715
+ text: "text/plain",
4716
+ tfi: "application/thraud+xml",
4717
+ tfx: "image/tiff-fx",
4718
+ tif: "image/tiff",
4719
+ tiff: "image/tiff",
4720
+ toml: "application/toml",
4721
+ tr: "text/troff",
4722
+ trig: "application/trig",
4723
+ ts: "video/mp2t",
4724
+ tsd: "application/timestamped-data",
4725
+ tsv: "text/tab-separated-values",
4726
+ ttc: "font/collection",
4727
+ ttf: "font/ttf",
4728
+ ttl: "text/turtle",
4729
+ ttml: "application/ttml+xml",
4730
+ txt: "text/plain",
4731
+ u3d: "model/u3d",
4732
+ u8dsn: "message/global-delivery-status",
4733
+ u8hdr: "message/global-headers",
4734
+ u8mdn: "message/global-disposition-notification",
4735
+ u8msg: "message/global",
4736
+ ubj: "application/ubjson",
4737
+ uri: "text/uri-list",
4738
+ uris: "text/uri-list",
4739
+ urls: "text/uri-list",
4740
+ vcard: "text/vcard",
4741
+ vrml: "model/vrml",
4742
+ vtt: "text/vtt",
4743
+ vxml: "application/voicexml+xml",
4744
+ war: "application/java-archive",
4745
+ wasm: "application/wasm",
4746
+ wav: "audio/wav",
4747
+ weba: "audio/webm",
4748
+ webm: "video/webm",
4749
+ webmanifest: "application/manifest+json",
4750
+ webp: "image/webp",
4751
+ wgsl: "text/wgsl",
4752
+ wgt: "application/widget",
4753
+ wif: "application/watcherinfo+xml",
4754
+ wmf: "image/wmf",
4755
+ woff: "font/woff",
4756
+ woff2: "font/woff2",
4757
+ wrl: "model/vrml",
4758
+ wsdl: "application/wsdl+xml",
4759
+ wspolicy: "application/wspolicy+xml",
4760
+ x3d: "model/x3d+xml",
4761
+ x3db: "model/x3d+fastinfoset",
4762
+ x3dbz: "model/x3d+binary",
4763
+ x3dv: "model/x3d-vrml",
4764
+ x3dvz: "model/x3d+vrml",
4765
+ x3dz: "model/x3d+xml",
4766
+ xaml: "application/xaml+xml",
4767
+ xav: "application/xcap-att+xml",
4768
+ xca: "application/xcap-caps+xml",
4769
+ xcs: "application/calendar+xml",
4770
+ xdf: "application/xcap-diff+xml",
4771
+ xdssc: "application/dssc+xml",
4772
+ xel: "application/xcap-el+xml",
4773
+ xenc: "application/xenc+xml",
4774
+ xer: "application/patch-ops-error+xml",
4775
+ xfdf: "application/xfdf",
4776
+ xht: "application/xhtml+xml",
4777
+ xhtml: "application/xhtml+xml",
4778
+ xhvml: "application/xv+xml",
4779
+ xlf: "application/xliff+xml",
4780
+ xm: "audio/xm",
4781
+ xml: "text/xml",
4782
+ xns: "application/xcap-ns+xml",
4783
+ xop: "application/xop+xml",
4784
+ xpl: "application/xproc+xml",
4785
+ xsd: "application/xml",
4786
+ xsf: "application/prs.xsf+xml",
4787
+ xsl: "application/xml",
4788
+ xslt: "application/xml",
4789
+ xspf: "application/xspf+xml",
4790
+ xvm: "application/xv+xml",
4791
+ xvml: "application/xv+xml",
4792
+ yaml: "text/yaml",
4793
+ yang: "application/yang",
4794
+ yin: "application/yin+xml",
4795
+ yml: "text/yaml",
4796
+ zip: "application/zip"
4797
+ };
4798
+ function mrmime_lookup(extn) {
4799
+ let tmp = ('' + extn).trim().toLowerCase(), idx = tmp.lastIndexOf('.');
4800
+ return mimes[!~idx ? tmp : tmp.substring(++idx)];
4801
+ }
4358
4802
  let chainStaticAssetRule = ({ emit, rule, maxSize, filename, assetType })=>{
4359
4803
  let generatorOptions = {
4360
4804
  filename
@@ -5424,6 +5868,14 @@ async function open_open({ port, routes, config, protocol, clearCache, logger })
5424
5868
  let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${protocol}://${host}:${port}`;
5425
5869
  for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url, logger), openedURLs.push(url));
5426
5870
  }
5871
+ let getServerUrlFromClientConfig = async (config, context)=>{
5872
+ let { devServer } = context;
5873
+ if (!devServer) return;
5874
+ let { client } = config.dev, hasClientHost = !!client.host, hasClientPort = void 0 !== client.port && '' !== client.port;
5875
+ if (!hasClientHost && !hasClientPort) return;
5876
+ let protocol = client.protocol ? `${'wss' === client.protocol ? 'https' : 'http'}:` : '', hostname = await getHostInUrl(client.host || devServer.hostname), port = client.port && '<port>' !== client.port ? client.port : devServer.port;
5877
+ return `${protocol}//${hostname}:${port}`;
5878
+ };
5427
5879
  function recursiveChunkGroup(chunkGroup, visited = new Set()) {
5428
5880
  if (visited.has(chunkGroup)) return [];
5429
5881
  visited.add(chunkGroup);
@@ -5566,6 +6018,17 @@ let HtmlResourceHintsPlugin_defaultOptions = {
5566
6018
  function filterResourceHints(resourceHints, scripts) {
5567
6019
  return resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href));
5568
6020
  }
6021
+ function getResourceHintKey(resourceHint) {
6022
+ return `${resourceHint.attributes.rel}:${resourceHint.attributes.href}`;
6023
+ }
6024
+ function mergeResourceHints(resourceHintGroups, scripts) {
6025
+ let links = [], seen = new Set();
6026
+ for (let { links: groupLinks, dedupe } of resourceHintGroups)for (let link of dedupe ? filterResourceHints(groupLinks, scripts) : groupLinks){
6027
+ let key = getResourceHintKey(link);
6028
+ seen.has(key) || (seen.add(key), links.push(link));
6029
+ }
6030
+ return links;
6031
+ }
5569
6032
  function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
5570
6033
  let extractedChunks = extractChunks(compilation, options.type), sortedFilteredFiles = ((files, include, exclude)=>{
5571
6034
  let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
@@ -5617,16 +6080,19 @@ class HtmlResourceHintsPlugin {
5617
6080
  isDev;
5618
6081
  getHTMLPlugin;
5619
6082
  constructor(options, type, HTMLCount, isDev, getHTMLPlugin){
5620
- this.options = {
5621
- ...HtmlResourceHintsPlugin_defaultOptions,
5622
- ...options
5623
- }, this.type = type, this.HTMLCount = HTMLCount, this.isDev = isDev, this.getHTMLPlugin = getHTMLPlugin;
6083
+ this.options = helpers_castArray(options).map((option)=>({
6084
+ ...HtmlResourceHintsPlugin_defaultOptions,
6085
+ ...option
6086
+ })), this.type = type, this.HTMLCount = HTMLCount, this.isDev = isDev, this.getHTMLPlugin = getHTMLPlugin;
5624
6087
  }
5625
6088
  apply(compiler) {
5626
6089
  compiler.hooks.compilation.tap(this.name, (compilation)=>{
5627
6090
  let pluginHooks = this.getHTMLPlugin().getCompilationHooks(compilation), pluginName = `HTML${upperFirst(this.type)}Plugin`;
5628
- pluginHooks.beforeAssetTagGeneration.tap(pluginName, (data)=>(this.resourceHints = generateLinks(this.options, this.type, compilation, data, this.HTMLCount, this.isDev), data)), pluginHooks.alterAssetTags.tap(pluginName, (data)=>(this.resourceHints && (data.assetTags.styles = [
5629
- ...this.options.dedupe ? filterResourceHints(this.resourceHints, data.assetTags.scripts) : this.resourceHints,
6091
+ pluginHooks.beforeAssetTagGeneration.tap(pluginName, (data)=>(this.resourceHints = this.options.map((option)=>({
6092
+ links: generateLinks(option, this.type, compilation, data, this.HTMLCount, this.isDev),
6093
+ dedupe: !1 !== option.dedupe
6094
+ })), data)), pluginHooks.alterAssetTags.tap(pluginName, (data)=>(this.resourceHints.length && (data.assetTags.styles = [
6095
+ ...mergeResourceHints(this.resourceHints, data.assetTags.scripts),
5630
6096
  ...data.assetTags.styles
5631
6097
  ]), data));
5632
6098
  });
@@ -5638,7 +6104,17 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
5638
6104
  rel,
5639
6105
  ...option
5640
6106
  }
6107
+ })), appendExcludes = (options, excludes)=>{
6108
+ if (!excludes.length) return options;
6109
+ let optionsList = helpers_castArray(options).map((option)=>({
6110
+ ...option,
6111
+ exclude: option.exclude ? [
6112
+ ...helpers_castArray(option.exclude),
6113
+ ...excludes
6114
+ ] : excludes
5641
6115
  }));
6116
+ return Array.isArray(options) ? optionsList : optionsList[0];
6117
+ };
5642
6118
  function isTerminalTraceOutput(output) {
5643
6119
  return 'stdout' === output || 'stderr' === output;
5644
6120
  }
@@ -5993,17 +6469,15 @@ function getEtag(stat) {
5993
6469
  let mtime = stat.mtime.getTime().toString(16), size = stat.size.toString(16);
5994
6470
  return `W/"${size}-${mtime}"`;
5995
6471
  }
5996
- function createReadStreamOrReadFileSync(filename, outputFileSystem, start, end, byteLength) {
5997
- return {
5998
- bufferOrStream: outputFileSystem.createReadStream(filename, {
5999
- start,
6000
- end
6001
- }),
6002
- byteLength
6003
- };
6472
+ function createReadStream(filename, outputFileSystem, start, end) {
6473
+ return (0, outputFileSystem.createReadStream)(filename, {
6474
+ start,
6475
+ end,
6476
+ highWaterMark: 524288
6477
+ });
6004
6478
  }
6005
- async function getContentType(str) {
6006
- let { lookup } = await import("./mrmime.js"), mime = lookup(str);
6479
+ function getContentType(str) {
6480
+ let mime = mrmime_lookup(str);
6007
6481
  return !!mime && ((mime.startsWith('text/') || 'application/json' === mime || 'application/manifest+json' === mime) && (mime += '; charset=utf-8'), mime);
6008
6482
  }
6009
6483
  let BYTES_RANGE_REGEXP = /^ *bytes/i;
@@ -6015,6 +6489,84 @@ function parseHttpDate(date) {
6015
6489
  return 'number' == typeof timestamp ? timestamp : NaN;
6016
6490
  }
6017
6491
  let CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/;
6492
+ function getRequestHeader(headers, name) {
6493
+ let value = headers[name];
6494
+ return Array.isArray(value) ? value.join(',') : value;
6495
+ }
6496
+ function isConditionalGET(headers) {
6497
+ return !!(headers['if-match'] || headers['if-unmodified-since'] || headers['if-none-match'] || headers['if-modified-since']);
6498
+ }
6499
+ function isPreconditionFailure(headers, res) {
6500
+ let ifMatch = getRequestHeader(headers, 'if-match');
6501
+ if (ifMatch) {
6502
+ let etag = res.getHeader('ETag');
6503
+ return !etag || '*' !== ifMatch && parseTokenList(ifMatch).every((match)=>match !== etag && match !== `W/${etag}` && `W/${match}` !== etag);
6504
+ }
6505
+ let ifUnmodifiedSince = getRequestHeader(headers, 'if-unmodified-since');
6506
+ if (ifUnmodifiedSince) {
6507
+ let unmodifiedSince = parseHttpDate(ifUnmodifiedSince);
6508
+ if (!Number.isNaN(unmodifiedSince)) {
6509
+ let lastModified = parseHttpDate(String(res.getHeader('Last-Modified')));
6510
+ return Number.isNaN(lastModified) || lastModified > unmodifiedSince;
6511
+ }
6512
+ }
6513
+ return !1;
6514
+ }
6515
+ function isCachable(statusCode) {
6516
+ return statusCode >= 200 && statusCode < 300 || 304 === statusCode;
6517
+ }
6518
+ function isFresh(headers, resHeaders) {
6519
+ let cacheControl = getRequestHeader(headers, 'cache-control');
6520
+ if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) return !1;
6521
+ let noneMatch = getRequestHeader(headers, 'if-none-match'), modifiedSince = getRequestHeader(headers, 'if-modified-since');
6522
+ if (!noneMatch && !modifiedSince) return !1;
6523
+ if (noneMatch && '*' !== noneMatch) {
6524
+ if (!resHeaders.etag) return !1;
6525
+ let matches = parseTokenList(noneMatch), etagStale = !0;
6526
+ for(let i = 0; i < matches.length; i++){
6527
+ let match = matches[i];
6528
+ if (match === resHeaders.etag || match === `W/${resHeaders.etag}` || `W/${match}` === resHeaders.etag) {
6529
+ etagStale = !1;
6530
+ break;
6531
+ }
6532
+ }
6533
+ if (etagStale) return !1;
6534
+ }
6535
+ if (noneMatch) return !0;
6536
+ if (modifiedSince) {
6537
+ let lastModified = resHeaders['last-modified'];
6538
+ if (!lastModified || !(parseHttpDate(String(lastModified)) <= parseHttpDate(modifiedSince))) return !1;
6539
+ }
6540
+ return !0;
6541
+ }
6542
+ function isRangeFresh(headers, res) {
6543
+ let ifRange = getRequestHeader(headers, 'if-range');
6544
+ if (!ifRange) return !0;
6545
+ if (-1 !== ifRange.indexOf('"')) {
6546
+ let etag = res.getHeader('ETag');
6547
+ return !etag || !(ifRange.startsWith('W/') || etag.startsWith('W/')) && ifRange === etag;
6548
+ }
6549
+ let lastModified = res.getHeader('Last-Modified');
6550
+ return !lastModified || parseHttpDate(lastModified) <= parseHttpDate(ifRange);
6551
+ }
6552
+ function getRangeHeader(headers) {
6553
+ let range = getRequestHeader(headers, 'range');
6554
+ if (range && BYTES_RANGE_REGEXP.test(range)) return range;
6555
+ }
6556
+ function getOffsetAndLenFromRange(range) {
6557
+ let { start, end } = range;
6558
+ return [
6559
+ start,
6560
+ end - start + 1
6561
+ ];
6562
+ }
6563
+ function calcStartAndEnd(start, len) {
6564
+ let end = Math.max(start, start + len - 1);
6565
+ return [
6566
+ start,
6567
+ end
6568
+ ];
6569
+ }
6018
6570
  function destroyStream(stream, suppress) {
6019
6571
  'function' == typeof stream.destroy && stream.destroy(), 'function' == typeof stream.close && stream.on('open', function onOpenClose(fd) {
6020
6572
  'number' == typeof fd && this.close();
@@ -6025,10 +6577,7 @@ let parseRangeHeaders = async (value)=>{
6025
6577
  return rangeParser(Number(len), rangeHeader, {
6026
6578
  combine: !0
6027
6579
  });
6028
- }, acceptedMethods = [
6029
- 'GET',
6030
- 'HEAD'
6031
- ];
6580
+ };
6032
6581
  function sendError(res, code) {
6033
6582
  let content = {
6034
6583
  400: 'Bad Request',
@@ -6063,83 +6612,8 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6063
6612
  });
6064
6613
  });
6065
6614
  }
6066
- if (req.method && !acceptedMethods.includes(req.method)) return void await goNext();
6067
- function isConditionalGET() {
6068
- return req.headers['if-match'] || req.headers['if-unmodified-since'] || req.headers['if-none-match'] || req.headers['if-modified-since'];
6069
- }
6070
- function isPreconditionFailure() {
6071
- let ifMatch = req.headers['if-match'];
6072
- if (ifMatch) {
6073
- let etag = res.getHeader('ETag');
6074
- return !etag || '*' !== ifMatch && parseTokenList(ifMatch).every((match)=>match !== etag && match !== `W/${etag}` && `W/${match}` !== etag);
6075
- }
6076
- let ifUnmodifiedSince = req.headers['if-unmodified-since'];
6077
- if (ifUnmodifiedSince) {
6078
- let unmodifiedSince = parseHttpDate(ifUnmodifiedSince);
6079
- if (!Number.isNaN(unmodifiedSince)) {
6080
- let lastModified = parseHttpDate(String(res.getHeader('Last-Modified')));
6081
- return Number.isNaN(lastModified) || lastModified > unmodifiedSince;
6082
- }
6083
- }
6084
- return !1;
6085
- }
6086
- function isCachable() {
6087
- return res.statusCode >= 200 && res.statusCode < 300 || 304 === res.statusCode;
6088
- }
6089
- function isFresh(resHeaders) {
6090
- let cacheControl = req.headers['cache-control'];
6091
- if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) return !1;
6092
- let noneMatch = req.headers['if-none-match'], modifiedSince = req.headers['if-modified-since'];
6093
- if (!noneMatch && !modifiedSince) return !1;
6094
- if (noneMatch && '*' !== noneMatch) {
6095
- if (!resHeaders.etag) return !1;
6096
- let matches = parseTokenList(noneMatch), etagStale = !0;
6097
- for(let i = 0; i < matches.length; i++){
6098
- let match = matches[i];
6099
- if (match === resHeaders.etag || match === `W/${resHeaders.etag}` || `W/${match}` === resHeaders.etag) {
6100
- etagStale = !1;
6101
- break;
6102
- }
6103
- }
6104
- if (etagStale) return !1;
6105
- }
6106
- if (noneMatch) return !0;
6107
- if (modifiedSince) {
6108
- let lastModified = resHeaders['last-modified'];
6109
- if (!lastModified || !(parseHttpDate(String(lastModified)) <= parseHttpDate(modifiedSince))) return !1;
6110
- }
6111
- return !0;
6112
- }
6113
- function isRangeFresh() {
6114
- let ifRange = req.headers['if-range'];
6115
- if (!ifRange) return !0;
6116
- if (-1 !== ifRange.indexOf('"')) {
6117
- let etag = res.getHeader('ETag');
6118
- return !etag || !!(etag && -1 !== ifRange.indexOf(etag));
6119
- }
6120
- let lastModified = res.getHeader('Last-Modified');
6121
- return !lastModified || parseHttpDate(lastModified) <= parseHttpDate(ifRange);
6122
- }
6123
- function getRangeHeader() {
6124
- let { range } = req.headers;
6125
- if (range && BYTES_RANGE_REGEXP.test(range)) return range;
6126
- }
6127
- function getOffsetAndLenFromRange(range) {
6128
- let { start, end } = range;
6129
- return [
6130
- start,
6131
- end - start + 1
6132
- ];
6133
- }
6134
- function calcStartAndEnd(start, len) {
6135
- let end = Math.max(start, start + len - 1);
6136
- return [
6137
- start,
6138
- end
6139
- ];
6140
- }
6141
- ready(async function processRequest() {
6142
- let bufferOrStream, byteLength;
6615
+ req.method && 'GET' !== req.method && 'HEAD' !== req.method ? await goNext() : ready(async function processRequest() {
6616
+ let readStream;
6143
6617
  if (!req.url) return void await goNext();
6144
6618
  let resolved = await getFileFromUrl(req.url, outputFileSystem, context);
6145
6619
  if (!resolved) return void await goNext();
@@ -6149,18 +6623,18 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6149
6623
  }
6150
6624
  let { fsStats, filename } = resolved, { size } = fsStats, len = size, offset = 0;
6151
6625
  if (!res.getHeader('Content-Type')) {
6152
- let contentType = await getContentType(filename);
6626
+ let contentType = getContentType(filename);
6153
6627
  contentType && res.setHeader('Content-Type', contentType);
6154
6628
  }
6155
6629
  res.getHeader('Accept-Ranges') || res.setHeader('Accept-Ranges', 'bytes');
6156
- let rangeHeader = getRangeHeader();
6630
+ let rangeHeader = getRangeHeader(req.headers);
6157
6631
  if (!res.getHeader('ETag') && fsStats) {
6158
6632
  let hash = getEtag(fsStats);
6159
6633
  res.setHeader('ETag', hash);
6160
6634
  }
6161
- if (isConditionalGET()) {
6162
- if (isPreconditionFailure()) return void sendError(res, 412);
6163
- if (404 === res.statusCode && (res.statusCode = 200), isCachable() && isFresh({
6635
+ if (isConditionalGET(req.headers)) {
6636
+ if (isPreconditionFailure(req.headers, res)) return void sendError(res, 412);
6637
+ if (404 === res.statusCode && (res.statusCode = 200), isCachable(res.statusCode) && isFresh(req.headers, {
6164
6638
  etag: res.getHeader('ETag'),
6165
6639
  'last-modified': res.getHeader('Last-Modified')
6166
6640
  })) {
@@ -6170,7 +6644,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6170
6644
  }
6171
6645
  if (rangeHeader) {
6172
6646
  let parsedRanges = await parseRangeHeaders(`${size}|${rangeHeader}`);
6173
- if (isRangeFresh() || (parsedRanges = []), -1 === parsedRanges) {
6647
+ if (isRangeFresh(req.headers, res) || (parsedRanges = []), -1 === parsedRanges) {
6174
6648
  logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, 416);
6175
6649
  return;
6176
6650
  }
@@ -6178,20 +6652,19 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6178
6652
  }
6179
6653
  let [start, end] = calcStartAndEnd(offset, len);
6180
6654
  try {
6181
- ({ bufferOrStream, byteLength } = createReadStreamOrReadFileSync(filename, outputFileSystem, start, end, len));
6655
+ readStream = createReadStream(filename, outputFileSystem, start, end);
6182
6656
  } catch {
6183
6657
  await goNext();
6184
6658
  return;
6185
6659
  }
6186
- if (res.setHeader('Content-Length', byteLength), 'HEAD' === req.method) {
6660
+ if (res.setHeader('Content-Length', len), 'HEAD' === req.method) {
6187
6661
  404 === res.statusCode && (res.statusCode = 200), res.end();
6188
6662
  return;
6189
6663
  }
6190
- if ('function' != typeof bufferOrStream.pipe) return void res.end(bufferOrStream);
6191
6664
  let cleanup = ()=>{
6192
- destroyStream(bufferOrStream, !0);
6665
+ destroyStream(readStream, !0);
6193
6666
  };
6194
- bufferOrStream.on('error', (error)=>{
6667
+ readStream.on('error', (error)=>{
6195
6668
  switch(cleanup(), error.code){
6196
6669
  case 'ENAMETOOLONG':
6197
6670
  case 'ENOENT':
@@ -6201,13 +6674,13 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6201
6674
  default:
6202
6675
  sendError(res, 500);
6203
6676
  }
6204
- }), bufferOrStream.pipe(res), on_finished_default()(res, cleanup);
6677
+ }), readStream.pipe(res), on_finished_default()(res, cleanup);
6205
6678
  });
6206
6679
  };
6207
6680
  }
6208
6681
  async function setupOutputFileSystem(writeToDisk, compilers) {
6209
6682
  if (!0 !== writeToDisk) {
6210
- let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.3/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6683
+ let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.6/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6211
6684
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
6212
6685
  }
6213
6686
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -6251,12 +6724,13 @@ function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort })
6251
6724
  let { target } = compiler.options;
6252
6725
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
6253
6726
  })(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
6254
- let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), clientConfig = {
6727
+ let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), { webSocketUrlResolver, ...clientConfig } = {
6255
6728
  ...config.dev.client
6256
6729
  };
6257
6730
  '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
6258
- let hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
6731
+ let resolverPath = webSocketUrlResolver && !external_node_path_isAbsolute(webSocketUrlResolver) ? join(compiler.context, webSocketUrlResolver) : webSocketUrlResolver, hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
6259
6732
  ${!0 === (overlay1 = overlay = config.dev.client.overlay) || 'object' == typeof overlay1 && !1 !== overlay1.errors || isRuntimeOverlayEnabled(overlay) ? `import '${toPosixPath(join(CLIENT_PATH, 'overlay.js'))}';` : ''}
6733
+ ${resolverPath ? `import urlResolver from ${JSON.stringify(toPosixPath(resolverPath))};` : ''}
6260
6734
  init(
6261
6735
  '${token}',
6262
6736
  ${JSON.stringify(clientConfig)},
@@ -6265,7 +6739,7 @@ init(
6265
6739
  ${JSON.stringify(config.server.base)},
6266
6740
  ${liveReloadEnabled},
6267
6741
  ${!!config.dev.browserLogs},
6268
- ${JSON.stringify(config.dev.client.logLevel)}
6742
+ ${JSON.stringify(config.dev.client.logLevel)}${resolverPath ? ',\n urlResolver' : ''}
6269
6743
  )
6270
6744
  `;
6271
6745
  new core_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
@@ -7095,7 +7569,7 @@ async function createProxyMiddleware(proxyOptions, logger) {
7095
7569
  };
7096
7570
  }
7097
7571
  let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer, middlewares, postCallbacks })=>{
7098
- let upgradeEvents = [], { server } = config, { logger } = context;
7572
+ let launchEditorHandlerPromise, upgradeEvents = [], { server } = config, { logger } = context;
7099
7573
  if (server.cors) {
7100
7574
  let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.6/node_modules/cors/lib/index.js", 23));
7101
7575
  middlewares.use(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
@@ -7113,11 +7587,18 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
7113
7587
  let { compiler } = buildManager;
7114
7588
  (compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.use(core_rspack.lazyCompilationMiddleware(compiler));
7115
7589
  }
7116
- server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
7590
+ if (server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
7117
7591
  base: server.base
7118
- }));
7119
- let { default: launchEditorMiddleware } = await import("./launch-editor-middleware.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/launch-editor-middleware@2.14.0/node_modules/launch-editor-middleware/index.js", 23));
7120
- if (middlewares.use('/__open-in-editor', launchEditorMiddleware()), middlewares.use((({ environments, logger })=>async function viewingServedFilesMiddleware(req, res, next) {
7592
+ })), middlewares.use('/__open-in-editor', async (req, res, next)=>{
7593
+ try {
7594
+ (await (launchEditorHandlerPromise ??= (async ()=>{
7595
+ let { default: launchEditorMiddleware } = await import("./launch-editor-middleware.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/launch-editor-middleware@2.14.1/node_modules/launch-editor-middleware/index.js", 23));
7596
+ return launchEditorMiddleware();
7597
+ })()))(req, res, next);
7598
+ } catch (err) {
7599
+ next(err);
7600
+ }
7601
+ }), middlewares.use((({ environments, logger })=>async function viewingServedFilesMiddleware(req, res, next) {
7121
7602
  if ('/rsbuild-dev-server' !== req.url.replace(postfixRE, '')) return void next();
7122
7603
  res.writeHead(200, {
7123
7604
  'Content-Type': 'text/html; charset=utf-8'
@@ -7450,11 +7931,12 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
7450
7931
  all: !1,
7451
7932
  chunks: !0,
7452
7933
  entrypoints: !0,
7934
+ ids: !0,
7453
7935
  outputPath: !0
7454
7936
  });
7455
7937
  if (!entrypoints?.[entryName]) throw Error(`${color.dim('[rsbuild:loadBundle]')} Can't find entry: ${color.yellow(entryName)}`);
7456
- let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
7457
- let chunk = chunks?.find((chunk)=>chunk.entry && chunk.names?.includes(String(entryChunkName)));
7938
+ let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkId)=>{
7939
+ let chunk = chunks?.find((chunk)=>chunk.entry && chunk.id === entryChunkId);
7458
7940
  return chunk?.files ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
7459
7941
  }, []);
7460
7942
  if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
@@ -7875,7 +8357,10 @@ function applyDefaultPlugins(pluginManager, context) {
7875
8357
  level: 'error'
7876
8358
  }), chain.watchOptions({
7877
8359
  aggregateTimeout: 0
7878
- }), chain.performance.hints(!1), chain.module.parser.merge({
8360
+ }), chain.performance.hints(!1), chain.experiments({
8361
+ ...chain.get('experiments'),
8362
+ pureFunctions: !0
8363
+ }), chain.module.parser.merge({
7879
8364
  javascript: {
7880
8365
  typeReexportsPresence: 'tolerant'
7881
8366
  }
@@ -8312,7 +8797,7 @@ function applyDefaultPlugins(pluginManager, context) {
8312
8797
  }, async ({ compilation, environment, sources })=>{
8313
8798
  let { config } = environment, { appIcon } = config.html;
8314
8799
  if (!appIcon) return;
8315
- let { lookup } = await import("./mrmime.js"), distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
8800
+ let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
8316
8801
  let { src, size } = icon, cacheKey = `${distDir}|${publicPath}|${src}`, cached = iconFormatMap.get(cacheKey);
8317
8802
  if (cached) return cached;
8318
8803
  let sizes = `${size}x${size}`;
@@ -8336,7 +8821,7 @@ function applyDefaultPlugins(pluginManager, context) {
8336
8821
  mimeType: lookup(absolutePath)
8337
8822
  };
8338
8823
  return iconFormatMap.set(cacheKey, formatted), formatted;
8339
- })(icon, distDir, publicPath, lookup)), tags = [];
8824
+ })(icon, distDir, publicPath, mrmime_lookup)), tags = [];
8340
8825
  for (let icon of icons){
8341
8826
  if ('web-app-manifest' === icon.target && !appIcon.name) {
8342
8827
  addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
@@ -8867,11 +9352,8 @@ try {
8867
9352
  ].filter((item)=>isRegExp(item));
8868
9353
  })(config);
8869
9354
  if (prefetch) {
8870
- let options = !0 === prefetch ? {} : prefetch;
8871
- excludes.length && (options.exclude = options.exclude ? [
8872
- ...helpers_castArray(options.exclude),
8873
- ...excludes
8874
- ] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(HtmlResourceHintsPlugin, [
9355
+ let options = appendExcludes(!0 === prefetch ? {} : prefetch, excludes);
9356
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(HtmlResourceHintsPlugin, [
8875
9357
  options,
8876
9358
  'prefetch',
8877
9359
  HTMLCount,
@@ -8880,11 +9362,8 @@ try {
8880
9362
  ]);
8881
9363
  }
8882
9364
  if (preload) {
8883
- let options = !0 === preload ? {} : preload;
8884
- excludes.length && (options.exclude = options.exclude ? [
8885
- ...helpers_castArray(options.exclude),
8886
- ...excludes
8887
- ] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(HtmlResourceHintsPlugin, [
9365
+ let options = appendExcludes(!0 === preload ? {} : preload, excludes);
9366
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(HtmlResourceHintsPlugin, [
8888
9367
  options,
8889
9368
  'preload',
8890
9369
  HTMLCount,
@@ -8956,7 +9435,7 @@ try {
8956
9435
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8957
9436
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8958
9437
  if (!1 === manifest) return;
8959
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.6/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
9438
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.0.8/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8960
9439
  manifestFilenames.set(environment.name, manifestOptions.filename);
8961
9440
  let pluginOptions = {
8962
9441
  fileName: manifestOptions.filename,
@@ -8983,7 +9462,7 @@ try {
8983
9462
  for (let file of chunkFiles){
8984
9463
  file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
8985
9464
  let relatedLICENSE = licenseMap.get(file.path);
8986
- if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
9465
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(manifestOptions.prefix ? ensureAssetPrefix(auxiliaryFile, publicPath) : auxiliaryFile);
8987
9466
  }
8988
9467
  let entryManifest = {};
8989
9468
  assets.size && (entryManifest.assets = Array.from(assets));
@@ -9048,18 +9527,39 @@ try {
9048
9527
  name: 'rsbuild:lazy-compilation',
9049
9528
  apply: 'serve',
9050
9529
  setup (api) {
9051
- api.modifyBundlerChain((chain, { environment, target })=>{
9530
+ api.modifyBundlerChain(async (chain, { environment, target })=>{
9052
9531
  if ('web' !== target) return;
9053
- let { config } = environment, options = config.dev?.lazyCompilation;
9532
+ let { config } = environment;
9533
+ if (!config.dev.hmr && !config.dev.liveReload) return;
9534
+ let options = config.dev?.lazyCompilation;
9054
9535
  if (options) {
9055
- if (!0 === options && Object.keys(chain.entryPoints.entries() || {}).length <= 1) return void chain.lazyCompilation({
9056
- entries: !1,
9057
- imports: !0
9058
- });
9536
+ if (!0 === options) {
9537
+ let entries = chain.entryPoints.entries() || {}, serverUrl = await getServerUrlFromClientConfig(config, api.context);
9538
+ if (Object.keys(entries).length <= 1) return void chain.lazyCompilation({
9539
+ entries: !1,
9540
+ imports: !0,
9541
+ ...serverUrl ? {
9542
+ serverUrl
9543
+ } : {}
9544
+ });
9545
+ if (serverUrl) return void chain.lazyCompilation({
9546
+ entries: !0,
9547
+ imports: !0,
9548
+ serverUrl
9549
+ });
9550
+ }
9059
9551
  if ('object' == typeof options && 'string' == typeof options.serverUrl && api.context.devServer) return void chain.lazyCompilation({
9060
9552
  ...options,
9061
9553
  serverUrl: replacePortPlaceholder(options.serverUrl, api.context.devServer.port)
9062
9554
  });
9555
+ if ('object' == typeof options) {
9556
+ let serverUrl = await getServerUrlFromClientConfig(config, api.context);
9557
+ chain.lazyCompilation(serverUrl ? {
9558
+ ...options,
9559
+ serverUrl
9560
+ } : options);
9561
+ return;
9562
+ }
9063
9563
  chain.lazyCompilation(options);
9064
9564
  }
9065
9565
  });
@@ -9470,7 +9970,7 @@ let applyServerOptions = (command)=>{
9470
9970
  };
9471
9971
  function setupCommands() {
9472
9972
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9473
- cli.version("2.0.11"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9973
+ cli.version("2.0.13"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9474
9974
  default: 'auto'
9475
9975
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9476
9976
  type: [
@@ -9541,7 +10041,7 @@ function initNodeEnv(command) {
9541
10041
  }
9542
10042
  function showGreeting() {
9543
10043
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9544
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.11\n`);
10044
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.13\n`);
9545
10045
  }
9546
10046
  function setupLogLevel() {
9547
10047
  if (cli_argv.length <= 3) return;
@@ -9563,5 +10063,5 @@ function runCLI() {
9563
10063
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9564
10064
  }
9565
10065
  }
9566
- let src_version = "2.0.11";
9567
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
10066
+ let src_version = "2.0.13";
10067
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };