@rsbuild/core 2.0.11 → 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/compiled/connect-next/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +80 -8
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.d.ts +4 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -1
- package/dist/756.js +610 -139
- package/dist/client/hmr.js +8 -3
- package/dist/connect-next.js +29 -26
- package/dist/http-proxy-middleware.js +64 -34
- package/dist/launch-editor-middleware.js +53 -44
- package/dist/manifest-plugin.js +7 -6
- package/dist/memfs.js +95 -95
- package/dist/sirv.js +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +8 -3
- package/dist-types/types/config.d.ts +10 -5
- package/package.json +35 -35
- package/types.d.ts +3 -2
- package/dist/mrmime.js +0 -445
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.
|
|
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
|
|
@@ -5566,6 +6010,17 @@ let HtmlResourceHintsPlugin_defaultOptions = {
|
|
|
5566
6010
|
function filterResourceHints(resourceHints, scripts) {
|
|
5567
6011
|
return resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href));
|
|
5568
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
|
+
}
|
|
5569
6024
|
function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
|
|
5570
6025
|
let extractedChunks = extractChunks(compilation, options.type), sortedFilteredFiles = ((files, include, exclude)=>{
|
|
5571
6026
|
let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
|
|
@@ -5617,16 +6072,19 @@ class HtmlResourceHintsPlugin {
|
|
|
5617
6072
|
isDev;
|
|
5618
6073
|
getHTMLPlugin;
|
|
5619
6074
|
constructor(options, type, HTMLCount, isDev, getHTMLPlugin){
|
|
5620
|
-
this.options = {
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
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;
|
|
5624
6079
|
}
|
|
5625
6080
|
apply(compiler) {
|
|
5626
6081
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
5627
6082
|
let pluginHooks = this.getHTMLPlugin().getCompilationHooks(compilation), pluginName = `HTML${upperFirst(this.type)}Plugin`;
|
|
5628
|
-
pluginHooks.beforeAssetTagGeneration.tap(pluginName, (data)=>(this.resourceHints =
|
|
5629
|
-
|
|
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),
|
|
5630
6088
|
...data.assetTags.styles
|
|
5631
6089
|
]), data));
|
|
5632
6090
|
});
|
|
@@ -5638,7 +6096,17 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
5638
6096
|
rel,
|
|
5639
6097
|
...option
|
|
5640
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
|
|
5641
6107
|
}));
|
|
6108
|
+
return Array.isArray(options) ? optionsList : optionsList[0];
|
|
6109
|
+
};
|
|
5642
6110
|
function isTerminalTraceOutput(output) {
|
|
5643
6111
|
return 'stdout' === output || 'stderr' === output;
|
|
5644
6112
|
}
|
|
@@ -5993,17 +6461,15 @@ function getEtag(stat) {
|
|
|
5993
6461
|
let mtime = stat.mtime.getTime().toString(16), size = stat.size.toString(16);
|
|
5994
6462
|
return `W/"${size}-${mtime}"`;
|
|
5995
6463
|
}
|
|
5996
|
-
function
|
|
5997
|
-
return {
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
byteLength
|
|
6003
|
-
};
|
|
6464
|
+
function createReadStream(filename, outputFileSystem, start, end) {
|
|
6465
|
+
return (0, outputFileSystem.createReadStream)(filename, {
|
|
6466
|
+
start,
|
|
6467
|
+
end,
|
|
6468
|
+
highWaterMark: 524288
|
|
6469
|
+
});
|
|
6004
6470
|
}
|
|
6005
|
-
|
|
6006
|
-
let
|
|
6471
|
+
function getContentType(str) {
|
|
6472
|
+
let mime = mrmime_lookup(str);
|
|
6007
6473
|
return !!mime && ((mime.startsWith('text/') || 'application/json' === mime || 'application/manifest+json' === mime) && (mime += '; charset=utf-8'), mime);
|
|
6008
6474
|
}
|
|
6009
6475
|
let BYTES_RANGE_REGEXP = /^ *bytes/i;
|
|
@@ -6015,6 +6481,84 @@ function parseHttpDate(date) {
|
|
|
6015
6481
|
return 'number' == typeof timestamp ? timestamp : NaN;
|
|
6016
6482
|
}
|
|
6017
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
|
+
}
|
|
6018
6562
|
function destroyStream(stream, suppress) {
|
|
6019
6563
|
'function' == typeof stream.destroy && stream.destroy(), 'function' == typeof stream.close && stream.on('open', function onOpenClose(fd) {
|
|
6020
6564
|
'number' == typeof fd && this.close();
|
|
@@ -6025,10 +6569,7 @@ let parseRangeHeaders = async (value)=>{
|
|
|
6025
6569
|
return rangeParser(Number(len), rangeHeader, {
|
|
6026
6570
|
combine: !0
|
|
6027
6571
|
});
|
|
6028
|
-
}
|
|
6029
|
-
'GET',
|
|
6030
|
-
'HEAD'
|
|
6031
|
-
];
|
|
6572
|
+
};
|
|
6032
6573
|
function sendError(res, code) {
|
|
6033
6574
|
let content = {
|
|
6034
6575
|
400: 'Bad Request',
|
|
@@ -6063,83 +6604,8 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6063
6604
|
});
|
|
6064
6605
|
});
|
|
6065
6606
|
}
|
|
6066
|
-
|
|
6067
|
-
|
|
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;
|
|
6607
|
+
req.method && 'GET' !== req.method && 'HEAD' !== req.method ? await goNext() : ready(async function processRequest() {
|
|
6608
|
+
let readStream;
|
|
6143
6609
|
if (!req.url) return void await goNext();
|
|
6144
6610
|
let resolved = await getFileFromUrl(req.url, outputFileSystem, context);
|
|
6145
6611
|
if (!resolved) return void await goNext();
|
|
@@ -6149,18 +6615,18 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6149
6615
|
}
|
|
6150
6616
|
let { fsStats, filename } = resolved, { size } = fsStats, len = size, offset = 0;
|
|
6151
6617
|
if (!res.getHeader('Content-Type')) {
|
|
6152
|
-
let contentType =
|
|
6618
|
+
let contentType = getContentType(filename);
|
|
6153
6619
|
contentType && res.setHeader('Content-Type', contentType);
|
|
6154
6620
|
}
|
|
6155
6621
|
res.getHeader('Accept-Ranges') || res.setHeader('Accept-Ranges', 'bytes');
|
|
6156
|
-
let rangeHeader = getRangeHeader();
|
|
6622
|
+
let rangeHeader = getRangeHeader(req.headers);
|
|
6157
6623
|
if (!res.getHeader('ETag') && fsStats) {
|
|
6158
6624
|
let hash = getEtag(fsStats);
|
|
6159
6625
|
res.setHeader('ETag', hash);
|
|
6160
6626
|
}
|
|
6161
|
-
if (isConditionalGET()) {
|
|
6162
|
-
if (isPreconditionFailure()) return void sendError(res, 412);
|
|
6163
|
-
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, {
|
|
6164
6630
|
etag: res.getHeader('ETag'),
|
|
6165
6631
|
'last-modified': res.getHeader('Last-Modified')
|
|
6166
6632
|
})) {
|
|
@@ -6170,7 +6636,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6170
6636
|
}
|
|
6171
6637
|
if (rangeHeader) {
|
|
6172
6638
|
let parsedRanges = await parseRangeHeaders(`${size}|${rangeHeader}`);
|
|
6173
|
-
if (isRangeFresh() || (parsedRanges = []), -1 === parsedRanges) {
|
|
6639
|
+
if (isRangeFresh(req.headers, res) || (parsedRanges = []), -1 === parsedRanges) {
|
|
6174
6640
|
logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, 416);
|
|
6175
6641
|
return;
|
|
6176
6642
|
}
|
|
@@ -6178,20 +6644,19 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6178
6644
|
}
|
|
6179
6645
|
let [start, end] = calcStartAndEnd(offset, len);
|
|
6180
6646
|
try {
|
|
6181
|
-
|
|
6647
|
+
readStream = createReadStream(filename, outputFileSystem, start, end);
|
|
6182
6648
|
} catch {
|
|
6183
6649
|
await goNext();
|
|
6184
6650
|
return;
|
|
6185
6651
|
}
|
|
6186
|
-
if (res.setHeader('Content-Length',
|
|
6652
|
+
if (res.setHeader('Content-Length', len), 'HEAD' === req.method) {
|
|
6187
6653
|
404 === res.statusCode && (res.statusCode = 200), res.end();
|
|
6188
6654
|
return;
|
|
6189
6655
|
}
|
|
6190
|
-
if ('function' != typeof bufferOrStream.pipe) return void res.end(bufferOrStream);
|
|
6191
6656
|
let cleanup = ()=>{
|
|
6192
|
-
destroyStream(
|
|
6657
|
+
destroyStream(readStream, !0);
|
|
6193
6658
|
};
|
|
6194
|
-
|
|
6659
|
+
readStream.on('error', (error)=>{
|
|
6195
6660
|
switch(cleanup(), error.code){
|
|
6196
6661
|
case 'ENAMETOOLONG':
|
|
6197
6662
|
case 'ENOENT':
|
|
@@ -6201,13 +6666,13 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6201
6666
|
default:
|
|
6202
6667
|
sendError(res, 500);
|
|
6203
6668
|
}
|
|
6204
|
-
}),
|
|
6669
|
+
}), readStream.pipe(res), on_finished_default()(res, cleanup);
|
|
6205
6670
|
});
|
|
6206
6671
|
};
|
|
6207
6672
|
}
|
|
6208
6673
|
async function setupOutputFileSystem(writeToDisk, compilers) {
|
|
6209
6674
|
if (!0 !== writeToDisk) {
|
|
6210
|
-
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.
|
|
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());
|
|
6211
6676
|
for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
|
|
6212
6677
|
}
|
|
6213
6678
|
let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
|
|
@@ -6251,12 +6716,13 @@ function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort })
|
|
|
6251
6716
|
let { target } = compiler.options;
|
|
6252
6717
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
6253
6718
|
})(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
|
|
6254
|
-
let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), clientConfig = {
|
|
6719
|
+
let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), { webSocketUrlResolver, ...clientConfig } = {
|
|
6255
6720
|
...config.dev.client
|
|
6256
6721
|
};
|
|
6257
6722
|
'<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
|
|
6258
|
-
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'))}';
|
|
6259
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))};` : ''}
|
|
6260
6726
|
init(
|
|
6261
6727
|
'${token}',
|
|
6262
6728
|
${JSON.stringify(clientConfig)},
|
|
@@ -6265,7 +6731,7 @@ init(
|
|
|
6265
6731
|
${JSON.stringify(config.server.base)},
|
|
6266
6732
|
${liveReloadEnabled},
|
|
6267
6733
|
${!!config.dev.browserLogs},
|
|
6268
|
-
${JSON.stringify(config.dev.client.logLevel)}
|
|
6734
|
+
${JSON.stringify(config.dev.client.logLevel)}${resolverPath ? ',\n urlResolver' : ''}
|
|
6269
6735
|
)
|
|
6270
6736
|
`;
|
|
6271
6737
|
new core_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
|
|
@@ -7095,7 +7561,7 @@ async function createProxyMiddleware(proxyOptions, logger) {
|
|
|
7095
7561
|
};
|
|
7096
7562
|
}
|
|
7097
7563
|
let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer, middlewares, postCallbacks })=>{
|
|
7098
|
-
let upgradeEvents = [], { server } = config, { logger } = context;
|
|
7564
|
+
let launchEditorHandlerPromise, upgradeEvents = [], { server } = config, { logger } = context;
|
|
7099
7565
|
if (server.cors) {
|
|
7100
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));
|
|
7101
7567
|
middlewares.use(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
|
|
@@ -7113,11 +7579,18 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7113
7579
|
let { compiler } = buildManager;
|
|
7114
7580
|
(compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.use(core_rspack.lazyCompilationMiddleware(compiler));
|
|
7115
7581
|
}
|
|
7116
|
-
server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
|
|
7582
|
+
if (server.base && '/' !== server.base && middlewares.use(getBaseUrlMiddleware({
|
|
7117
7583
|
base: server.base
|
|
7118
|
-
}))
|
|
7119
|
-
|
|
7120
|
-
|
|
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) {
|
|
7121
7594
|
if ('/rsbuild-dev-server' !== req.url.replace(postfixRE, '')) return void next();
|
|
7122
7595
|
res.writeHead(200, {
|
|
7123
7596
|
'Content-Type': 'text/html; charset=utf-8'
|
|
@@ -7450,11 +7923,12 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7450
7923
|
all: !1,
|
|
7451
7924
|
chunks: !0,
|
|
7452
7925
|
entrypoints: !0,
|
|
7926
|
+
ids: !0,
|
|
7453
7927
|
outputPath: !0
|
|
7454
7928
|
});
|
|
7455
7929
|
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,
|
|
7457
|
-
let chunk = chunks?.find((chunk)=>chunk.entry && chunk.
|
|
7930
|
+
let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkId)=>{
|
|
7931
|
+
let chunk = chunks?.find((chunk)=>chunk.entry && chunk.id === entryChunkId);
|
|
7458
7932
|
return chunk?.files ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
|
|
7459
7933
|
}, []);
|
|
7460
7934
|
if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
|
|
@@ -7875,7 +8349,10 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7875
8349
|
level: 'error'
|
|
7876
8350
|
}), chain.watchOptions({
|
|
7877
8351
|
aggregateTimeout: 0
|
|
7878
|
-
}), chain.performance.hints(!1), chain.
|
|
8352
|
+
}), chain.performance.hints(!1), chain.experiments({
|
|
8353
|
+
...chain.get('experiments'),
|
|
8354
|
+
pureFunctions: !0
|
|
8355
|
+
}), chain.module.parser.merge({
|
|
7879
8356
|
javascript: {
|
|
7880
8357
|
typeReexportsPresence: 'tolerant'
|
|
7881
8358
|
}
|
|
@@ -8312,7 +8789,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8312
8789
|
}, async ({ compilation, environment, sources })=>{
|
|
8313
8790
|
let { config } = environment, { appIcon } = config.html;
|
|
8314
8791
|
if (!appIcon) return;
|
|
8315
|
-
let
|
|
8792
|
+
let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
|
|
8316
8793
|
let { src, size } = icon, cacheKey = `${distDir}|${publicPath}|${src}`, cached = iconFormatMap.get(cacheKey);
|
|
8317
8794
|
if (cached) return cached;
|
|
8318
8795
|
let sizes = `${size}x${size}`;
|
|
@@ -8336,7 +8813,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8336
8813
|
mimeType: lookup(absolutePath)
|
|
8337
8814
|
};
|
|
8338
8815
|
return iconFormatMap.set(cacheKey, formatted), formatted;
|
|
8339
|
-
})(icon, distDir, publicPath,
|
|
8816
|
+
})(icon, distDir, publicPath, mrmime_lookup)), tags = [];
|
|
8340
8817
|
for (let icon of icons){
|
|
8341
8818
|
if ('web-app-manifest' === icon.target && !appIcon.name) {
|
|
8342
8819
|
addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
|
|
@@ -8867,11 +9344,8 @@ try {
|
|
|
8867
9344
|
].filter((item)=>isRegExp(item));
|
|
8868
9345
|
})(config);
|
|
8869
9346
|
if (prefetch) {
|
|
8870
|
-
let options = !0 === prefetch ? {} : prefetch;
|
|
8871
|
-
|
|
8872
|
-
...helpers_castArray(options.exclude),
|
|
8873
|
-
...excludes
|
|
8874
|
-
] : 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, [
|
|
8875
9349
|
options,
|
|
8876
9350
|
'prefetch',
|
|
8877
9351
|
HTMLCount,
|
|
@@ -8880,11 +9354,8 @@ try {
|
|
|
8880
9354
|
]);
|
|
8881
9355
|
}
|
|
8882
9356
|
if (preload) {
|
|
8883
|
-
let options = !0 === preload ? {} : preload;
|
|
8884
|
-
|
|
8885
|
-
...helpers_castArray(options.exclude),
|
|
8886
|
-
...excludes
|
|
8887
|
-
] : 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, [
|
|
8888
9359
|
options,
|
|
8889
9360
|
'preload',
|
|
8890
9361
|
HTMLCount,
|
|
@@ -8956,7 +9427,7 @@ try {
|
|
|
8956
9427
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
8957
9428
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
8958
9429
|
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.
|
|
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'));
|
|
8960
9431
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
8961
9432
|
let pluginOptions = {
|
|
8962
9433
|
fileName: manifestOptions.filename,
|
|
@@ -9470,7 +9941,7 @@ let applyServerOptions = (command)=>{
|
|
|
9470
9941
|
};
|
|
9471
9942
|
function setupCommands() {
|
|
9472
9943
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9473
|
-
cli.version("2.0.
|
|
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)', {
|
|
9474
9945
|
default: 'auto'
|
|
9475
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', {
|
|
9476
9947
|
type: [
|
|
@@ -9541,7 +10012,7 @@ function initNodeEnv(command) {
|
|
|
9541
10012
|
}
|
|
9542
10013
|
function showGreeting() {
|
|
9543
10014
|
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.
|
|
10015
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.12\n`);
|
|
9545
10016
|
}
|
|
9546
10017
|
function setupLogLevel() {
|
|
9547
10018
|
if (cli_argv.length <= 3) return;
|
|
@@ -9563,5 +10034,5 @@ function runCLI() {
|
|
|
9563
10034
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
9564
10035
|
}
|
|
9565
10036
|
}
|
|
9566
|
-
let src_version = "2.0.
|
|
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 };
|
|
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 };
|