@rsbuild/core 2.0.10 → 2.0.12

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
@@ -3084,10 +3084,10 @@ function exitHook(onExit) {
3084
3084
  exitHook_callbacks.delete(onExit);
3085
3085
  };
3086
3086
  }
3087
- let addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
3087
+ let removeTailingSlash = (s)=>s.endsWith('/') ? s.replace(/\/+$/, '') : s, addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
3088
3088
  let [urlProtocol, baseUrl] = base.split('://');
3089
3089
  return `${urlProtocol}://${posix.join(baseUrl, path)}`;
3090
- }, ensureAssetPrefix = (url, assetPrefix = "/")=>url.startsWith('//') || external_node_url_URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : publicPath.replace(/\/+$/, ''), getPublicPathFromChain = (chain, withSlash = !0)=>{
3090
+ }, ensureAssetPrefix = (url, assetPrefix = "/")=>url.startsWith('//') || external_node_url_URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : removeTailingSlash(publicPath), getPublicPathFromChain = (chain, withSlash = !0)=>{
3091
3091
  let publicPath = chain.output.get('publicPath');
3092
3092
  return 'string' == typeof publicPath ? formatPublicPath(publicPath, withSlash) : formatPublicPath("/", withSlash);
3093
3093
  };
@@ -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.10",
3486
+ version: "2.0.12",
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
@@ -5171,9 +5615,14 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
5171
5615
  if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
5172
5616
  let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
5173
5617
  return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
5174
- }, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''), removeBasePath = (url, base)=>{
5175
- let basePath = base.replace(/\/+$/, '');
5176
- return '' === basePath ? url : url === basePath ? '/' : url.startsWith(`${basePath}/`) ? url.slice(basePath.length) : url;
5618
+ }, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''), isUrlPathUnderBase = (pathname, base)=>{
5619
+ let basePath = removeTailingSlash(base);
5620
+ return '' === basePath || pathname === basePath || pathname.startsWith(`${basePath}/`);
5621
+ }, removeBasePath = (url, base)=>{
5622
+ let basePath = removeTailingSlash(base);
5623
+ if ('' === basePath || !url.startsWith(basePath)) return url;
5624
+ let nextChar = url[basePath.length];
5625
+ return void 0 === nextChar ? '/' : '/' === nextChar ? url.slice(basePath.length) : '?' === nextChar || '#' === nextChar ? `/${url.slice(basePath.length)}` : url;
5177
5626
  }, getRoutes = (context)=>{
5178
5627
  let environmentWithHtml = context.environmentList.filter((item)=>Object.keys(item.htmlPaths).length > 0);
5179
5628
  if (0 === environmentWithHtml.length) return [];
@@ -5561,6 +6010,17 @@ let HtmlResourceHintsPlugin_defaultOptions = {
5561
6010
  function filterResourceHints(resourceHints, scripts) {
5562
6011
  return resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href));
5563
6012
  }
6013
+ function getResourceHintKey(resourceHint) {
6014
+ return `${resourceHint.attributes.rel}:${resourceHint.attributes.href}`;
6015
+ }
6016
+ function mergeResourceHints(resourceHintGroups, scripts) {
6017
+ let links = [], seen = new Set();
6018
+ for (let { links: groupLinks, dedupe } of resourceHintGroups)for (let link of dedupe ? filterResourceHints(groupLinks, scripts) : groupLinks){
6019
+ let key = getResourceHintKey(link);
6020
+ seen.has(key) || (seen.add(key), links.push(link));
6021
+ }
6022
+ return links;
6023
+ }
5564
6024
  function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
5565
6025
  let extractedChunks = extractChunks(compilation, options.type), sortedFilteredFiles = ((files, include, exclude)=>{
5566
6026
  let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
@@ -5612,16 +6072,19 @@ class HtmlResourceHintsPlugin {
5612
6072
  isDev;
5613
6073
  getHTMLPlugin;
5614
6074
  constructor(options, type, HTMLCount, isDev, getHTMLPlugin){
5615
- this.options = {
5616
- ...HtmlResourceHintsPlugin_defaultOptions,
5617
- ...options
5618
- }, this.type = type, this.HTMLCount = HTMLCount, this.isDev = isDev, this.getHTMLPlugin = getHTMLPlugin;
6075
+ this.options = helpers_castArray(options).map((option)=>({
6076
+ ...HtmlResourceHintsPlugin_defaultOptions,
6077
+ ...option
6078
+ })), this.type = type, this.HTMLCount = HTMLCount, this.isDev = isDev, this.getHTMLPlugin = getHTMLPlugin;
5619
6079
  }
5620
6080
  apply(compiler) {
5621
6081
  compiler.hooks.compilation.tap(this.name, (compilation)=>{
5622
6082
  let pluginHooks = this.getHTMLPlugin().getCompilationHooks(compilation), pluginName = `HTML${upperFirst(this.type)}Plugin`;
5623
- 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 = [
5624
- ...this.options.dedupe ? filterResourceHints(this.resourceHints, data.assetTags.scripts) : this.resourceHints,
6083
+ pluginHooks.beforeAssetTagGeneration.tap(pluginName, (data)=>(this.resourceHints = this.options.map((option)=>({
6084
+ links: generateLinks(option, this.type, compilation, data, this.HTMLCount, this.isDev),
6085
+ dedupe: !1 !== option.dedupe
6086
+ })), data)), pluginHooks.alterAssetTags.tap(pluginName, (data)=>(this.resourceHints.length && (data.assetTags.styles = [
6087
+ ...mergeResourceHints(this.resourceHints, data.assetTags.scripts),
5625
6088
  ...data.assetTags.styles
5626
6089
  ]), data));
5627
6090
  });
@@ -5633,7 +6096,17 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
5633
6096
  rel,
5634
6097
  ...option
5635
6098
  }
6099
+ })), appendExcludes = (options, excludes)=>{
6100
+ if (!excludes.length) return options;
6101
+ let optionsList = helpers_castArray(options).map((option)=>({
6102
+ ...option,
6103
+ exclude: option.exclude ? [
6104
+ ...helpers_castArray(option.exclude),
6105
+ ...excludes
6106
+ ] : excludes
5636
6107
  }));
6108
+ return Array.isArray(options) ? optionsList : optionsList[0];
6109
+ };
5637
6110
  function isTerminalTraceOutput(output) {
5638
6111
  return 'stdout' === output || 'stderr' === output;
5639
6112
  }
@@ -5937,7 +6410,7 @@ async function getFileFromUrl(url, outputFileSystem, context) {
5937
6410
  }), { environmentList, publicPathnames } = context, distPaths = environmentList.map((env)=>env.distPath), possibleFilenames = new Set();
