@rsbuild/core 0.6.6 → 0.6.8

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.
@@ -1 +1 @@
1
- (()=>{var i={841:(i,a,t)=>{const p=t(477);function parse(i){let a=i.url;if(a==null)return;let t=i._parsedUrl;if(t&&t.raw===a)return t;let e=a,l="",o;if(a.length>1){let i=a.indexOf("?",1);if(i!==-1){l=a.substring(i);e=a.substring(0,i);if(l.length>1){o=p.parse(l.substring(1))}}}return i._parsedUrl={pathname:e,search:l,query:o,raw:a}}a.parse=parse},786:(i,a)=>{const t={"3g2":"video/3gpp2","3gp":"video/3gpp","3gpp":"video/3gpp","3mf":"model/3mf",aac:"audio/aac",ac:"application/pkix-attr-cert",adp:"audio/adpcm",adts:"audio/aac",ai:"application/postscript",aml:"application/automationml-aml+xml",amlx:"application/automationml-amlx+zip",amr:"audio/amr",apng:"image/apng",appcache:"text/cache-manifest",appinstaller:"application/appinstaller",appx:"application/appx",appxbundle:"application/appxbundle",asc:"application/pgp-keys",atom:"application/atom+xml",atomcat:"application/atomcat+xml",atomdeleted:"application/atomdeleted+xml",atomsvc:"application/atomsvc+xml",au:"audio/basic",avci:"image/avci",avcs:"image/avcs",avif:"image/avif",aw:"application/applixware",bdoc:"application/bdoc",bin:"application/octet-stream",bmp:"image/bmp",bpk:"application/octet-stream",btf:"image/prs.btif",btif:"image/prs.btif",buffer:"application/octet-stream",ccxml:"application/ccxml+xml",cdfx:"application/cdfx+xml",cdmia:"application/cdmi-capability",cdmic:"application/cdmi-container",cdmid:"application/cdmi-domain",cdmio:"application/cdmi-object",cdmiq:"application/cdmi-queue",cer:"application/pkix-cert",cgm:"image/cgm",cjs:"application/node",class:"application/java-vm",coffee:"text/coffeescript",conf:"text/plain",cpl:"application/cpl+xml",cpt:"application/mac-compactpro",crl:"application/pkix-crl",css:"text/css",csv:"text/csv",cu:"application/cu-seeme",cwl:"application/cwl",cww:"application/prs.cww",davmount:"application/davmount+xml",dbk:"application/docbook+xml",deb:"application/octet-stream",def:"text/plain",deploy:"application/octet-stream",dib:"image/bmp","disposition-notification":"message/disposition-notification",dist:"application/octet-stream",distz:"application/octet-stream",dll:"application/octet-stream",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dpx:"image/dpx",drle:"image/dicom-rle",dsc:"text/prs.lines.tag",dssc:"application/dssc+der",dtd:"application/xml-dtd",dump:"application/octet-stream",dwd:"application/atsc-dwd+xml",ear:"application/java-archive",ecma:"application/ecmascript",elc:"application/octet-stream",emf:"image/emf",eml:"message/rfc822",emma:"application/emma+xml",emotionml:"application/emotionml+xml",eps:"application/postscript",epub:"application/epub+zip",exe:"application/octet-stream",exi:"application/exi",exp:"application/express",exr:"image/aces",ez:"application/andrew-inset",fdf:"application/fdf",fdt:"application/fdt+xml",fits:"image/fits",g3:"image/g3fax",gbr:"application/rpki-ghostbusters",geojson:"application/geo+json",gif:"image/gif",glb:"model/gltf-binary",gltf:"model/gltf+json",gml:"application/gml+xml",gpx:"application/gpx+xml",gram:"application/srgs",grxml:"application/srgs+xml",gxf:"application/gxf",gz:"application/gzip",h261:"video/h261",h263:"video/h263",h264:"video/h264",heic:"image/heic",heics:"image/heic-sequence",heif:"image/heif",heifs:"image/heif-sequence",hej2:"image/hej2k",held:"application/atsc-held+xml",hjson:"application/hjson",hlp:"application/winhlp",hqx:"application/mac-binhex40",hsj2:"image/hsj2",htm:"text/html",html:"text/html",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",img:"application/octet-stream",in:"text/plain",ini:"text/plain",ink:"application/inkml+xml",inkml:"application/inkml+xml",ipfix:"application/ipfix",iso:"application/octet-stream",its:"application/its+xml",jade:"text/jade",jar:"application/java-archive",jhc:"image/jphc",jls:"image/jls",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpf:"image/jpx",jpg:"image/jpeg",jpg2:"image/jp2",jpgm:"image/jpm",jpgv:"video/jpeg",jph:"image/jph",jpm:"image/jpm",jpx:"image/jpx",js:"text/javascript",json:"application/json",json5:"application/json5",jsonld:"application/ld+json",jsonml:"application/jsonml+json",jsx:"text/jsx",jt:"model/jt",jxr:"image/jxr",jxra:"image/jxra",jxrs:"image/jxrs",jxs:"image/jxs",jxsc:"image/jxsc",jxsi:"image/jxsi",jxss:"image/jxss",kar:"audio/midi",ktx:"image/ktx",ktx2:"image/ktx2",less:"text/less",lgr:"application/lgr+xml",list:"text/plain",litcoffee:"text/coffeescript",log:"text/plain",lostxml:"application/lost+xml",lrf:"application/octet-stream",m1v:"video/mpeg",m21:"application/mp21",m2a:"audio/mpeg",m2v:"video/mpeg",m3a:"audio/mpeg",m4a:"audio/mp4",m4p:"application/mp4",m4s:"video/iso.segment",ma:"application/mathematica",mads:"application/mads+xml",maei:"application/mmt-aei+xml",man:"text/troff",manifest:"text/cache-manifest",map:"application/json",mar:"application/octet-stream",markdown:"text/markdown",mathml:"application/mathml+xml",mb:"application/mathematica",mbox:"application/mbox",md:"text/markdown",mdx:"text/mdx",me:"text/troff",mesh:"model/mesh",meta4:"application/metalink4+xml",metalink:"application/metalink+xml",mets:"application/mets+xml",mft:"application/rpki-manifest",mid:"audio/midi",midi:"audio/midi",mime:"message/rfc822",mj2:"video/mj2",mjp2:"video/mj2",mjs:"text/javascript",mml:"text/mathml",mods:"application/mods+xml",mov:"video/quicktime",mp2:"audio/mpeg",mp21:"application/mp21",mp2a:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4a:"audio/mp4",mp4s:"application/mp4",mp4v:"video/mp4",mpd:"application/dash+xml",mpe:"video/mpeg",mpeg:"video/mpeg",mpf:"application/media-policy-dataset+xml",mpg:"video/mpeg",mpg4:"video/mp4",mpga:"audio/mpeg",mpp:"application/dash-patch+xml",mrc:"application/marc",mrcx:"application/marcxml+xml",ms:"text/troff",mscml:"application/mediaservercontrol+xml",msh:"model/mesh",msi:"application/octet-stream",msix:"application/msix",msixbundle:"application/msixbundle",msm:"application/octet-stream",msp:"application/octet-stream",mtl:"model/mtl",musd:"application/mmt-usd+xml",mxf:"application/mxf",mxmf:"audio/mobile-xmf",mxml:"application/xv+xml",n3:"text/n3",nb:"application/mathematica",nq:"application/n-quads",nt:"application/n-triples",obj:"model/obj",oda:"application/oda",oga:"audio/ogg",ogg:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",omdoc:"application/omdoc+xml",onepkg:"application/onenote",onetmp:"application/onenote",onetoc:"application/onenote",onetoc2:"application/onenote",opf:"application/oebps-package+xml",opus:"audio/ogg",otf:"font/otf",owl:"application/rdf+xml",oxps:"application/oxps",p10:"application/pkcs10",p7c:"application/pkcs7-mime",p7m:"application/pkcs7-mime",p7s:"application/pkcs7-signature",p8:"application/pkcs8",pdf:"application/pdf",pfr:"application/font-tdpfr",pgp:"application/pgp-encrypted",pkg:"application/octet-stream",pki:"application/pkixcmp",pkipath:"application/pkix-pkipath",pls:"application/pls+xml",png:"image/png",prc:"model/prc",prf:"application/pics-rules",provx:"application/provenance+xml",ps:"application/postscript",pskcxml:"application/pskc+xml",pti:"image/prs.pti",qt:"video/quicktime",raml:"application/raml+yaml",rapd:"application/route-apd+xml",rdf:"application/rdf+xml",relo:"application/p2p-overlay+xml",rif:"application/reginfo+xml",rl:"application/resource-lists+xml",rld:"application/resource-lists-diff+xml",rmi:"audio/midi",rnc:"application/relax-ng-compact-syntax",rng:"application/xml",roa:"application/rpki-roa",roff:"text/troff",rq:"application/sparql-query",rs:"application/rls-services+xml",rsat:"application/atsc-rsat+xml",rsd:"application/rsd+xml",rsheet:"application/urc-ressheet+xml",rss:"application/rss+xml",rtf:"text/rtf",rtx:"text/richtext",rusd:"application/route-usd+xml",s3m:"audio/s3m",sbml:"application/sbml+xml",scq:"application/scvp-cv-request",scs:"application/scvp-cv-response",sdp:"application/sdp",senmlx:"application/senml+xml",sensmlx:"application/sensml+xml",ser:"application/java-serialized-object",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgi:"image/sgi",sgm:"text/sgml",sgml:"text/sgml",shex:"text/shex",shf:"application/shf+xml",shtml:"text/html",sieve:"application/sieve",sig:"application/pgp-signature",sil:"audio/silk",silo:"model/mesh",siv:"application/sieve",slim:"text/slim",slm:"text/slim",sls:"application/route-s-tsid+xml",smi:"application/smil+xml",smil:"application/smil+xml",snd:"audio/basic",so:"application/octet-stream",spdx:"text/spdx",spp:"application/scvp-vp-response",spq:"application/scvp-vp-request",spx:"audio/ogg",sql:"application/sql",sru:"application/sru+xml",srx:"application/sparql-results+xml",ssdl:"application/ssdl+xml",ssml:"application/ssml+xml",stk:"application/hyperstudio",stl:"model/stl",stpx:"model/step+xml",stpxz:"model/step-xml+zip",stpz:"model/step+zip",styl:"text/stylus",stylus:"text/stylus",svg:"image/svg+xml",svgz:"image/svg+xml",swidtag:"application/swid+xml",t:"text/troff",t38:"image/t38",td:"application/urc-targetdesc+xml",tei:"application/tei+xml",teicorpus:"application/tei+xml",text:"text/plain",tfi:"application/thraud+xml",tfx:"image/tiff-fx",tif:"image/tiff",tiff:"image/tiff",toml:"application/toml",tr:"text/troff",trig:"application/trig",ts:"video/mp2t",tsd:"application/timestamped-data",tsv:"text/tab-separated-values",ttc:"font/collection",ttf:"font/ttf",ttl:"text/turtle",ttml:"application/ttml+xml",txt:"text/plain",u3d:"model/u3d",u8dsn:"message/global-delivery-status",u8hdr:"message/global-headers",u8mdn:"message/global-disposition-notification",u8msg:"message/global",ubj:"application/ubjson",uri:"text/uri-list",uris:"text/uri-list",urls:"text/uri-list",vcard:"text/vcard",vrml:"model/vrml",vtt:"text/vtt",vxml:"application/voicexml+xml",war:"application/java-archive",wasm:"application/wasm",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webmanifest:"application/manifest+json",webp:"image/webp",wgsl:"text/wgsl",wgt:"application/widget",wif:"application/watcherinfo+xml",wmf:"image/wmf",woff:"font/woff",woff2:"font/woff2",wrl:"model/vrml",wsdl:"application/wsdl+xml",wspolicy:"application/wspolicy+xml",x3d:"model/x3d+xml",x3db:"model/x3d+fastinfoset",x3dbz:"model/x3d+binary",x3dv:"model/x3d-vrml",x3dvz:"model/x3d+vrml",x3dz:"model/x3d+xml",xaml:"application/xaml+xml",xav:"application/xcap-att+xml",xca:"application/xcap-caps+xml",xcs:"application/calendar+xml",xdf:"application/xcap-diff+xml",xdssc:"application/dssc+xml",xel:"application/xcap-el+xml",xenc:"application/xenc+xml",xer:"application/patch-ops-error+xml",xfdf:"application/xfdf",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xhvml:"application/xv+xml",xlf:"application/xliff+xml",xm:"audio/xm",xml:"text/xml",xns:"application/xcap-ns+xml",xop:"application/xop+xml",xpl:"application/xproc+xml",xsd:"application/xml",xsf:"application/prs.xsf+xml",xsl:"application/xml",xslt:"application/xml",xspf:"application/xspf+xml",xvm:"application/xv+xml",xvml:"application/xv+xml",yaml:"text/yaml",yang:"application/yang",yin:"application/yin+xml",yml:"text/yaml",zip:"application/zip"};function lookup(i){let a=(""+i).trim().toLowerCase();let p=a.lastIndexOf(".");return t[!~p?a:a.substring(++p)]}a.mimes=t;a.lookup=lookup},486:(i,a,t)=>{const p=t(147);const{join:e,normalize:l,resolve:o}=t(17);const{totalist:s}=t(190);const{parse:m}=t(841);const{lookup:n}=t(786);const noop=()=>{};function isMatch(i,a){for(let t=0;t<a.length;t++){if(a[t].test(i))return true}}function toAssume(i,a){let t=0,p,e=i.length-1;if(i.charCodeAt(e)===47){i=i.substring(0,e)}let l=[],o=`${i}/index`;for(;t<a.length;t++){p=a[t]?`.${a[t]}`:"";if(i)l.push(i+p);l.push(o+p)}return l}function viaCache(i,a,t){let p=0,e,l=toAssume(a,t);for(;p<l.length;p++){if(e=i[l[p]])return e}}function viaLocal(i,a,t,o){let s=0,m=toAssume(t,o);let n,c,r,x;for(;s<m.length;s++){n=l(e(i,r=m[s]));if(n.startsWith(i)&&p.existsSync(n)){c=p.statSync(n);if(c.isDirectory())continue;x=toHeaders(r,c,a);x["Cache-Control"]=a?"no-cache":"no-store";return{abs:n,stats:c,headers:x}}}}function is404(i,a){return a.statusCode=404,a.end()}function send(i,a,t,e,l){let o=200,s,m={};l={...l};for(let i in l){s=a.getHeader(i);if(s)l[i]=s}if(s=a.getHeader("content-type")){l["Content-Type"]=s}if(i.headers.range){o=206;let[t,p]=i.headers.range.replace("bytes=","").split("-");let s=m.end=parseInt(p,10)||e.size-1;let n=m.start=parseInt(t,10)||0;if(s>=e.size){s=e.size-1}if(n>=e.size){a.setHeader("Content-Range",`bytes */${e.size}`);a.statusCode=416;return a.end()}l["Content-Range"]=`bytes ${n}-${s}/${e.size}`;l["Content-Length"]=s-n+1;l["Accept-Ranges"]="bytes"}a.writeHead(o,l);p.createReadStream(t,m).pipe(a)}const c={".br":"br",".gz":"gzip"};function toHeaders(i,a,t){let p=c[i.slice(-3)];let e=n(i.slice(0,p&&-3))||"";if(e==="text/html")e+=";charset=utf-8";let l={"Content-Length":a.size,"Content-Type":e,"Last-Modified":a.mtime.toUTCString()};if(p)l["Content-Encoding"]=p;if(t)l["ETag"]=`W/"${a.size}-${a.mtime.getTime()}"`;return l}i.exports=function(i,a={}){i=o(i||".");let t=a.onNoMatch||is404;let p=a.setHeaders||noop;let e=a.extensions||["html","htm"];let l=a.gzip&&e.map((i=>`${i}.gz`)).concat("gz");let n=a.brotli&&e.map((i=>`${i}.br`)).concat("br");const c={};let r="/";let x=!!a.etag;let d=!!a.single;if(typeof a.single==="string"){let i=a.single.lastIndexOf(".");r+=!!~i?a.single.substring(0,i):a.single}let g=[];if(a.ignores!==false){g.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);if(a.dotfiles)g.push(/\/\.\w/);else g.push(/\/\.well-known/);[].concat(a.ignores||[]).forEach((i=>{g.push(new RegExp(i,"i"))}))}let f=a.maxAge!=null&&`public,max-age=${a.maxAge}`;if(f&&a.immutable)f+=",immutable";else if(f&&a.maxAge===0)f+=",must-revalidate";if(!a.dev){s(i,((i,t,p)=>{if(/\.well-known[\\+\/]/.test(i)){}else if(!a.dotfiles&&/(^\.|[\\+|\/+]\.)/.test(i))return;let e=toHeaders(i,p,x);if(f)e["Cache-Control"]=f;c["/"+i.normalize().replace(/\\+/g,"/")]={abs:t,stats:p,headers:e}}))}let u=a.dev?viaLocal.bind(0,i,x):viaCache.bind(0,c);return function(i,a,o){let s=[""];let c=m(i).pathname;let f=i.headers["accept-encoding"]||"";if(l&&f.includes("gzip"))s.unshift(...l);if(n&&/(br|brotli)/i.test(f))s.unshift(...n);s.push(...e);if(c.indexOf("%")!==-1){try{c=decodeURI(c)}catch(i){}}let h=u(c,s)||d&&!isMatch(c,g)&&u(r,s);if(!h)return o?o():t(i,a);if(x&&i.headers["if-none-match"]===h.headers["ETag"]){a.writeHead(304);return a.end()}if(l||n){a.setHeader("Vary","Accept-Encoding")}p(a,c,h.stats);send(i,a,h.abs,h.stats,h.headers)}}},190:(i,a,t)=>{const{join:p,resolve:e}=t(17);const{readdirSync:l,statSync:o}=t(147);function totalist(i,a,t=""){i=e(".",i);let s=l(i);let m=0,n,c;for(;m<s.length;m++){n=p(i,s[m]);c=o(n);c.isDirectory()?totalist(n,a,p(t,s[m])):a(p(t,s[m]),n,c)}}a.totalist=totalist},147:i=>{"use strict";i.exports=require("fs")},17:i=>{"use strict";i.exports=require("path")},477:i=>{"use strict";i.exports=require("querystring")}};var a={};function __nccwpck_require__(t){var p=a[t];if(p!==undefined){return p.exports}var e=a[t]={exports:{}};var l=true;try{i[t](e,e.exports,__nccwpck_require__);l=false}finally{if(l)delete a[t]}return e.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(486);module.exports=t})();
1
+ (()=>{var i={665:(i,a,t)=>{const p=t(477);function parse(i){let a=i.url;if(a==null)return;let t=i._parsedUrl;if(t&&t.raw===a)return t;let e=a,l="",o;if(a.length>1){let i=a.indexOf("?",1);if(i!==-1){l=a.substring(i);e=a.substring(0,i);if(l.length>1){o=p.parse(l.substring(1))}}}return i._parsedUrl={pathname:e,search:l,query:o,raw:a}}a.parse=parse},786:(i,a)=>{const t={"3g2":"video/3gpp2","3gp":"video/3gpp","3gpp":"video/3gpp","3mf":"model/3mf",aac:"audio/aac",ac:"application/pkix-attr-cert",adp:"audio/adpcm",adts:"audio/aac",ai:"application/postscript",aml:"application/automationml-aml+xml",amlx:"application/automationml-amlx+zip",amr:"audio/amr",apng:"image/apng",appcache:"text/cache-manifest",appinstaller:"application/appinstaller",appx:"application/appx",appxbundle:"application/appxbundle",asc:"application/pgp-keys",atom:"application/atom+xml",atomcat:"application/atomcat+xml",atomdeleted:"application/atomdeleted+xml",atomsvc:"application/atomsvc+xml",au:"audio/basic",avci:"image/avci",avcs:"image/avcs",avif:"image/avif",aw:"application/applixware",bdoc:"application/bdoc",bin:"application/octet-stream",bmp:"image/bmp",bpk:"application/octet-stream",btf:"image/prs.btif",btif:"image/prs.btif",buffer:"application/octet-stream",ccxml:"application/ccxml+xml",cdfx:"application/cdfx+xml",cdmia:"application/cdmi-capability",cdmic:"application/cdmi-container",cdmid:"application/cdmi-domain",cdmio:"application/cdmi-object",cdmiq:"application/cdmi-queue",cer:"application/pkix-cert",cgm:"image/cgm",cjs:"application/node",class:"application/java-vm",coffee:"text/coffeescript",conf:"text/plain",cpl:"application/cpl+xml",cpt:"application/mac-compactpro",crl:"application/pkix-crl",css:"text/css",csv:"text/csv",cu:"application/cu-seeme",cwl:"application/cwl",cww:"application/prs.cww",davmount:"application/davmount+xml",dbk:"application/docbook+xml",deb:"application/octet-stream",def:"text/plain",deploy:"application/octet-stream",dib:"image/bmp","disposition-notification":"message/disposition-notification",dist:"application/octet-stream",distz:"application/octet-stream",dll:"application/octet-stream",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dpx:"image/dpx",drle:"image/dicom-rle",dsc:"text/prs.lines.tag",dssc:"application/dssc+der",dtd:"application/xml-dtd",dump:"application/octet-stream",dwd:"application/atsc-dwd+xml",ear:"application/java-archive",ecma:"application/ecmascript",elc:"application/octet-stream",emf:"image/emf",eml:"message/rfc822",emma:"application/emma+xml",emotionml:"application/emotionml+xml",eps:"application/postscript",epub:"application/epub+zip",exe:"application/octet-stream",exi:"application/exi",exp:"application/express",exr:"image/aces",ez:"application/andrew-inset",fdf:"application/fdf",fdt:"application/fdt+xml",fits:"image/fits",g3:"image/g3fax",gbr:"application/rpki-ghostbusters",geojson:"application/geo+json",gif:"image/gif",glb:"model/gltf-binary",gltf:"model/gltf+json",gml:"application/gml+xml",gpx:"application/gpx+xml",gram:"application/srgs",grxml:"application/srgs+xml",gxf:"application/gxf",gz:"application/gzip",h261:"video/h261",h263:"video/h263",h264:"video/h264",heic:"image/heic",heics:"image/heic-sequence",heif:"image/heif",heifs:"image/heif-sequence",hej2:"image/hej2k",held:"application/atsc-held+xml",hjson:"application/hjson",hlp:"application/winhlp",hqx:"application/mac-binhex40",hsj2:"image/hsj2",htm:"text/html",html:"text/html",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",img:"application/octet-stream",in:"text/plain",ini:"text/plain",ink:"application/inkml+xml",inkml:"application/inkml+xml",ipfix:"application/ipfix",iso:"application/octet-stream",its:"application/its+xml",jade:"text/jade",jar:"application/java-archive",jhc:"image/jphc",jls:"image/jls",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpf:"image/jpx",jpg:"image/jpeg",jpg2:"image/jp2",jpgm:"image/jpm",jpgv:"video/jpeg",jph:"image/jph",jpm:"image/jpm",jpx:"image/jpx",js:"text/javascript",json:"application/json",json5:"application/json5",jsonld:"application/ld+json",jsonml:"application/jsonml+json",jsx:"text/jsx",jt:"model/jt",jxr:"image/jxr",jxra:"image/jxra",jxrs:"image/jxrs",jxs:"image/jxs",jxsc:"image/jxsc",jxsi:"image/jxsi",jxss:"image/jxss",kar:"audio/midi",ktx:"image/ktx",ktx2:"image/ktx2",less:"text/less",lgr:"application/lgr+xml",list:"text/plain",litcoffee:"text/coffeescript",log:"text/plain",lostxml:"application/lost+xml",lrf:"application/octet-stream",m1v:"video/mpeg",m21:"application/mp21",m2a:"audio/mpeg",m2v:"video/mpeg",m3a:"audio/mpeg",m4a:"audio/mp4",m4p:"application/mp4",m4s:"video/iso.segment",ma:"application/mathematica",mads:"application/mads+xml",maei:"application/mmt-aei+xml",man:"text/troff",manifest:"text/cache-manifest",map:"application/json",mar:"application/octet-stream",markdown:"text/markdown",mathml:"application/mathml+xml",mb:"application/mathematica",mbox:"application/mbox",md:"text/markdown",mdx:"text/mdx",me:"text/troff",mesh:"model/mesh",meta4:"application/metalink4+xml",metalink:"application/metalink+xml",mets:"application/mets+xml",mft:"application/rpki-manifest",mid:"audio/midi",midi:"audio/midi",mime:"message/rfc822",mj2:"video/mj2",mjp2:"video/mj2",mjs:"text/javascript",mml:"text/mathml",mods:"application/mods+xml",mov:"video/quicktime",mp2:"audio/mpeg",mp21:"application/mp21",mp2a:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4a:"audio/mp4",mp4s:"application/mp4",mp4v:"video/mp4",mpd:"application/dash+xml",mpe:"video/mpeg",mpeg:"video/mpeg",mpf:"application/media-policy-dataset+xml",mpg:"video/mpeg",mpg4:"video/mp4",mpga:"audio/mpeg",mpp:"application/dash-patch+xml",mrc:"application/marc",mrcx:"application/marcxml+xml",ms:"text/troff",mscml:"application/mediaservercontrol+xml",msh:"model/mesh",msi:"application/octet-stream",msix:"application/msix",msixbundle:"application/msixbundle",msm:"application/octet-stream",msp:"application/octet-stream",mtl:"model/mtl",musd:"application/mmt-usd+xml",mxf:"application/mxf",mxmf:"audio/mobile-xmf",mxml:"application/xv+xml",n3:"text/n3",nb:"application/mathematica",nq:"application/n-quads",nt:"application/n-triples",obj:"model/obj",oda:"application/oda",oga:"audio/ogg",ogg:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",omdoc:"application/omdoc+xml",onepkg:"application/onenote",onetmp:"application/onenote",onetoc:"application/onenote",onetoc2:"application/onenote",opf:"application/oebps-package+xml",opus:"audio/ogg",otf:"font/otf",owl:"application/rdf+xml",oxps:"application/oxps",p10:"application/pkcs10",p7c:"application/pkcs7-mime",p7m:"application/pkcs7-mime",p7s:"application/pkcs7-signature",p8:"application/pkcs8",pdf:"application/pdf",pfr:"application/font-tdpfr",pgp:"application/pgp-encrypted",pkg:"application/octet-stream",pki:"application/pkixcmp",pkipath:"application/pkix-pkipath",pls:"application/pls+xml",png:"image/png",prc:"model/prc",prf:"application/pics-rules",provx:"application/provenance+xml",ps:"application/postscript",pskcxml:"application/pskc+xml",pti:"image/prs.pti",qt:"video/quicktime",raml:"application/raml+yaml",rapd:"application/route-apd+xml",rdf:"application/rdf+xml",relo:"application/p2p-overlay+xml",rif:"application/reginfo+xml",rl:"application/resource-lists+xml",rld:"application/resource-lists-diff+xml",rmi:"audio/midi",rnc:"application/relax-ng-compact-syntax",rng:"application/xml",roa:"application/rpki-roa",roff:"text/troff",rq:"application/sparql-query",rs:"application/rls-services+xml",rsat:"application/atsc-rsat+xml",rsd:"application/rsd+xml",rsheet:"application/urc-ressheet+xml",rss:"application/rss+xml",rtf:"text/rtf",rtx:"text/richtext",rusd:"application/route-usd+xml",s3m:"audio/s3m",sbml:"application/sbml+xml",scq:"application/scvp-cv-request",scs:"application/scvp-cv-response",sdp:"application/sdp",senmlx:"application/senml+xml",sensmlx:"application/sensml+xml",ser:"application/java-serialized-object",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgi:"image/sgi",sgm:"text/sgml",sgml:"text/sgml",shex:"text/shex",shf:"application/shf+xml",shtml:"text/html",sieve:"application/sieve",sig:"application/pgp-signature",sil:"audio/silk",silo:"model/mesh",siv:"application/sieve",slim:"text/slim",slm:"text/slim",sls:"application/route-s-tsid+xml",smi:"application/smil+xml",smil:"application/smil+xml",snd:"audio/basic",so:"application/octet-stream",spdx:"text/spdx",spp:"application/scvp-vp-response",spq:"application/scvp-vp-request",spx:"audio/ogg",sql:"application/sql",sru:"application/sru+xml",srx:"application/sparql-results+xml",ssdl:"application/ssdl+xml",ssml:"application/ssml+xml",stk:"application/hyperstudio",stl:"model/stl",stpx:"model/step+xml",stpxz:"model/step-xml+zip",stpz:"model/step+zip",styl:"text/stylus",stylus:"text/stylus",svg:"image/svg+xml",svgz:"image/svg+xml",swidtag:"application/swid+xml",t:"text/troff",t38:"image/t38",td:"application/urc-targetdesc+xml",tei:"application/tei+xml",teicorpus:"application/tei+xml",text:"text/plain",tfi:"application/thraud+xml",tfx:"image/tiff-fx",tif:"image/tiff",tiff:"image/tiff",toml:"application/toml",tr:"text/troff",trig:"application/trig",ts:"video/mp2t",tsd:"application/timestamped-data",tsv:"text/tab-separated-values",ttc:"font/collection",ttf:"font/ttf",ttl:"text/turtle",ttml:"application/ttml+xml",txt:"text/plain",u3d:"model/u3d",u8dsn:"message/global-delivery-status",u8hdr:"message/global-headers",u8mdn:"message/global-disposition-notification",u8msg:"message/global",ubj:"application/ubjson",uri:"text/uri-list",uris:"text/uri-list",urls:"text/uri-list",vcard:"text/vcard",vrml:"model/vrml",vtt:"text/vtt",vxml:"application/voicexml+xml",war:"application/java-archive",wasm:"application/wasm",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webmanifest:"application/manifest+json",webp:"image/webp",wgsl:"text/wgsl",wgt:"application/widget",wif:"application/watcherinfo+xml",wmf:"image/wmf",woff:"font/woff",woff2:"font/woff2",wrl:"model/vrml",wsdl:"application/wsdl+xml",wspolicy:"application/wspolicy+xml",x3d:"model/x3d+xml",x3db:"model/x3d+fastinfoset",x3dbz:"model/x3d+binary",x3dv:"model/x3d-vrml",x3dvz:"model/x3d+vrml",x3dz:"model/x3d+xml",xaml:"application/xaml+xml",xav:"application/xcap-att+xml",xca:"application/xcap-caps+xml",xcs:"application/calendar+xml",xdf:"application/xcap-diff+xml",xdssc:"application/dssc+xml",xel:"application/xcap-el+xml",xenc:"application/xenc+xml",xer:"application/patch-ops-error+xml",xfdf:"application/xfdf",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xhvml:"application/xv+xml",xlf:"application/xliff+xml",xm:"audio/xm",xml:"text/xml",xns:"application/xcap-ns+xml",xop:"application/xop+xml",xpl:"application/xproc+xml",xsd:"application/xml",xsf:"application/prs.xsf+xml",xsl:"application/xml",xslt:"application/xml",xspf:"application/xspf+xml",xvm:"application/xv+xml",xvml:"application/xv+xml",yaml:"text/yaml",yang:"application/yang",yin:"application/yin+xml",yml:"text/yaml",zip:"application/zip"};function lookup(i){let a=(""+i).trim().toLowerCase();let p=a.lastIndexOf(".");return t[!~p?a:a.substring(++p)]}a.mimes=t;a.lookup=lookup},486:(i,a,t)=>{const p=t(147);const{join:e,normalize:l,resolve:o}=t(17);const{totalist:s}=t(190);const{parse:m}=t(665);const{lookup:n}=t(786);const noop=()=>{};function isMatch(i,a){for(let t=0;t<a.length;t++){if(a[t].test(i))return true}}function toAssume(i,a){let t=0,p,e=i.length-1;if(i.charCodeAt(e)===47){i=i.substring(0,e)}let l=[],o=`${i}/index`;for(;t<a.length;t++){p=a[t]?`.${a[t]}`:"";if(i)l.push(i+p);l.push(o+p)}return l}function viaCache(i,a,t){let p=0,e,l=toAssume(a,t);for(;p<l.length;p++){if(e=i[l[p]])return e}}function viaLocal(i,a,t,o){let s=0,m=toAssume(t,o);let n,c,r,x;for(;s<m.length;s++){n=l(e(i,r=m[s]));if(n.startsWith(i)&&p.existsSync(n)){c=p.statSync(n);if(c.isDirectory())continue;x=toHeaders(r,c,a);x["Cache-Control"]=a?"no-cache":"no-store";return{abs:n,stats:c,headers:x}}}}function is404(i,a){return a.statusCode=404,a.end()}function send(i,a,t,e,l){let o=200,s,m={};l={...l};for(let i in l){s=a.getHeader(i);if(s)l[i]=s}if(s=a.getHeader("content-type")){l["Content-Type"]=s}if(i.headers.range){o=206;let[t,p]=i.headers.range.replace("bytes=","").split("-");let s=m.end=parseInt(p,10)||e.size-1;let n=m.start=parseInt(t,10)||0;if(s>=e.size){s=e.size-1}if(n>=e.size){a.setHeader("Content-Range",`bytes */${e.size}`);a.statusCode=416;return a.end()}l["Content-Range"]=`bytes ${n}-${s}/${e.size}`;l["Content-Length"]=s-n+1;l["Accept-Ranges"]="bytes"}a.writeHead(o,l);p.createReadStream(t,m).pipe(a)}const c={".br":"br",".gz":"gzip"};function toHeaders(i,a,t){let p=c[i.slice(-3)];let e=n(i.slice(0,p&&-3))||"";if(e==="text/html")e+=";charset=utf-8";let l={"Content-Length":a.size,"Content-Type":e,"Last-Modified":a.mtime.toUTCString()};if(p)l["Content-Encoding"]=p;if(t)l["ETag"]=`W/"${a.size}-${a.mtime.getTime()}"`;return l}i.exports=function(i,a={}){i=o(i||".");let t=a.onNoMatch||is404;let p=a.setHeaders||noop;let e=a.extensions||["html","htm"];let l=a.gzip&&e.map((i=>`${i}.gz`)).concat("gz");let n=a.brotli&&e.map((i=>`${i}.br`)).concat("br");const c={};let r="/";let x=!!a.etag;let d=!!a.single;if(typeof a.single==="string"){let i=a.single.lastIndexOf(".");r+=!!~i?a.single.substring(0,i):a.single}let g=[];if(a.ignores!==false){g.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);if(a.dotfiles)g.push(/\/\.\w/);else g.push(/\/\.well-known/);[].concat(a.ignores||[]).forEach((i=>{g.push(new RegExp(i,"i"))}))}let f=a.maxAge!=null&&`public,max-age=${a.maxAge}`;if(f&&a.immutable)f+=",immutable";else if(f&&a.maxAge===0)f+=",must-revalidate";if(!a.dev){s(i,((i,t,p)=>{if(/\.well-known[\\+\/]/.test(i)){}else if(!a.dotfiles&&/(^\.|[\\+|\/+]\.)/.test(i))return;let e=toHeaders(i,p,x);if(f)e["Cache-Control"]=f;c["/"+i.normalize().replace(/\\+/g,"/")]={abs:t,stats:p,headers:e}}))}let u=a.dev?viaLocal.bind(0,i,x):viaCache.bind(0,c);return function(i,a,o){let s=[""];let c=m(i).pathname;let f=i.headers["accept-encoding"]||"";if(l&&f.includes("gzip"))s.unshift(...l);if(n&&/(br|brotli)/i.test(f))s.unshift(...n);s.push(...e);if(c.indexOf("%")!==-1){try{c=decodeURI(c)}catch(i){}}let h=u(c,s)||d&&!isMatch(c,g)&&u(r,s);if(!h)return o?o():t(i,a);if(x&&i.headers["if-none-match"]===h.headers["ETag"]){a.writeHead(304);return a.end()}if(l||n){a.setHeader("Vary","Accept-Encoding")}p(a,c,h.stats);send(i,a,h.abs,h.stats,h.headers)}}},190:(i,a,t)=>{const{join:p,resolve:e}=t(17);const{readdirSync:l,statSync:o}=t(147);function totalist(i,a,t=""){i=e(".",i);let s=l(i);let m=0,n,c;for(;m<s.length;m++){n=p(i,s[m]);c=o(n);c.isDirectory()?totalist(n,a,p(t,s[m])):a(p(t,s[m]),n,c)}}a.totalist=totalist},147:i=>{"use strict";i.exports=require("fs")},17:i=>{"use strict";i.exports=require("path")},477:i=>{"use strict";i.exports=require("querystring")}};var a={};function __nccwpck_require__(t){var p=a[t];if(p!==undefined){return p.exports}var e=a[t]={exports:{}};var l=true;try{i[t](e,e.exports,__nccwpck_require__);l=false}finally{if(l)delete a[t]}return e.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(486);module.exports=t})();
@@ -39,7 +39,7 @@ const applyServerOptions = (command) => {
39
39
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
40
40
  };
41
41
  function runCli() {
42
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.6");
42
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.8");
43
43
  const devCommand = import_commander.program.command("dev");
44
44
  const buildCommand = import_commander.program.command("build");
45
45
  const previewCommand = import_commander.program.command("preview");
@@ -34,7 +34,7 @@ function prepareCli() {
34
34
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
35
35
  console.log();
36
36
  }
37
- import_rslog.logger.greet(` ${`Rsbuild v${"0.6.6"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.6.8"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -6,7 +6,7 @@
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
8
  import type { StatsCompilation } from 'webpack';
9
- export declare function formatStatsMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
9
+ export declare function formatStatsMessages(stats: Pick<StatsCompilation, 'errors' | 'warnings'>): {
10
10
  errors: string[];
11
11
  warnings: string[];
12
12
  };
@@ -25,12 +25,24 @@ const friendlySyntaxErrorLabel = "SyntaxError:";
25
25
  function isLikelyASyntaxError(message) {
26
26
  return message.includes(friendlySyntaxErrorLabel);
27
27
  }
28
+ function resolveFileName(stats) {
29
+ const regex = /(?:\!|^)([^!]+)$/;
30
+ const fileName = stats.moduleIdentifier?.match(regex)?.at(-1) ?? "";
31
+ return fileName ? (
32
+ // add default column add lines for linking
33
+ `File: ${fileName}:1:1
34
+ `
35
+ ) : (
36
+ // fallback to moduleName if moduleIdentifier parse failed
37
+ `File: ${stats.moduleName}
38
+ `
39
+ );
40
+ }
28
41
  function formatMessage(stats) {
29
42
  let lines = [];
30
43
  let message;
31
44
  if (typeof stats === "object") {
32
- const fileName = stats.moduleName ? `File: ${stats.moduleName}
33
- ` : "";
45
+ const fileName = resolveFileName(stats);
34
46
  const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
35
47
  const details = stats.details ? `
36
48
  Details: ${stats.details}
@@ -72,13 +84,12 @@ ${stats.stack}` : "";
72
84
  message = lines.join("\n");
73
85
  return message.trim();
74
86
  }
75
- function formatStatsMessages(json) {
76
- const formattedErrors = json?.errors?.map(formatMessage);
77
- const formattedWarnings = json?.warnings?.map(formatMessage);
87
+ function formatStatsMessages(stats) {
88
+ const formattedErrors = stats.errors?.map(formatMessage);
89
+ const formattedWarnings = stats.warnings?.map(formatMessage);
78
90
  const result = {
79
91
  errors: formattedErrors || [],
80
- warnings: formattedWarnings || [],
81
- errorTips: []
92
+ warnings: formattedWarnings || []
82
93
  };
83
94
  if (result.errors?.some(isLikelyASyntaxError)) {
84
95
  result.errors = result.errors.filter(isLikelyASyntaxError);
@@ -1,4 +1 @@
1
- export declare const registerOverlay: (options: {
2
- createOverlay: (err: string[]) => void;
3
- clearOverlay: () => void;
4
- }) => void;
1
+ export declare const registerOverlay: (createFn: (err: string[]) => void, clearFn: () => void) => void;
@@ -0,0 +1,6 @@
1
+ import type { ClientConfig } from '@rsbuild/shared';
2
+ /**
3
+ * hmr socket connect path
4
+ */
5
+ export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
6
+ export declare function getSocketUrl(urlParts: ClientConfig): string;
@@ -173,11 +173,20 @@ var friendlySyntaxErrorLabel = "SyntaxError:";
173
173
  function isLikelyASyntaxError(message) {
174
174
  return message.includes(friendlySyntaxErrorLabel);
175
175
  }
176
+ function resolveFileName(stats) {
177
+ var _stats_moduleIdentifier_match, _stats_moduleIdentifier;
178
+ var regex = /(?:\!|^)([^!]+)$/;
179
+ var _stats_moduleIdentifier_match_at;
180
+ var fileName = (_stats_moduleIdentifier_match_at = (_stats_moduleIdentifier = stats.moduleIdentifier) === null || _stats_moduleIdentifier === void 0 ? void 0 : (_stats_moduleIdentifier_match = _stats_moduleIdentifier.match(regex)) === null || _stats_moduleIdentifier_match === void 0 ? void 0 : _stats_moduleIdentifier_match.at(-1)) !== null && _stats_moduleIdentifier_match_at !== void 0 ? _stats_moduleIdentifier_match_at : "";
181
+ return fileName ? // add default column add lines for linking
182
+ "File: ".concat(fileName, ":1:1\n") : // fallback to moduleName if moduleIdentifier parse failed
183
+ "File: ".concat(stats.moduleName, "\n");
184
+ }
176
185
  function formatMessage(stats) {
177
186
  var lines = [];
178
187
  var message;
179
188
  if (typeof stats === "object") {
180
- var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
189
+ var fileName = resolveFileName(stats);
181
190
  var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
182
191
  var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
183
192
  var stack = stats.stack ? "\n".concat(stats.stack) : "";
@@ -210,14 +219,13 @@ function formatMessage(stats) {
210
219
  message = lines.join("\n");
211
220
  return message.trim();
212
221
  }
213
- function formatStatsMessages(json) {
214
- var _json_errors, _json_warnings, _result_errors;
215
- var formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
216
- var formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
222
+ function formatStatsMessages(stats) {
223
+ var _stats_errors, _stats_warnings, _result_errors;
224
+ var formattedErrors = (_stats_errors = stats.errors) === null || _stats_errors === void 0 ? void 0 : _stats_errors.map(formatMessage);
225
+ var formattedWarnings = (_stats_warnings = stats.warnings) === null || _stats_warnings === void 0 ? void 0 : _stats_warnings.map(formatMessage);
217
226
  var result = {
218
227
  errors: formattedErrors || [],
219
- warnings: formattedWarnings || [],
220
- errorTips: []
228
+ warnings: formattedWarnings || []
221
229
  };
222
230
  if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.some(isLikelyASyntaxError)) {
223
231
  result.errors = result.errors.filter(isLikelyASyntaxError);
@@ -227,13 +235,8 @@ function formatStatsMessages(json) {
227
235
  }
228
236
  return result;
229
237
  }
230
- // src/client/hmr/createSocketUrl.ts
238
+ // src/client/hmr/url.ts
231
239
  var HMR_SOCK_PATH = "/rsbuild-hmr";
232
- function createSocketUrl() {
233
- var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
234
- var currentLocation = self.location;
235
- return getSocketUrl(options2, currentLocation);
236
- }
237
240
  function formatURL(param) {
238
241
  var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
239
242
  if (typeof URL !== "undefined") {
@@ -247,7 +250,8 @@ function formatURL(param) {
247
250
  var colon = protocol.indexOf(":") === -1 ? ":" : "";
248
251
  return "".concat(protocol).concat(colon, "//").concat(hostname, ":").concat(port).concat(pathname);
249
252
  }
250
- function getSocketUrl(urlParts, location) {
253
+ function getSocketUrl(urlParts) {
254
+ var location = self.location;
251
255
  var host = urlParts.host, port = urlParts.port, path = urlParts.path, protocol = urlParts.protocol;
252
256
  return formatURL({
253
257
  protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
@@ -257,24 +261,19 @@ function getSocketUrl(urlParts, location) {
257
261
  });
258
262
  }
259
263
  // src/client/hmr/index.ts
260
- var options = RSBUILD_CLIENT_CONFIG;
261
- var socketUrl = createSocketUrl(options);
262
- var enableOverlay = !!options.overlay;
263
264
  var isFirstCompilation = true;
264
- var mostRecentCompilationHash = null;
265
+ var lastCompilationHash = null;
265
266
  var hasCompileErrors = false;
266
267
  function clearOutdatedErrors() {
267
- if (typeof console !== "undefined" && typeof console.clear === "function") {
268
- if (hasCompileErrors) {
269
- console.clear();
270
- }
268
+ if (console.clear && hasCompileErrors) {
269
+ console.clear();
271
270
  }
272
271
  }
273
272
  var createOverlay;
274
273
  var clearOverlay;
275
- var registerOverlay = function(options2) {
276
- createOverlay = options2.createOverlay;
277
- clearOverlay = options2.clearOverlay;
274
+ var registerOverlay = function(createFn, clearFn) {
275
+ createOverlay = createFn;
276
+ clearOverlay = clearFn;
278
277
  };
279
278
  function handleSuccess() {
280
279
  clearOutdatedErrors();
@@ -290,22 +289,17 @@ function handleWarnings(warnings) {
290
289
  var isHotUpdate = !isFirstCompilation;
291
290
  isFirstCompilation = false;
292
291
  hasCompileErrors = false;
293
- function printWarnings() {
294
- var formatted = formatStatsMessages({
295
- warnings: warnings,
296
- errors: []
297
- });
298
- if (typeof console !== "undefined" && typeof console.warn === "function") {
299
- for(var i = 0; i < formatted.warnings.length; i++){
300
- if (i === 5) {
301
- console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
302
- break;
303
- }
304
- console.warn(formatted.warnings[i]);
305
- }
292
+ var formatted = formatStatsMessages({
293
+ warnings: warnings,
294
+ errors: []
295
+ });
296
+ for(var i = 0; i < formatted.warnings.length; i++){
297
+ if (i === 5) {
298
+ console.warn("There were more warnings in other files, you can find a complete log in the terminal.");
299
+ break;
306
300
  }
301
+ console.warn(formatted.warnings[i]);
307
302
  }
308
- printWarnings();
309
303
  if (isHotUpdate) {
310
304
  tryApplyUpdates();
311
305
  }
@@ -318,59 +312,51 @@ function handleErrors(errors) {
318
312
  errors: errors,
319
313
  warnings: []
320
314
  });
321
- if (typeof console !== "undefined" && typeof console.error === "function") {
322
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
315
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
316
+ try {
317
+ for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
318
+ var error = _step.value;
319
+ console.error(error);
320
+ }
321
+ } catch (err) {
322
+ _didIteratorError = true;
323
+ _iteratorError = err;
324
+ } finally{
323
325
  try {
324
- for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
325
- var error = _step.value;
326
- console.error(error);
326
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
327
+ _iterator.return();
327
328
  }
328
- } catch (err) {
329
- _didIteratorError = true;
330
- _iteratorError = err;
331
329
  } finally{
332
- try {
333
- if (!_iteratorNormalCompletion && _iterator.return != null) {
334
- _iterator.return();
335
- }
336
- } finally{
337
- if (_didIteratorError) {
338
- throw _iteratorError;
339
- }
330
+ if (_didIteratorError) {
331
+ throw _iteratorError;
340
332
  }
341
333
  }
342
334
  }
343
- if (enableOverlay) {
344
- createOverlay === null || createOverlay === void 0 ? void 0 : createOverlay(formatted.errors);
335
+ if (createOverlay) {
336
+ createOverlay(formatted.errors);
345
337
  }
346
338
  }
347
- function handleAvailableHash(hash) {
348
- mostRecentCompilationHash = hash;
349
- }
350
339
  function isUpdateAvailable() {
351
- return mostRecentCompilationHash !== __webpack_hash__;
352
- }
353
- function canApplyUpdates() {
354
- return import.meta.webpackHot.status() === "idle";
340
+ return lastCompilationHash !== __webpack_hash__;
355
341
  }
356
342
  function tryApplyUpdates() {
357
343
  if (!isUpdateAvailable()) {
358
344
  return;
359
345
  }
360
346
  if (!import.meta.webpackHot) {
361
- window.location.reload();
347
+ reloadPage();
362
348
  return;
363
349
  }
364
- if (!canApplyUpdates()) {
350
+ if (import.meta.webpackHot.status() !== "idle") {
365
351
  return;
366
352
  }
367
353
  function handleApplyUpdates(err, updatedModules) {
368
- var wantsForcedReload = err || !updatedModules;
369
- if (wantsForcedReload) {
370
- if (err && typeof console !== "undefined" && typeof console.error === "function") {
354
+ var forcedReload = err || !updatedModules;
355
+ if (forcedReload) {
356
+ if (err) {
371
357
  console.error("[HMR] Forced reload caused by: ", err);
372
358
  }
373
- window.location.reload();
359
+ reloadPage();
374
360
  return;
375
361
  }
376
362
  if (isUpdateAvailable()) {
@@ -385,30 +371,26 @@ function tryApplyUpdates() {
385
371
  }
386
372
  var MAX_RETRIES = 100;
387
373
  var connection = null;
388
- var retry_counter = 0;
374
+ var retryCount = 0;
389
375
  function onOpen() {
390
- if (typeof console !== "undefined" && typeof console.info === "function") {
391
- console.info("[HMR] connected.");
392
- }
376
+ console.info("[HMR] connected.");
393
377
  }
394
378
  function onMessage(e) {
395
379
  var message = JSON.parse(e.data);
396
380
  switch(message.type){
397
381
  case "hash":
398
- if (enableOverlay) {
399
- clearOverlay === null || clearOverlay === void 0 ? void 0 : clearOverlay();
382
+ lastCompilationHash = message.data;
383
+ if (clearOverlay && isUpdateAvailable()) {
384
+ clearOverlay();
400
385
  }
401
- handleAvailableHash(message.data);
402
386
  break;
403
387
  case "still-ok":
404
388
  case "ok":
405
389
  handleSuccess();
406
390
  break;
407
391
  case "static-changed":
408
- window.location.reload();
409
- break;
410
392
  case "content-changed":
411
- window.location.reload();
393
+ reloadPage();
412
394
  break;
413
395
  case "warnings":
414
396
  handleWarnings(message.data);
@@ -416,27 +398,13 @@ function onMessage(e) {
416
398
  case "errors":
417
399
  handleErrors(message.data);
418
400
  break;
419
- default:
420
401
  }
421
402
  }
422
403
  function sleep() {
423
- return _sleep.apply(this, arguments);
424
- }
425
- function _sleep() {
426
- _sleep = _async_to_generator(function() {
427
- var msec;
428
- var _arguments = arguments;
429
- return _ts_generator(this, function(_state) {
430
- msec = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : 1e3;
431
- return [
432
- 2,
433
- new Promise(function(resolve) {
434
- setTimeout(resolve, msec);
435
- })
436
- ];
437
- });
404
+ var msec = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1e3;
405
+ return new Promise(function(resolve) {
406
+ setTimeout(resolve, msec);
438
407
  });
439
- return _sleep.apply(this, arguments);
440
408
  }
441
409
  function onClose() {
442
410
  return _onClose.apply(this, arguments);
@@ -446,9 +414,7 @@ function _onClose() {
446
414
  return _ts_generator(this, function(_state) {
447
415
  switch(_state.label){
448
416
  case 0:
449
- if (typeof console !== "undefined" && typeof console.info === "function") {
450
- console.info("[HMR] disconnected. Attempting to reconnect.");
451
- }
417
+ console.info("[HMR] disconnected. Attempting to reconnect.");
452
418
  removeListeners();
453
419
  return [
454
420
  4,
@@ -456,18 +422,16 @@ function _onClose() {
456
422
  ];
457
423
  case 1:
458
424
  _state.sent();
459
- retry_counter++;
425
+ retryCount++;
460
426
  if (connection && (connection.readyState === connection.CONNECTING || connection.readyState === connection.OPEN)) {
461
- retry_counter = 0;
427
+ retryCount = 0;
462
428
  return [
463
429
  2
464
430
  ];
465
431
  }
466
- if (retry_counter > MAX_RETRIES) {
467
- if (typeof console !== "undefined" && typeof console.info === "function") {
468
- console.info("[HMR] Unable to establish a connection after exceeding the maximum retry attempts.");
469
- }
470
- retry_counter = 0;
432
+ if (retryCount > MAX_RETRIES) {
433
+ console.info("[HMR] Unable to establish a connection after exceeding the maximum retry attempts.");
434
+ retryCount = 0;
471
435
  return [
472
436
  2
473
437
  ];
@@ -482,6 +446,7 @@ function _onClose() {
482
446
  return _onClose.apply(this, arguments);
483
447
  }
484
448
  function connect() {
449
+ var socketUrl = getSocketUrl(RSBUILD_CLIENT_CONFIG);
485
450
  connection = new WebSocket(socketUrl);
486
451
  connection.addEventListener("open", onOpen);
487
452
  connection.addEventListener("close", onClose);
@@ -500,5 +465,10 @@ function reconnect() {
500
465
  }
501
466
  connect();
502
467
  }
468
+ function reloadPage() {
469
+ if (RSBUILD_DEV_LIVE_RELOAD) {
470
+ window.location.reload();
471
+ }
472
+ }
503
473
  connect();
504
474
  export { registerOverlay };
@@ -227,24 +227,17 @@ var overlayId = "rsbuild-error-overlay";
227
227
  if (customElements && !customElements.get(overlayId)) {
228
228
  customElements.define(overlayId, ErrorOverlay);
229
229
  }
230
- var documentAvailable = typeof document !== "undefined";
231
230
  function createOverlay(err) {
232
- if (!documentAvailable) {
233
- console.info("[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.");
234
- return;
235
- }
236
231
  clearOverlay();
237
232
  document.body.appendChild(new ErrorOverlay(err));
238
233
  }
239
234
  function clearOverlay() {
240
- if (!documentAvailable) {
241
- return;
242
- }
243
235
  document.querySelectorAll(overlayId).forEach(function(n) {
244
236
  return n.close();
245
237
  });
246
238
  }
247
- registerOverlay({
248
- createOverlay: createOverlay,
249
- clearOverlay: clearOverlay
250
- });
239
+ if (typeof document !== "undefined") {
240
+ registerOverlay(createOverlay, clearOverlay);
241
+ } else {
242
+ console.info("[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.");
243
+ }
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
44
44
  const context = {
45
45
  entry: (0, import_entry.getEntryObject)(config, "web"),
46
46
  targets: config.output?.targets || [],
47
- version: "0.6.6",
47
+ version: "0.6.8",
48
48
  rootPath,
49
49
  distPath,
50
50
  cachePath,
package/dist/index.d.ts CHANGED
@@ -2,13 +2,16 @@
2
2
  * The methods and types exported from this file are considered as
3
3
  * the public API of @rsbuild/core.
4
4
  */
5
+ import { rspack } from '@rspack/core';
6
+ import type * as Rspack from '@rspack/core';
5
7
  export { loadEnv } from './loadEnv';
6
8
  export { createRsbuild } from './createRsbuild';
7
9
  export { loadConfig, defineConfig } from './config';
8
10
  export declare const version: any;
11
+ export { rspack };
12
+ export type { Rspack };
9
13
  export { logger } from '@rsbuild/shared';
10
14
  export { mergeRsbuildConfig } from './mergeConfig';
11
15
  export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, PLUGIN_SASS_NAME, PLUGIN_LESS_NAME, PLUGIN_STYLUS_NAME, } from './constants';
12
- export type { Rspack } from '@rsbuild/shared';
13
16
  export type { RsbuildConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, RsbuildPlugin, RsbuildPlugins, RsbuildPluginAPI, } from './types';
14
17
  export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyRsbuildConfigFn, TransformFn, TransformHandler, } from '@rsbuild/shared';
package/dist/index.js CHANGED
@@ -29,16 +29,18 @@ __export(src_exports, {
29
29
  loadEnv: () => import_loadEnv.loadEnv,
30
30
  logger: () => import_shared.logger,
31
31
  mergeRsbuildConfig: () => import_mergeConfig.mergeRsbuildConfig,
32
+ rspack: () => import_core.rspack,
32
33
  version: () => version
33
34
  });
34
35
  module.exports = __toCommonJS(src_exports);
36
+ var import_core = require("@rspack/core");
35
37
  var import_loadEnv = require("./loadEnv");
36
38
  var import_createRsbuild = require("./createRsbuild");
37
39
  var import_config = require("./config");
38
40
  var import_shared = require("@rsbuild/shared");
39
41
  var import_mergeConfig = require("./mergeConfig");
40
42
  var import_constants = require("./constants");
41
- const version = "0.6.6";
43
+ const version = "0.6.8";
42
44
  // Annotate the CommonJS export names for ESM import in node:
43
45
  0 && (module.exports = {
44
46
  PLUGIN_CSS_NAME,
@@ -52,5 +54,6 @@ const version = "0.6.6";
52
54
  loadEnv,
53
55
  logger,
54
56
  mergeRsbuildConfig,
57
+ rspack,
55
58
  version
56
59
  });
@@ -96,7 +96,10 @@ function getPluginAPI({
96
96
  const transform = (descriptor, handler) => {
97
97
  const id = `rsbuild-transform-${transformId++}`;
98
98
  transformer[id] = handler;
99
- hooks.modifyBundlerChain.tap((chain) => {
99
+ hooks.modifyBundlerChain.tap((chain, { target }) => {
100
+ if (descriptor.targets && !descriptor.targets.includes(target)) {
101
+ return;
102
+ }
100
103
  const rule = chain.module.rule(id);
101
104
  if (descriptor.test) {
102
105
  rule.test(descriptor.test);
@@ -104,7 +107,9 @@ function getPluginAPI({
104
107
  if (descriptor.resourceQuery) {
105
108
  rule.resourceQuery(descriptor.resourceQuery);
106
109
  }
107
- rule.use(id).loader((0, import_node_path.join)(__dirname, "./rspack/transformLoader")).options({ id });
110
+ const loaderName = descriptor.raw ? "transformRawLoader" : "transformLoader";
111
+ const loaderPath = (0, import_node_path.join)(__dirname, `./rspack/${loaderName}`);
112
+ rule.use(id).loader(loaderPath).options({ id });
108
113
  applyTransformPlugin(chain, transformer);
109
114
  });
110
115
  };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
7
  var __export = (target, all) => {
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var __publicField = (obj, key, value) => {
31
21
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -37,6 +27,7 @@ __export(moduleFederation_exports, {
37
27
  });
38
28
  module.exports = __toCommonJS(moduleFederation_exports);
39
29
  var import_shared = require("@rsbuild/shared");
30
+ var import_core = require("@rspack/core");
40
31
  class PatchSplitChunksPlugin {
41
32
  constructor(name) {
42
33
  __publicField(this, "name");
@@ -116,8 +107,7 @@ function pluginModuleFederation() {
116
107
  return;
117
108
  }
118
109
  const { options } = config.moduleFederation;
119
- const { rspack } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
120
- chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack.container.ModuleFederationPlugin, [options]);
110
+ chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(import_core.rspack.container.ModuleFederationPlugin, [options]);
121
111
  if (options.name) {
122
112
  chain.plugin("mf-patch-split-chunks").use(PatchSplitChunksPlugin, [options.name]);
123
113
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,22 +17,55 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var nodeAddons_exports = {};
20
30
  __export(nodeAddons_exports, {
21
31
  pluginNodeAddons: () => pluginNodeAddons
22
32
  });
23
33
  module.exports = __toCommonJS(nodeAddons_exports);
24
- var import_node_path = require("node:path");
34
+ var import_node_path = __toESM(require("node:path"));
35
+ const getFilename = (resourcePath) => {
36
+ let basename = "";
37
+ if (resourcePath) {
38
+ const parsed = import_node_path.default.parse(resourcePath);
39
+ if (parsed.dir) {
40
+ basename = parsed.name;
41
+ }
42
+ }
43
+ if (basename) {
44
+ return `${basename}.node`;
45
+ }
46
+ return null;
47
+ };
25
48
  const pluginNodeAddons = () => ({
26
49
  name: "rsbuild:node-addons",
27
50
  setup(api) {
28
- api.modifyBundlerChain(async (chain, { isServer, CHAIN_ID }) => {
29
- if (!isServer) {
30
- return;
51
+ api.transform(
52
+ { test: /\.node$/, targets: ["node"], raw: true },
53
+ ({ code, emitFile, resourcePath }) => {
54
+ const name = getFilename(resourcePath);
55
+ if (name === null) {
56
+ throw new Error(`Failed to load Node.js addon: "${resourcePath}"`);
57
+ }
58
+ emitFile(name, code);
59
+ return `
60
+ try {
61
+ const path = require("path");
62
+ process.dlopen(module, path.join(__dirname, "${name}"));
63
+ } catch (error) {
64
+ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
65
+ }
66
+ `;
31
67
  }
32
- chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_node_path.join)(__dirname, "../rspack/nodeAddonsLoader"));
33
- });
68
+ );
34
69
  }
35
70
  });
36
71
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var build_exports = {};
30
20
  __export(build_exports, {
@@ -32,6 +22,7 @@ __export(build_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(build_exports);
34
24
  var import_shared = require("@rsbuild/shared");
25
+ var import_core = require("@rspack/core");
35
26
  var import_createCompiler = require("./createCompiler");
36
27
  var import_initConfigs = require("./initConfigs");
37
28
  const build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
@@ -60,12 +51,11 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
60
51
  isFirstCompile = false;
61
52
  await p;
62
53
  };
63
- const { MultiStats: MultiStatsStor } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
64
54
  (0, import_shared.onCompileDone)(
65
55
  compiler,
66
56
  onDone,
67
57
  // @ts-expect-error type mismatch
68
- MultiStatsStor
58
+ import_core.rspack.MultiStats
69
59
  );
70
60
  if (watch) {
71
61
  compiler.watch({}, (err) => {
@@ -33,6 +33,7 @@ __export(createCompiler_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(createCompiler_exports);
35
35
  var import_shared = require("@rsbuild/shared");
36
+ var import_core = require("@rspack/core");
36
37
  var import_initConfigs = require("./initConfigs");
37
38
  var import_shared2 = require("./shared");
38
39
  async function createCompiler({
@@ -43,21 +44,20 @@ async function createCompiler({
43
44
  await context.hooks.onBeforeCreateCompiler.call({
44
45
  bundlerConfigs: rspackConfigs
45
46
  });
46
- const { rspack } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
47
- if (!await (0, import_shared2.isSatisfyRspackVersion)(rspack.rspackVersion)) {
47
+ if (!await (0, import_shared2.isSatisfyRspackVersion)(import_core.rspack.rspackVersion)) {
48
48
  throw new Error(
49
49
  `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_shared.color.green(
50
50
  import_shared2.rspackMinVersion
51
51
  )}`
52
52
  );
53
53
  }
54
- const compiler = rspackConfigs.length === 1 ? rspack(rspackConfigs[0]) : rspack(rspackConfigs);
54
+ const compiler = rspackConfigs.length === 1 ? (0, import_core.rspack)(rspackConfigs[0]) : (0, import_core.rspack)(rspackConfigs);
55
55
  let isFirstCompile = true;
56
56
  let isVersionLogged = false;
57
57
  let isCompiling = false;
58
58
  const logRspackVersion = () => {
59
59
  if (!isVersionLogged) {
60
- (0, import_shared.debug)(`Use Rspack v${rspack.rspackVersion}`);
60
+ (0, import_shared.debug)(`Use Rspack v${import_core.rspack.rspackVersion}`);
61
61
  isVersionLogged = true;
62
62
  }
63
63
  };
@@ -109,12 +109,11 @@ async function createCompiler({
109
109
  isCompiling = false;
110
110
  isFirstCompile = false;
111
111
  };
112
- const { MultiStats: MultiStatsStor } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
113
112
  (0, import_shared.onCompileDone)(
114
113
  compiler,
115
114
  done,
116
115
  // @ts-expect-error type mismatch
117
- MultiStatsStor
116
+ import_core.rspack.MultiStats
118
117
  );
119
118
  await context.hooks.onAfterCreateCompiler.call({ compiler });
120
119
  (0, import_shared.debug)("create compiler done");
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var minimize_exports = {};
30
20
  __export(minimize_exports, {
@@ -32,6 +22,7 @@ __export(minimize_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(minimize_exports);
34
24
  var import_shared = require("@rsbuild/shared");
25
+ var import_core = require("@rspack/core");
35
26
  const pluginMinimize = () => ({
36
27
  name: "rsbuild:minimize",
37
28
  setup(api) {
@@ -41,7 +32,7 @@ const pluginMinimize = () => ({
41
32
  if (!isMinimize) {
42
33
  return;
43
34
  }
44
- const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
35
+ const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = import_core.rspack;
45
36
  const { minifyJs, minifyCss } = (0, import_shared.parseMinifyOptions)(config);
46
37
  if (minifyJs) {
47
38
  chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [(0, import_shared.getSwcMinimizerOptions)(config)]).end();
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var output_exports = {};
30
20
  __export(output_exports, {
@@ -33,6 +23,7 @@ __export(output_exports, {
33
23
  module.exports = __toCommonJS(output_exports);
34
24
  var import_node_path = require("node:path");
35
25
  var import_shared = require("@rsbuild/shared");
26
+ var import_core = require("@rspack/core");
36
27
  const pluginOutput = () => ({
37
28
  name: "rsbuild:output",
38
29
  setup(api) {
@@ -40,10 +31,9 @@ const pluginOutput = () => ({
40
31
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
41
32
  const config = api.getNormalizedConfig();
42
33
  if (config.output.copy) {
43
- const { CopyRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
44
34
  const { copy } = config.output;
45
35
  const options = Array.isArray(copy) ? { patterns: copy } : copy;
46
- chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyRspackPlugin, [options]);
36
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).use(import_core.rspack.CopyRspackPlugin, [options]);
47
37
  }
48
38
  });
49
39
  api.modifyRspackConfig(async (rspackConfig, { isProd }) => {
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var progress_exports = {};
30
20
  __export(progress_exports, {
@@ -32,6 +22,7 @@ __export(progress_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(progress_exports);
34
24
  var import_shared = require("@rsbuild/shared");
25
+ var import_core = require("@rspack/core");
35
26
  const pluginProgress = () => ({
36
27
  name: "rsbuild:progress",
37
28
  setup(api) {
@@ -43,8 +34,7 @@ const pluginProgress = () => ({
43
34
  return;
44
35
  }
45
36
  const prefix = options !== true && options.id !== void 0 ? options.id : import_shared.TARGET_ID_MAP[target];
46
- const { ProgressPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
47
- chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
37
+ chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(import_core.rspack.ProgressPlugin, [
48
38
  {
49
39
  prefix,
50
40
  ...options === true ? {} : options
@@ -36,6 +36,7 @@ var import_node_inspector = __toESM(require("node:inspector"));
36
36
  var import_node_path = __toESM(require("node:path"));
37
37
  var import_shared = require("@rsbuild/shared");
38
38
  var import_shared2 = require("@rsbuild/shared");
39
+ var import_core = require("@rspack/core");
39
40
  const stopProfiler = (output, profileSession) => {
40
41
  if (!profileSession) {
41
42
  return;
@@ -55,10 +56,6 @@ const pluginRspackProfile = () => ({
55
56
  if (!RSPACK_PROFILE) {
56
57
  return;
57
58
  }
58
- const {
59
- experimental_registerGlobalTrace: registerGlobalTrace,
60
- experimental_cleanupGlobalTrace: cleanupGlobalTrace
61
- } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
62
59
  const timestamp = Date.now();
63
60
  const profileDir = import_node_path.default.join(
64
61
  api.context.distPath,
@@ -74,7 +71,11 @@ const pluginRspackProfile = () => ({
74
71
  const onStart = () => {
75
72
  import_shared.fse.ensureDirSync(profileDir);
76
73
  if (enableProfileTrace) {
77
- registerGlobalTrace("trace", "chrome", traceFilePath);
74
+ import_core.rspack.experimental_registerGlobalTrace(
75
+ "trace",
76
+ "chrome",
77
+ traceFilePath
78
+ );
78
79
  }
79
80
  if (enableCPUProfile) {
80
81
  profileSession = new import_node_inspector.default.Session();
@@ -96,7 +97,9 @@ const pluginRspackProfile = () => ({
96
97
  }
97
98
  });
98
99
  api.onExit(() => {
99
- enableProfileTrace && cleanupGlobalTrace();
100
+ if (enableProfileTrace) {
101
+ import_core.rspack.experimental_cleanupGlobalTrace();
102
+ }
100
103
  stopProfiler(cpuProfilePath, profileSession);
101
104
  import_shared2.logger.info(`Saved Rspack profile file to ${profileDir}`);
102
105
  });
@@ -33,6 +33,7 @@ __export(rspackConfig_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(rspackConfig_exports);
35
35
  var import_shared = require("@rsbuild/shared");
36
+ var import_core = require("@rspack/core");
36
37
  var import_htmlUtils = require("../htmlUtils");
37
38
  var import_shared2 = require("./shared");
38
39
  async function modifyRspackConfig(context, rspackConfig, utils) {
@@ -54,10 +55,9 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
54
55
  }
55
56
  async function getConfigUtils(config, chainUtils) {
56
57
  const { merge } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-merge")));
57
- const rspack = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
58
58
  return {
59
59
  ...chainUtils,
60
- rspack,
60
+ rspack: import_core.rspack,
61
61
  mergeConfig: merge,
62
62
  addRules(rules) {
63
63
  const ruleArr = (0, import_shared.castArray)(rules);
@@ -118,7 +118,7 @@ async function generateRspackConfig({
118
118
  IgnorePlugin,
119
119
  ProvidePlugin,
120
120
  HotModuleReplacementPlugin
121
- } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
121
+ } = import_core.rspack;
122
122
  const chain = await (0, import_shared.modifyBundlerChain)(context, {
123
123
  ...chainUtils,
124
124
  bundler: {
@@ -0,0 +1,3 @@
1
+ import transform from './transformLoader';
2
+ export default transform;
3
+ export declare const raw = true;
@@ -26,41 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var nodeAddonsLoader_exports = {};
30
- __export(nodeAddonsLoader_exports, {
31
- default: () => nodeAddonsLoader_default,
29
+ var transformRawLoader_exports = {};
30
+ __export(transformRawLoader_exports, {
31
+ default: () => transformRawLoader_default,
32
32
  raw: () => raw
33
33
  });
34
- module.exports = __toCommonJS(nodeAddonsLoader_exports);
35
- var import_node_path = __toESM(require("node:path"));
36
- const getFilename = (resourcePath) => {
37
- let basename = "";
38
- if (resourcePath) {
39
- const parsed = import_node_path.default.parse(resourcePath);
40
- if (parsed.dir) {
41
- basename = parsed.name;
42
- }
43
- }
44
- if (basename) {
45
- return `${basename}.node`;
46
- }
47
- return null;
48
- };
49
- function nodeAddonsLoader_default(source) {
50
- const name = getFilename(this.resourcePath);
51
- if (name === null) {
52
- throw new Error(`Failed to load Node.js addon: "${this.resourcePath}"`);
53
- }
54
- this.emitFile(name, source);
55
- return `
56
- try {
57
- const path = require("path");
58
- process.dlopen(module, path.join(__dirname, "${name}"));
59
- } catch (error) {
60
- throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
61
- }
62
- `;
63
- }
34
+ module.exports = __toCommonJS(transformRawLoader_exports);
35
+ var import_transformLoader = __toESM(require("./transformLoader"));
36
+ var transformRawLoader_default = import_transformLoader.default;
64
37
  const raw = true;
65
38
  // Annotate the CommonJS export names for ESM import in node:
66
39
  0 && (module.exports = {
@@ -99,6 +99,7 @@ class CompilerDevMiddleware {
99
99
  callbacks,
100
100
  clientPaths,
101
101
  clientConfig: devConfig.client,
102
+ liveReload: devConfig.liveReload,
102
103
  writeToDisk: devConfig.writeToDisk,
103
104
  serverSideRender: true,
104
105
  // weak is enough in dev
@@ -36,13 +36,15 @@ var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev
36
36
  function applyHMREntry({
37
37
  compiler,
38
38
  clientPaths,
39
- clientConfig = {}
39
+ clientConfig = {},
40
+ liveReload = true
40
41
  }) {
41
42
  if (!(0, import_shared.isClientCompiler)(compiler)) {
42
43
  return;
43
44
  }
44
45
  new compiler.webpack.DefinePlugin({
45
- RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig)
46
+ RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
47
+ RSBUILD_DEV_LIVE_RELOAD: liveReload
46
48
  }).apply(compiler);
47
49
  for (const clientPath of clientPaths) {
48
50
  new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
@@ -51,13 +53,14 @@ function applyHMREntry({
51
53
  }
52
54
  }
53
55
  const getDevMiddleware = (multiCompiler) => (options) => {
54
- const { clientPaths, clientConfig, callbacks, ...restOptions } = options;
56
+ const { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
55
57
  const setupCompiler = (compiler) => {
56
58
  if (clientPaths) {
57
59
  applyHMREntry({
58
60
  compiler,
59
61
  clientPaths,
60
- clientConfig
62
+ clientConfig,
63
+ liveReload
61
64
  });
62
65
  }
63
66
  (0, import_shared.setupServerHooks)(compiler, callbacks);
@@ -50,4 +50,5 @@ export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
50
50
  port: number;
51
51
  host: string;
52
52
  https: boolean;
53
+ liveReload: boolean | undefined;
53
54
  }>;
@@ -136,7 +136,8 @@ const mergeDevOptions = ({
136
136
  // By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
137
137
  protocol: void 0
138
138
  },
139
- writeToDisk: false
139
+ writeToDisk: false,
140
+ liveReload: true
140
141
  };
141
142
  const devConfig = rsbuildConfig.dev ? (0, import_shared.deepmerge)(defaultDevConfig, rsbuildConfig.dev) : defaultDevConfig;
142
143
  return devConfig;
@@ -214,12 +215,14 @@ const getDevOptions = async ({
214
215
  getPortSilently
215
216
  });
216
217
  const devConfig = mergeDevOptions({ rsbuildConfig, port });
218
+ const liveReload = devConfig.liveReload;
217
219
  return {
218
220
  devConfig,
219
221
  serverConfig,
220
222
  port,
221
223
  host,
222
- https
224
+ https,
225
+ liveReload
223
226
  };
224
227
  };
225
228
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -51,14 +51,27 @@
51
51
  "@rspack/core": "0.6.3",
52
52
  "@swc/helpers": "0.5.3",
53
53
  "core-js": "~3.36.0",
54
- "html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
54
+ "html-webpack-plugin": "npm:html-rspack-plugin@5.7.0",
55
55
  "postcss": "^8.4.38",
56
- "@rsbuild/shared": "0.6.6"
56
+ "@rsbuild/shared": "0.6.8"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "18.x",
60
+ "@types/on-finished": "2.3.4",
61
+ "@types/ws": "^8.5.10",
62
+ "commander": "^12.0.0",
63
+ "connect-history-api-fallback": "^2.0.0",
64
+ "dotenv": "16.4.5",
65
+ "dotenv-expand": "11.0.6",
66
+ "http-compression": "1.0.19",
67
+ "launch-editor-middleware": "^2.6.1",
68
+ "on-finished": "2.4.1",
69
+ "open": "^8.4.0",
70
+ "prebundle": "1.0.3",
71
+ "sirv": "^2.0.4",
60
72
  "typescript": "^5.4.2",
61
- "webpack": "^5.91.0"
73
+ "webpack": "^5.91.0",
74
+ "ws": "^8.16.0"
62
75
  },
63
76
  "engines": {
64
77
  "node": ">=16.0.0"
@@ -70,6 +83,7 @@
70
83
  },
71
84
  "scripts": {
72
85
  "build": "modern build",
73
- "dev": "modern build --watch"
86
+ "dev": "modern build --watch",
87
+ "prebundle": "prebundle"
74
88
  }
75
89
  }
@@ -1,12 +0,0 @@
1
- import type { ClientConfig } from '@rsbuild/shared';
2
- /**
3
- * hmr socket connect path
4
- */
5
- export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
6
- export declare function createSocketUrl(options?: ClientConfig): string;
7
- export declare function formatURL({ port, protocol, hostname, pathname, }: {
8
- port: string;
9
- protocol: string;
10
- hostname: string;
11
- pathname: string;
12
- }): string;
@@ -1,3 +0,0 @@
1
- import type { Rspack } from '@rsbuild/shared';
2
- export default function (this: Rspack.LoaderContext, source: string): string;
3
- export declare const raw = true;