5938
6411
  for (let [index, distPath] of distPaths.entries()){
5939
6412
  let prefix = publicPathnames[index];
5940
- prefix && '/' !== prefix && pathname.startsWith(prefix) && possibleFilenames.add(node_path.join(distPath, pathname.slice(prefix.length)));
6413
+ prefix && '/' !== prefix && isUrlPathUnderBase(pathname, prefix) && possibleFilenames.add(node_path.join(distPath, pathname.slice(prefix.length)));
5941
6414
  }
5942
6415
  for (let distPath of distPaths)possibleFilenames.add(node_path.join(distPath, pathname));
5943
6416
  for (let filename of possibleFilenames){
@@ -5988,17 +6461,15 @@ function getEtag(stat) {
5988
6461
  let mtime = stat.mtime.getTime().toString(16), size = stat.size.toString(16);
5989
6462
  return `W/"${size}-${mtime}"`;
5990
6463
  }
5991
- function createReadStreamOrReadFileSync(filename, outputFileSystem, start, end) {
5992
- return {
5993
- bufferOrStream: outputFileSystem.createReadStream(filename, {
5994
- start,
5995
- end
5996
- }),
5997
- byteLength: 0 === end ? 0 : end - start + 1
5998
- };
6464
+ function createReadStream(filename, outputFileSystem, start, end) {
6465
+ return (0, outputFileSystem.createReadStream)(filename, {
6466
+ start,
6467
+ end,
6468
+ highWaterMark: 524288
6469
+ });
5999
6470
  }
6000
- async function getContentType(str) {
6001
- let { lookup } = await import("./mrmime.js"), mime = lookup(str);
6471
+ function getContentType(str) {
6472
+ let mime = mrmime_lookup(str);
6002
6473
  return !!mime && ((mime.startsWith('text/') || 'application/json' === mime || 'application/manifest+json' === mime) && (mime += '; charset=utf-8'), mime);
6003
6474
  }
6004
6475
  let BYTES_RANGE_REGEXP = /^ *bytes/i;
@@ -6010,6 +6481,84 @@ function parseHttpDate(date) {
6010
6481
  return 'number' == typeof timestamp ? timestamp : NaN;
6011
6482
  }
6012
6483
  let CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/;
6484
+ function getRequestHeader(headers, name) {
6485
+ let value = headers[name];
6486
+ return Array.isArray(value) ? value.join(',') : value;
6487
+ }
6488
+ function isConditionalGET(headers) {
6489
+ return !!(headers['if-match'] || headers['if-unmodified-since'] || headers['if-none-match'] || headers['if-modified-since']);
6490
+ }
6491
+ function isPreconditionFailure(headers, res) {
6492
+ let ifMatch = getRequestHeader(headers, 'if-match');
6493
+ if (ifMatch) {
6494
+ let etag = res.getHeader('ETag');
6495
+ return !etag || '*' !== ifMatch && parseTokenList(ifMatch).every((match)=>match !== etag && match !== `W/${etag}` && `W/${match}` !== etag);
6496
+ }
6497
+ let ifUnmodifiedSince = getRequestHeader(headers, 'if-unmodified-since');
6498
+ if (ifUnmodifiedSince) {
6499
+ let unmodifiedSince = parseHttpDate(ifUnmodifiedSince);
6500
+ if (!Number.isNaN(unmodifiedSince)) {
6501
+ let lastModified = parseHttpDate(String(res.getHeader('Last-Modified')));
6502
+ return Number.isNaN(lastModified) || lastModified > unmodifiedSince;
6503
+ }
6504
+ }
6505
+ return !1;
6506
+ }
6507
+ function isCachable(statusCode) {
6508
+ return statusCode >= 200 && statusCode < 300 || 304 === statusCode;
6509
+ }
6510
+ function isFresh(headers, resHeaders) {
6511
+ let cacheControl = getRequestHeader(headers, 'cache-control');
6512
+ if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) return !1;
6513
+ let noneMatch = getRequestHeader(headers, 'if-none-match'), modifiedSince = getRequestHeader(headers, 'if-modified-since');
6514
+ if (!noneMatch && !modifiedSince) return !1;
6515
+ if (noneMatch && '*' !== noneMatch) {
6516
+ if (!resHeaders.etag) return !1;
6517
+ let matches = parseTokenList(noneMatch), etagStale = !0;
6518
+ for(let i = 0; i < matches.length; i++){
6519
+ let match = matches[i];
6520
+ if (match === resHeaders.etag || match === `W/${resHeaders.etag}` || `W/${match}` === resHeaders.etag) {
6521
+ etagStale = !1;
6522
+ break;
6523
+ }
6524
+ }
6525
+ if (etagStale) return !1;
6526
+ }
6527
+ if (noneMatch) return !0;
6528
+ if (modifiedSince) {
6529
+ let lastModified = resHeaders['last-modified'];
6530
+ if (!lastModified || !(parseHttpDate(String(lastModified)) <= parseHttpDate(modifiedSince))) return !1;
6531
+ }
6532
+ return !0;
6533
+ }
6534
+ function isRangeFresh(headers, res) {
6535
+ let ifRange = getRequestHeader(headers, 'if-range');
6536
+ if (!ifRange) return !0;
6537
+ if (-1 !== ifRange.indexOf('"')) {
6538
+ let etag = res.getHeader('ETag');
6539
+ return !etag || !(ifRange.startsWith('W/') || etag.startsWith('W/')) && ifRange === etag;
6540
+ }
6541
+ let lastModified = res.getHeader('Last-Modified');
6542
+ return !lastModified || parseHttpDate(lastModified) <= parseHttpDate(ifRange);
6543
+ }
6544
+ function getRangeHeader(headers) {
6545
+ let range = getRequestHeader(headers, 'range');
6546
+ if (range && BYTES_RANGE_REGEXP.test(range)) return range;
6547
+ }
6548
+ function getOffsetAndLenFromRange(range) {
6549
+ let { start, end } = range;
6550
+ return [
6551
+ start,
6552
+ end - start + 1
6553
+ ];
6554
+ }
6555
+ function calcStartAndEnd(start, len) {
6556
+ let end = Math.max(start, start + len - 1);
6557
+ return [
6558
+ start,
6559
+ end
6560
+ ];
6561
+ }
6013
6562
  function destroyStream(stream, suppress) {
6014
6563
  'function' == typeof stream.destroy && stream.destroy(), 'function' == typeof stream.close && stream.on('open', function onOpenClose(fd) {
6015
6564
  'number' == typeof fd && this.close();
@@ -6020,10 +6569,7 @@ let parseRangeHeaders = async (value)=>{
6020
6569
  return rangeParser(Number(len), rangeHeader, {
6021
6570
  combine: !0
6022
6571
  });
6023
- }, acceptedMethods = [
6024
- 'GET',
6025
- 'HEAD'
6026
- ];
6572
+ };
6027
6573
  function sendError(res, code) {
6028
6574
  let content = {
6029
6575
  400: 'Bad Request',
@@ -6048,7 +6594,7 @@ function sendError(res, code) {
6048
6594
  let byteLength = Buffer.byteLength(document);
6049
6595
  res.setHeader('Content-Length', byteLength), res.end(document);
6050
6596
  }
6051
- function createMiddleware(context, ready, outputFileSystem) {
6597
+ function createAssetsMiddleware(context, ready, outputFileSystem) {
6052
6598
  let { logger } = context;
6053
6599
  return async function assetsMiddleware(req, res, next) {
6054
6600
  async function goNext() {
@@ -6058,83 +6604,8 @@ function createMiddleware(context, ready, outputFileSystem) {
6058
6604
  });
6059
6605
  });
6060
6606
  }
6061
- if (req.method && !acceptedMethods.includes(req.method)) return void await goNext();
6062
- function isConditionalGET() {
6063
- return req.headers['if-match'] || req.headers['if-unmodified-since'] || req.headers['if-none-match'] || req.headers['if-modified-since'];
6064
- }
6065
- function isPreconditionFailure() {
6066
- let ifMatch = req.headers['if-match'];
6067
- if (ifMatch) {
6068
- let etag = res.getHeader('ETag');
6069
- return !etag || '*' !== ifMatch && parseTokenList(ifMatch).every((match)=>match !== etag && match !== `W/${etag}` && `W/${match}` !== etag);
6070
- }
6071
- let ifUnmodifiedSince = req.headers['if-unmodified-since'];
6072
- if (ifUnmodifiedSince) {
6073
- let unmodifiedSince = parseHttpDate(ifUnmodifiedSince);
6074
- if (!Number.isNaN(unmodifiedSince)) {
6075
- let lastModified = parseHttpDate(String(res.getHeader('Last-Modified')));
6076
- return Number.isNaN(lastModified) || lastModified > unmodifiedSince;
6077
- }
6078
- }
6079
- return !1;
6080
- }
6081
- function isCachable() {
6082
- return res.statusCode >= 200 && res.statusCode < 300 || 304 === res.statusCode;
6083
- }
6084
- function isFresh(resHeaders) {
6085
- let cacheControl = req.headers['cache-control'];
6086
- if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) return !1;
6087
- let noneMatch = req.headers['if-none-match'], modifiedSince = req.headers['if-modified-since'];
6088
- if (!noneMatch && !modifiedSince) return !1;
6089
- if (noneMatch && '*' !== noneMatch) {
6090
- if (!resHeaders.etag) return !1;
6091
- let matches = parseTokenList(noneMatch), etagStale = !0;
6092
- for(let i = 0; i < matches.length; i++){
6093
- let match = matches[i];
6094
- if (match === resHeaders.etag || match === `W/${resHeaders.etag}` || `W/${match}` === resHeaders.etag) {
6095
- etagStale = !1;
6096
- break;
6097
- }
6098
- }
6099
- if (etagStale) return !1;
6100
- }
6101
- if (noneMatch) return !0;
6102
- if (modifiedSince) {
6103
- let lastModified = resHeaders['last-modified'];
6104
- if (!lastModified || !(parseHttpDate(String(lastModified)) <= parseHttpDate(modifiedSince))) return !1;
6105
- }
6106
- return !0;
6107
- }
6108
- function isRangeFresh() {
6109
- let ifRange = req.headers['if-range'];
6110
- if (!ifRange) return !0;
6111
- if (-1 !== ifRange.indexOf('"')) {
6112
- let etag = res.getHeader('ETag');
6113
- return !etag || !!(etag && -1 !== ifRange.indexOf(etag));
6114
- }
6115
- let lastModified = res.getHeader('Last-Modified');
6116
- return !lastModified || parseHttpDate(lastModified) <= parseHttpDate(ifRange);
6117
- }
6118
- function getRangeHeader() {
6119
- let { range } = req.headers;
6120
- if (range && BYTES_RANGE_REGEXP.test(range)) return range;
6121
- }
6122
- function getOffsetAndLenFromRange(range) {
6123
- let { start, end } = range;
6124
- return [
6125
- start,
6126
- end - start + 1
6127
- ];
6128
- }
6129
- function calcStartAndEnd(start, len) {
6130
- let end = Math.max(start, start + len - 1);
6131
- return [
6132
- start,
6133
- end
6134
- ];
6135
- }
6136
- ready(async function processRequest() {
6137
- let bufferOrStream, byteLength;
6607
+ req.method && 'GET' !== req.method && 'HEAD' !== req.method ? await goNext() : ready(async function processRequest() {
6608
+ let readStream;
6138
6609
  if (!req.url) return void await goNext();
6139
6610
  let resolved = await getFileFromUrl(req.url, outputFileSystem, context);
6140
6611
  if (!resolved) return void await goNext();
@@ -6144,18 +6615,18 @@ function createMiddleware(context, ready, outputFileSystem) {
6144
6615
  }
6145
6616
  let { fsStats, filename } = resolved, { size } = fsStats, len = size, offset = 0;
6146
6617
  if (!res.getHeader('Content-Type')) {
6147
- let contentType = await getContentType(filename);
6618
+ let contentType = getContentType(filename);
6148
6619
  contentType && res.setHeader('Content-Type', contentType);
6149
6620
  }
6150
6621
  res.getHeader('Accept-Ranges') || res.setHeader('Accept-Ranges', 'bytes');
6151
- let rangeHeader = getRangeHeader();
6622
+ let rangeHeader = getRangeHeader(req.headers);
6152
6623
  if (!res.getHeader('ETag') && fsStats) {
6153
6624
  let hash = getEtag(fsStats);
6154
6625
  res.setHeader('ETag', hash);
6155
6626
  }
6156
- if (isConditionalGET()) {
6157
- if (isPreconditionFailure()) return void sendError(res, 412);
6158
- if (404 === res.statusCode && (res.statusCode = 200), isCachable() && isFresh({
6627
+ if (isConditionalGET(req.headers)) {
6628
+ if (isPreconditionFailure(req.headers, res)) return void sendError(res, 412);
6629
+ if (404 === res.statusCode && (res.statusCode = 200), isCachable(res.statusCode) && isFresh(req.headers, {
6159
6630
  etag: res.getHeader('ETag'),
6160
6631
  'last-modified': res.getHeader('Last-Modified')
6161
6632
  })) {
@@ -6165,7 +6636,7 @@ function createMiddleware(context, ready, outputFileSystem) {
6165
6636
  }
6166
6637
  if (rangeHeader) {
6167
6638
  let parsedRanges = await parseRangeHeaders(`${size}|${rangeHeader}`);
6168
- if (isRangeFresh() || (parsedRanges = []), -1 === parsedRanges) {
6639
+ if (isRangeFresh(req.headers, res) || (parsedRanges = []), -1 === parsedRanges) {
6169
6640
  logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, 416);
6170
6641
  return;
6171
6642
  }
@@ -6173,20 +6644,19 @@ function createMiddleware(context, ready, outputFileSystem) {
6173
6644
  }
6174
6645
  let [start, end] = calcStartAndEnd(offset, len);
6175
6646
  try {
6176
- ({ bufferOrStream, byteLength } = createReadStreamOrReadFileSync(filename, outputFileSystem, start, end));
6647
+ readStream = createReadStream(filename, outputFileSystem, start, end);
6177
6648
  } catch {
6178
6649
  await goNext();
6179
6650
  return;
6180
6651
  }
6181
- if (res.setHeader('Content-Length', byteLength), 'HEAD' === req.method) {
6652
+ if (res.setHeader('Content-Length', len), 'HEAD' === req.method) {
6182
6653
  404 === res.statusCode && (res.statusCode = 200), res.end();
6183
6654
  return;
6184
6655
  }
6185
- if ('function' != typeof bufferOrStream.pipe) return void res.end(bufferOrStream);
6186
6656
  let cleanup = ()=>{
6187
- destroyStream(bufferOrStream, !0);
6657
+ destroyStream(readStream, !0);
6188
6658
  };
6189
- bufferOrStream.on('error', (error)=>{
6659
+ readStream.on('error', (error)=>{
6190
6660
  switch(cleanup(), error.code){
6191
6661
  case 'ENAMETOOLONG':
6192
6662
  case 'ENOENT':
@@ -6196,13 +6666,13 @@ function createMiddleware(context, ready, outputFileSystem) {
6196
6666
  default:
6197
6667
  sendError(res, 500);
6198
6668
  }
6199
- }), bufferOrStream.pipe(res), on_finished_default()(res, cleanup);
6669
+ }), readStream.pipe(res), on_finished_default()(res, cleanup);
6200
6670
  });
6201
6671
  };
6202
6672
  }
6203
6673
  async function setupOutputFileSystem(writeToDisk, compilers) {
6204
6674
  if (!0 !== writeToDisk) {
6205
- 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());
6675
+ 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());
6206
6676
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
6207
6677
  }
6208
6678
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -6246,12 +6716,13 @@ function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort })
6246
6716
  let { target } = compiler.options;
6247
6717
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
6248
6718
  })(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
6249
- let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), clientConfig = {
6719
+ let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), { webSocketUrlResolver, ...clientConfig } = {
6250
6720
  ...config.dev.client
6251
6721
  };
6252
6722
  '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
6253
- let hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
6723
+ let resolverPath = webSocketUrlResolver && !external_node_path_isAbsolute(webSocketUrlResolver) ? join(compiler.context, webSocketUrlResolver) : webSocketUrlResolver, hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
6254
6724
  ${!0 === (overlay1 = overlay = config.dev.client.overlay) || 'object' == typeof overlay1 && !1 !== overlay1.errors || isRuntimeOverlayEnabled(overlay) ? `import '${toPosixPath(join(CLIENT_PATH, 'overlay.js'))}';` : ''}
6725
+ ${resolverPath ? `import urlResolver from ${JSON.stringify(toPosixPath(resolverPath))};` : ''}
6255
6726
  init(
6256
6727
  '${token}',
6257
6728
  ${JSON.stringify(clientConfig)},
@@ -6260,7 +6731,7 @@ init(
6260
6731
  ${JSON.stringify(config.server.base)},
6261
6732
  ${liveReloadEnabled},
6262
6733
  ${!!config.dev.browserLogs},
6263
- ${JSON.stringify(config.dev.client.logLevel)}
6734
+ ${JSON.stringify(config.dev.client.logLevel)}${resolverPath ? ',\n urlResolver' : ''}
6264
6735
  )
6265
6736
  `;
6266
6737
  new core_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
@@ -6338,7 +6809,7 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
6338
6809
  return name && environments[name] && (writeToDisk = environments[name].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
6339
6810
  });
6340
6811
  writeToDisk && setupWriteToDisk(compilers, writeToDisk, logger);
6341
- let instance = createMiddleware(context, (callback)=>{
6812
+ let instance = createAssetsMiddleware(context, (callback)=>{
6342
6813
  'done' === context.buildState.status ? callback() : callbacks.push(callback);
6343
6814
  }, await setupOutputFileSystem(writeToDisk, compilers));
6344
6815
  return instance.watch = ()=>{
@@ -6990,21 +7461,38 @@ let faviconFallbackMiddleware = (req, res, next)=>{
6990
7461
  next();
6991
7462
  }, middlewares_isFileExists = async (filePath, outputFileSystem)=>new Promise((resolve)=>{
6992
7463
  outputFileSystem.stat(filePath, (_error, stats)=>{
6993
- resolve(stats?.isFile());
7464
+ resolve(!!stats?.isFile());
6994
7465
  });
6995
- }), maybeHTMLRequest = (req)=>{
7466
+ }), isFileExistsInDistPaths = async (distPaths, filename, outputFileSystem)=>{
7467
+ for (let distPath of distPaths)if (await middlewares_isFileExists(node_path.join(distPath, filename), outputFileSystem)) return !0;
7468
+ return !1;
7469
+ }, maybeHTMLRequest = (req)=>{
6996
7470
  if (!req.url || !req.headers || 'GET' !== req.method && 'HEAD' !== req.method) return !1;
6997
7471
  let { accept } = req.headers;
6998
7472
  return 'string' == typeof accept && (accept.includes('text/html') || accept.includes('*/*'));
6999
- }, postfixRE = /[?#].*$/, getBaseUrlMiddleware = ({ base })=>function baseUrlMiddleware(req, res, next) {
7000
- var pathname;
7001
- let basePath, url = req.url, pathname1 = url.replace(postfixRE, '');
7002
- if (pathname = pathname1, '' === (basePath = base.replace(/\/+$/, '')) || pathname === basePath || pathname.startsWith(`${basePath}/`)) {
7473
+ }, postfixRE = /[?#].*$/, getHtmlCompletionMiddleware = ({ distPaths, assetsMiddleware, outputFileSystem })=>async function htmlCompletionMiddleware(req, res, next) {
7474
+ if (!maybeHTMLRequest(req)) return void next();
7475
+ let pathname = req.url.replace(postfixRE, ''), rewrite = (newUrl)=>{
7476
+ req.url = newUrl, assetsMiddleware(req, res, (...args)=>{
7477
+ next(...args);
7478
+ });
7479
+ };
7480
+ if (pathname.endsWith('/')) {
7481
+ let newUrl = `${pathname}index.html`;
7482
+ if (await isFileExistsInDistPaths(distPaths, newUrl, outputFileSystem)) return void rewrite(newUrl);
7483
+ } else if (!node_path.extname(pathname)) {
7484
+ let newUrl = `${pathname}.html`;
7485
+ if (await isFileExistsInDistPaths(distPaths, newUrl, outputFileSystem)) return void rewrite(newUrl);
7486
+ }
7487
+ next();
7488
+ }, getBaseUrlMiddleware = ({ base })=>function baseUrlMiddleware(req, res, next) {
7489
+ let url = req.url, pathname = url.replace(postfixRE, '');
7490
+ if (isUrlPathUnderBase(pathname, base)) {
7003
7491
  req.url = removeBasePath(url, base), next();
7004
7492
  return;
7005
7493
  }
7006
7494
  let redirectPath = addTrailingSlash(url) !== base ? joinUrlPath(base, url) : base;
7007
- if ('/' === pathname1 || '/index.html' === pathname1) {
7495
+ if ('/' === pathname || '/index.html' === pathname) {
7008
7496
  res.writeHead(302, {
7009
7497
  Location: redirectPath
7010
7498
  }), res.end();
@@ -7019,6 +7507,16 @@ let faviconFallbackMiddleware = (req, res, next)=>{
7019
7507
  res.writeHead(404, {
7020
7508
  'Content-Type': 'text/plain'
7021
7509
  }), res.end(`The server is configured with a base URL of ${base} - did you mean to visit ${redirectPath} instead?`);
7510
+ }, getHtmlFallbackMiddleware = ({ distPaths, assetsMiddleware, outputFileSystem, logger })=>async function htmlFallbackMiddleware(req, res, next) {
7511
+ if (!maybeHTMLRequest(req) || '/favicon.ico' === req.url) return void next();
7512
+ if (await isFileExistsInDistPaths(distPaths, 'index.html', outputFileSystem)) {
7513
+ let newUrl = '/index.html';
7514
+ isVerbose(logger) && logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, assetsMiddleware(req, res, (...args)=>{
7515
+ next(...args);
7516
+ });
7517
+ return;
7518
+ }
7519
+ next();
7022
7520
  };
7023
7521
  function formatProxyOptions(proxyOptions, logger) {
7024
7522
  let logPrefix = color.dim('[http-proxy-middleware]: '), defaultOptions = {
@@ -7063,7 +7561,7 @@ async function createProxyMiddleware(proxyOptions, logger) {
7063
7561
  };
7064
7562
  }
7065
7563
  let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer, middlewares, postCallbacks })=>{
7066
- let upgradeEvents = [], { server } = config, { logger } = context;
7564
+ let launchEditorHandlerPromise, upgradeEvents = [], { server } = config, { logger } = context;
7067
7565
  if (server.cors) {
7068
7566
  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));
7069
7567
  middlewares.use(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
@@ -7081,11 +7579,18 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
7081
7579
  let { compiler } = buildManager;
7082
7580
  (compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.use(core_rspack.lazyCompilationMiddleware(compiler));
7083
7581
  }
7084
- server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
7582
+ if (server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
7085
7583
  base: server.base
7086
- }));
7087
- 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));
7088
- if (middlewares.use('/__open-in-editor', launchEditorMiddleware()), middlewares.use((({ environments, logger })=>async function viewingServedFilesMiddleware(req, res, next) {
7584
+ })), middlewares.use('/__open-in-editor', async (req, res, next)=>{
7585
+ try {
7586
+ (await (launchEditorHandlerPromise ??= (async ()=>{
7587
+ 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));
7588
+ return launchEditorMiddleware();
7589
+ })()))(req, res, next);
7590
+ } catch (err) {
7591
+ next(err);
7592
+ }
7593
+ }), middlewares.use((({ environments, logger })=>async function viewingServedFilesMiddleware(req, res, next) {
7089
7594
  if ('/rsbuild-dev-server' !== req.url.replace(postfixRE, '')) return void next();
7090
7595
  res.writeHead(200, {
7091
7596
  'Content-Type': 'text/html; charset=utf-8'
@@ -7148,24 +7653,12 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
7148
7653
  logger
7149
7654
  })), buildManager && (middlewares.use(buildManager.assetsMiddleware), upgradeEvents.push(buildManager.socketServer.upgrade), middlewares.use(function hotUpdateJsonFallbackMiddleware(req, res, next) {
7150
7655
  req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? notFoundMiddleware(req, res, next) : next();
7151
- })), buildManager && middlewares.use((({ distPath, buildManager })=>async function htmlCompletionMiddleware(req, res, next) {
7152
- if (!maybeHTMLRequest(req)) return void next();
7153
- let pathname = req.url.replace(postfixRE, ''), rewrite = (newUrl)=>{
7154
- req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
7155
- next(...args);
7156
- });
7157
- };
7158
- if (pathname.endsWith('/')) {
7159
- let newUrl = `${pathname}index.html`, filePath = node_path.join(distPath, newUrl);
7160
- if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
7161
- } else if (!node_path.extname(pathname)) {
7162
- let newUrl = `${pathname}.html`, filePath = node_path.join(distPath, newUrl);
7163
- if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
7164
- }
7165
- next();
7166
- })({
7167
- buildManager,
7168
- distPath: context.distPath
7656
+ })), buildManager && middlewares.use(getHtmlCompletionMiddleware({
7657
+ assetsMiddleware: buildManager.assetsMiddleware,
7658
+ distPaths: [
7659
+ context.distPath
7660
+ ],
7661
+ outputFileSystem: buildManager.outputFileSystem
7169
7662
  })), server.publicDir.length) {
7170
7663
  let { default: sirv } = await import("./sirv.js");
7171
7664
  for (let { name } of server.publicDir){
@@ -7179,21 +7672,13 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
7179
7672
  }
7180
7673
  }
7181
7674
  for (let callback of postCallbacks)await callback();
7182
- return server.historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === server.historyApiFallback ? {} : server.historyApiFallback)), buildManager?.assetsMiddleware && middlewares.use(buildManager.assetsMiddleware)), buildManager && server.htmlFallback && middlewares.use((({ distPath, buildManager, logger })=>async function htmlFallbackMiddleware(req, res, next) {
7183
- if (!maybeHTMLRequest(req) || '/favicon.ico' === req.url) return void next();
7184
- let filePath = node_path.join(distPath, 'index.html');
7185
- if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) {
7186
- let newUrl = '/index.html';
7187
- isVerbose(logger) && logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
7188
- next(...args);
7189
- });
7190
- return;
7191
- }
7192
- next();
7193
- })({
7194
- buildManager,
7195
- distPath: context.distPath,
7196
- logger
7675
+ return server.historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === server.historyApiFallback ? {} : server.historyApiFallback)), buildManager?.assetsMiddleware && middlewares.use(buildManager.assetsMiddleware)), buildManager && server.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
7676
+ assetsMiddleware: buildManager.assetsMiddleware,
7677
+ distPaths: [
7678
+ context.distPath
7679
+ ],
7680
+ logger,
7681
+ outputFileSystem: buildManager.outputFileSystem
7197
7682
  })), middlewares.use(faviconFallbackMiddleware), {
7198
7683
  onUpgrade: (...args)=>{
7199
7684
  for (let cb of upgradeEvents)cb(...args);
@@ -7438,11 +7923,12 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
7438
7923
  all: !1,
7439
7924
  chunks: !0,
7440
7925
  entrypoints: !0,
7926
+ ids: !0,
7441
7927
  outputPath: !0
7442
7928
  });
7443
7929
  if (!entrypoints?.[entryName]) throw Error(`${color.dim('[rsbuild:loadBundle]')} Can't find entry: ${color.yellow(entryName)}`);
7444
- let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
7445
- let chunk = chunks?.find((chunk)=>chunk.entry && chunk.names?.includes(String(entryChunkName)));
7930
+ let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkId)=>{
7931
+ let chunk = chunks?.find((chunk)=>chunk.entry && chunk.id === entryChunkId);
7446
7932
  return chunk?.files ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
7447
7933
  }, []);
7448
7934
  if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
@@ -7501,7 +7987,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
7501
7987
  }
7502
7988
  let { createServer } = await import("node:http");
7503
7989
  return createServer(middlewares);
7504
- };
7990
+ }, getPublicPathname = (publicPath)=>'auto' === publicPath || '' === publicPath ? '' : getPathnameFromUrl(publicPath.endsWith('/') ? publicPath : `${publicPath}/`), getPublicPathnames = (publicPaths, base)=>publicPaths.map(getPublicPathname).map((prefix)=>base && '/' !== base ? removeBasePath(prefix, base) : prefix);
7505
7991
  async function applyServerSetup(setup, context) {
7506
7992
  let postCallbacks = [];
7507
7993
  for (let handler of helpers_castArray(setup || [])){
@@ -7590,10 +8076,9 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
7590
8076
  let startCompile = async ()=>{
7591
8077
  let compiler = await createCompiler();
7592
8078
  if (!compiler) throw Error(`${color.dim('[rsbuild:server]')} Failed to get compiler instance.`);
7593
- let publicPaths = compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
8079
+ context.publicPathnames = getPublicPathnames(compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
7594
8080
  getPublicPathFromCompiler(compiler)
7595
- ], { base } = config.server;
7596
- context.publicPathnames = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? removeBasePath(prefix, base) : prefix), compiler?.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
8081
+ ], config.server.base), compiler?.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
7597
8082
  lastStats && (waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null), waitLastCompileDone = new Promise((resolve)=>{
7598
8083
  waitLastCompileDoneResolve = resolve;
7599
8084
  }));
@@ -7748,7 +8233,9 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
7748
8233
  }), state.buildManager?.watch(), logger.debug('create dev server done'), devServer;
7749
8234
  }
7750
8235
  async function startPreviewServer(context, config, { getPortSilently } = {}) {
7751
- let { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig, protocol = serverConfig.https ? 'https' : 'http', routes = getRoutes(context), urls = await getAddressUrls({
8236
+ let environmentList, { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig, assetPrefixes = context.environmentList.map((environment)=>environment.config.output.assetPrefix);
8237
+ context.publicPathnames = getPublicPathnames(assetPrefixes, base);
8238
+ let protocol = serverConfig.https ? 'https' : 'http', routes = getRoutes(context), urls = await getAddressUrls({
7752
8239
  protocol,
7753
8240
  port,
7754
8241
  host
@@ -7789,21 +8276,14 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
7789
8276
  server: previewServer,
7790
8277
  environments: context.environments
7791
8278
  });
7792
- let applyStaticAssetMiddleware = async ()=>{
7793
- let { default: sirv } = await import("./sirv.js"), assetsMiddleware = sirv(context.distPath, {
7794
- etag: !0,
7795
- dev: !0,
7796
- ignores: [
7797
- 'favicon.ico'
7798
- ],
7799
- single: 'index' === serverConfig.htmlFallback
7800
- }), assetPrefixes = context.environmentList.map((e)=>getPathnameFromUrl(e.config.output.assetPrefix));
7801
- middlewares.use(function staticAssetMiddleware(req, res, next) {
7802
- let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
7803
- assetPrefix && url?.startsWith(assetPrefix) ? (req.url = url.slice(assetPrefix.length), assetsMiddleware(req, res, (...args)=>{
7804
- req.url = url, next(...args);
7805
- })) : assetsMiddleware(req, res, next);
7806
- });
8279
+ let assetContext = (environmentList = context.environmentList.filter((environment)=>isWebTarget(environment.config.output.target)), {
8280
+ ...context,
8281
+ environmentList,
8282
+ publicPathnames: environmentList.map((environment)=>context.publicPathnames[environment.index])
8283
+ }), assetsMiddleware = createAssetsMiddleware(assetContext, (callback)=>callback(), node_fs), htmlMiddlewareOptions = {
8284
+ assetsMiddleware,
8285
+ distPaths: assetContext.environmentList.map((environment)=>environment.distPath),
8286
+ outputFileSystem: node_fs
7807
8287
  };
7808
8288
  if (isVerbose(logger) && middlewares.use(getRequestLoggerMiddleware(logger)), cors) {
7809
8289
  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));
@@ -7826,8 +8306,11 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
7826
8306
  }
7827
8307
  for (let callback of (base && '/' !== base && middlewares.use(getBaseUrlMiddleware({
7828
8308
  base
7829
- })), await applyStaticAssetMiddleware(), historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === historyApiFallback ? {} : historyApiFallback)), await applyStaticAssetMiddleware()), postSetupCallbacks))await callback();
7830
- return middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), new Promise((resolve)=>{
8309
+ })), middlewares.use(assetsMiddleware), middlewares.use(getHtmlCompletionMiddleware(htmlMiddlewareOptions)), historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === historyApiFallback ? {} : historyApiFallback)), middlewares.use(assetsMiddleware)), postSetupCallbacks))await callback();
8310
+ return serverConfig.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
8311
+ ...htmlMiddlewareOptions,
8312
+ logger
8313
+ })), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), new Promise((resolve)=>{
7831
8314
  httpServer.listen({
7832
8315
  host,
7833
8316
  port
@@ -7866,7 +8349,10 @@ function applyDefaultPlugins(pluginManager, context) {
7866
8349
  level: 'error'
7867
8350
  }), chain.watchOptions({
7868
8351
  aggregateTimeout: 0
7869
- }), chain.performance.hints(!1), chain.module.parser.merge({
8352
+ }), chain.performance.hints(!1), chain.experiments({
8353
+ ...chain.get('experiments'),
8354
+ pureFunctions: !0
8355
+ }), chain.module.parser.merge({
7870
8356
  javascript: {
7871
8357
  typeReexportsPresence: 'tolerant'
7872
8358
  }
@@ -8303,7 +8789,7 @@ function applyDefaultPlugins(pluginManager, context) {
8303
8789
  }, async ({ compilation, environment, sources })=>{
8304
8790
  let { config } = environment, { appIcon } = config.html;
8305
8791
  if (!appIcon) return;
8306
- 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)=>{
8792
+ let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
8307
8793
  let { src, size } = icon, cacheKey = `${distDir}|${publicPath}|${src}`, cached = iconFormatMap.get(cacheKey);
8308
8794
  if (cached) return cached;
8309
8795
  let sizes = `${size}x${size}`;
@@ -8327,7 +8813,7 @@ function applyDefaultPlugins(pluginManager, context) {
8327
8813
  mimeType: lookup(absolutePath)
8328
8814
  };
8329
8815
  return iconFormatMap.set(cacheKey, formatted), formatted;
8330
- })(icon, distDir, publicPath, lookup)), tags = [];
8816
+ })(icon, distDir, publicPath, mrmime_lookup)), tags = [];
8331
8817
  for (let icon of icons){
8332
8818
  if ('web-app-manifest' === icon.target && !appIcon.name) {
8333
8819
  addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
@@ -8858,11 +9344,8 @@ try {
8858
9344
  ].filter((item)=>isRegExp(item));
8859
9345
  })(config);
8860
9346
  if (prefetch) {
8861
- let options = !0 === prefetch ? {} : prefetch;
8862
- excludes.length && (options.exclude = options.exclude ? [
8863
- ...helpers_castArray(options.exclude),
8864
- ...excludes
8865
- ] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(HtmlResourceHintsPlugin, [
9347
+ let options = appendExcludes(!0 === prefetch ? {} : prefetch, excludes);
9348
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(HtmlResourceHintsPlugin, [
8866
9349
  options,
8867
9350
  'prefetch',
8868
9351
  HTMLCount,
@@ -8871,11 +9354,8 @@ try {
8871
9354
  ]);
8872
9355
  }
8873
9356
  if (preload) {
8874
- let options = !0 === preload ? {} : preload;
8875
- excludes.length && (options.exclude = options.exclude ? [
8876
- ...helpers_castArray(options.exclude),
8877
- ...excludes
8878
- ] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(HtmlResourceHintsPlugin, [
9357
+ let options = appendExcludes(!0 === preload ? {} : preload, excludes);
9358
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(HtmlResourceHintsPlugin, [
8879
9359
  options,
8880
9360
  'preload',
8881
9361
  HTMLCount,
@@ -8947,7 +9427,7 @@ try {
8947
9427
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8948
9428
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8949
9429
  if (!1 === manifest) return;
8950
- 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'));
9430
+ 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'));
8951
9431
  manifestFilenames.set(environment.name, manifestOptions.filename);
8952
9432
  let pluginOptions = {
8953
9433
  fileName: manifestOptions.filename,
@@ -9461,7 +9941,7 @@ let applyServerOptions = (command)=>{
9461
9941
  };
9462
9942
  function setupCommands() {
9463
9943
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9464
- cli.version("2.0.10"), 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)', {
9944
+ cli.version("2.0.12"), 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)', {
9465
9945
  default: 'auto'
9466
9946
  }).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', {
9467
9947
  type: [
@@ -9532,7 +10012,7 @@ function initNodeEnv(command) {
9532
10012
  }
9533
10013
  function showGreeting() {
9534
10014
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9535
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.10\n`);
10015
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.12\n`);
9536
10016
  }
9537
10017
  function setupLogLevel() {
9538
10018
  if (cli_argv.length <= 3) return;
@@ -9554,5 +10034,5 @@ function runCLI() {
9554
10034
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9555
10035
  }
9556
10036
  }
9557
- let src_version = "2.0.10";
9558
- 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 };
10037
+ let src_version = "2.0.12";
10038
+ 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 };