=194&&s<224){if(a-t>=6){var i=parseInt(e.substr(t+4,2),16);r+=String.fromCharCode((s&31)<<6|i&63)}else{r+=e.substr(t,6)}t+=6}else if(s>=224){if(a-t>=9){var o=parseInt(e.substr(t+4,2),16);var n=parseInt(e.substr(t+7,2),16);r+=String.fromCharCode((s&15)<<12|(o&63)<<6|n&63)}else{r+=e.substr(t,9)}t+=9}else{r+=e.substr(t,3);t+=3}}return r}function _normalizeComponentEncoding(e,r){function decodeUnreserved(e){var t=pctDecChars(e);return!t.match(r.UNRESERVED)?e:t}if(e.scheme)e.scheme=String(e.scheme).replace(r.PCT_ENCODED,decodeUnreserved).toLowerCase().replace(r.NOT_SCHEME,"");if(e.userinfo!==undefined)e.userinfo=String(e.userinfo).replace(r.PCT_ENCODED,decodeUnreserved).replace(r.NOT_USERINFO,pctEncChar).replace(r.PCT_ENCODED,toUpperCase);if(e.host!==undefined)e.host=String(e.host).replace(r.PCT_ENCODED,decodeUnreserved).toLowerCase().replace(r.NOT_HOST,pctEncChar).replace(r.PCT_ENCODED,toUpperCase);if(e.path!==undefined)e.path=String(e.path).replace(r.PCT_ENCODED,decodeUnreserved).replace(e.scheme?r.NOT_PATH:r.NOT_PATH_NOSCHEME,pctEncChar).replace(r.PCT_ENCODED,toUpperCase);if(e.query!==undefined)e.query=String(e.query).replace(r.PCT_ENCODED,decodeUnreserved).replace(r.NOT_QUERY,pctEncChar).replace(r.PCT_ENCODED,toUpperCase);if(e.fragment!==undefined)e.fragment=String(e.fragment).replace(r.PCT_ENCODED,decodeUnreserved).replace(r.NOT_FRAGMENT,pctEncChar).replace(r.PCT_ENCODED,toUpperCase);return e}function _stripLeadingZeros(e){return e.replace(/^0*(.*)/,"$1")||"0"}function _normalizeIPv4(e,r){var t=e.match(r.IPV4ADDRESS)||[];var s=a(t,2),i=s[1];if(i){return i.split(".").map(_stripLeadingZeros).join(".")}else{return e}}function _normalizeIPv6(e,r){var t=e.match(r.IPV6ADDRESS)||[];var s=a(t,3),i=s[1],o=s[2];if(i){var n=i.toLowerCase().split("::").reverse(),l=a(n,2),u=l[0],f=l[1];var c=f?f.split(":").map(_stripLeadingZeros):[];var h=u.split(":").map(_stripLeadingZeros);var d=r.IPV4ADDRESS.test(h[h.length-1]);var p=d?7:8;var m=h.length-p;var g=Array(p);for(var y=0;y1){var S=g.slice(0,b.index);var w=g.slice(b.index+b.length);E=S.join(":")+"::"+w.join(":")}else{E=g.join(":")}if(o){E+="%"+o}return E}else{return e}}var j=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;var I="".match(/(){0}/)[1]===undefined;function parse(e){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var s={};var i=a.iri!==false?t:r;if(a.reference==="suffix")e=(a.scheme?a.scheme+":":"")+"//"+e;var o=e.match(j);if(o){if(I){s.scheme=o[1];s.userinfo=o[3];s.host=o[4];s.port=parseInt(o[5],10);s.path=o[6]||"";s.query=o[7];s.fragment=o[8];if(isNaN(s.port)){s.port=o[5]}}else{s.scheme=o[1]||undefined;s.userinfo=e.indexOf("@")!==-1?o[3]:undefined;s.host=e.indexOf("//")!==-1?o[4]:undefined;s.port=parseInt(o[5],10);s.path=o[6]||"";s.query=e.indexOf("?")!==-1?o[7]:undefined;s.fragment=e.indexOf("#")!==-1?o[8]:undefined;if(isNaN(s.port)){s.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?o[4]:undefined}}if(s.host){s.host=_normalizeIPv6(_normalizeIPv4(s.host,i),i)}if(s.scheme===undefined&&s.userinfo===undefined&&s.host===undefined&&s.port===undefined&&!s.path&&s.query===undefined){s.reference="same-document"}else if(s.scheme===undefined){s.reference="relative"}else if(s.fragment===undefined){s.reference="absolute"}else{s.reference="uri"}if(a.reference&&a.reference!=="suffix"&&a.reference!==s.reference){s.error=s.error||"URI is not a "+a.reference+" reference."}var n=D[(a.scheme||s.scheme||"").toLowerCase()];if(!a.unicodeSupport&&(!n||!n.unicodeSupport)){if(s.host&&(a.domainHost||n&&n.domainHost)){try{s.host=O.toASCII(s.host.replace(i.PCT_ENCODED,pctDecChars).toLowerCase())}catch(e){s.error=s.error||"Host's domain name can not be converted to ASCII via punycode: "+e}}_normalizeComponentEncoding(s,r)}else{_normalizeComponentEncoding(s,i)}if(n&&n.parse){n.parse(s,a)}}else{s.error=s.error||"URI can not be parsed."}return s}function _recomposeAuthority(e,a){var s=a.iri!==false?t:r;var i=[];if(e.userinfo!==undefined){i.push(e.userinfo);i.push("@")}if(e.host!==undefined){i.push(_normalizeIPv6(_normalizeIPv4(String(e.host),s),s).replace(s.IPV6ADDRESS,(function(e,r,t){return"["+r+(t?"%25"+t:"")+"]"})))}if(typeof e.port==="number"||typeof e.port==="string"){i.push(":");i.push(String(e.port))}return i.length?i.join(""):undefined}var k=/^\.\.?\//;var C=/^\/\.(\/|$)/;var A=/^\/\.\.(\/|$)/;var N=/^\/?(?:.|\n)*?(?=\/|$)/;function removeDotSegments(e){var r=[];while(e.length){if(e.match(k)){e=e.replace(k,"")}else if(e.match(C)){e=e.replace(C,"/")}else if(e.match(A)){e=e.replace(A,"/");r.pop()}else if(e==="."||e===".."){e=""}else{var t=e.match(N);if(t){var a=t[0];e=e.slice(a.length);r.push(a)}else{throw new Error("Unexpected dot segment condition")}}}return r.join("")}function serialize(e){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var s=a.iri?t:r;var i=[];var o=D[(a.scheme||e.scheme||"").toLowerCase()];if(o&&o.serialize)o.serialize(e,a);if(e.host){if(s.IPV6ADDRESS.test(e.host)){}else if(a.domainHost||o&&o.domainHost){try{e.host=!a.iri?O.toASCII(e.host.replace(s.PCT_ENCODED,pctDecChars).toLowerCase()):O.toUnicode(e.host)}catch(r){e.error=e.error||"Host's domain name can not be converted to "+(!a.iri?"ASCII":"Unicode")+" via punycode: "+r}}}_normalizeComponentEncoding(e,s);if(a.reference!=="suffix"&&e.scheme){i.push(e.scheme);i.push(":")}var n=_recomposeAuthority(e,a);if(n!==undefined){if(a.reference!=="suffix"){i.push("//")}i.push(n);if(e.path&&e.path.charAt(0)!=="/"){i.push("/")}}if(e.path!==undefined){var l=e.path;if(!a.absolutePath&&(!o||!o.absolutePath)){l=removeDotSegments(l)}if(n===undefined){l=l.replace(/^\/\//,"/%2F")}i.push(l)}if(e.query!==undefined){i.push("?");i.push(e.query)}if(e.fragment!==undefined){i.push("#");i.push(e.fragment)}return i.join("")}function resolveComponents(e,r){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var a=arguments[3];var s={};if(!a){e=parse(serialize(e,t),t);r=parse(serialize(r,t),t)}t=t||{};if(!t.tolerant&&r.scheme){s.scheme=r.scheme;s.userinfo=r.userinfo;s.host=r.host;s.port=r.port;s.path=removeDotSegments(r.path||"");s.query=r.query}else{if(r.userinfo!==undefined||r.host!==undefined||r.port!==undefined){s.userinfo=r.userinfo;s.host=r.host;s.port=r.port;s.path=removeDotSegments(r.path||"");s.query=r.query}else{if(!r.path){s.path=e.path;if(r.query!==undefined){s.query=r.query}else{s.query=e.query}}else{if(r.path.charAt(0)==="/"){s.path=removeDotSegments(r.path)}else{if((e.userinfo!==undefined||e.host!==undefined||e.port!==undefined)&&!e.path){s.path="/"+r.path}else if(!e.path){s.path=r.path}else{s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path}s.path=removeDotSegments(s.path)}s.query=r.query}s.userinfo=e.userinfo;s.host=e.host;s.port=e.port}s.scheme=e.scheme}s.fragment=r.fragment;return s}function resolve(e,r,t){var a=assign({scheme:"null"},t);return serialize(resolveComponents(parse(e,a),parse(r,a),a,true),a)}function normalize(e,r){if(typeof e==="string"){e=serialize(parse(e,r),r)}else if(typeOf(e)==="object"){e=parse(serialize(e,r),r)}return e}function equal(e,r,t){if(typeof e==="string"){e=serialize(parse(e,t),t)}else if(typeOf(e)==="object"){e=serialize(e,t)}if(typeof r==="string"){r=serialize(parse(r,t),t)}else if(typeOf(r)==="object"){r=serialize(r,t)}return e===r}function escapeComponent(e,a){return e&&e.toString().replace(!a||!a.iri?r.ESCAPE:t.ESCAPE,pctEncChar)}function unescapeComponent(e,a){return e&&e.toString().replace(!a||!a.iri?r.PCT_ENCODED:t.PCT_ENCODED,pctDecChars)}var T={scheme:"http",domainHost:true,parse:function parse(e,r){if(!e.host){e.error=e.error||"HTTP URIs must have a host."}return e},serialize:function serialize(e,r){var t=String(e.scheme).toLowerCase()==="https";if(e.port===(t?443:80)||e.port===""){e.port=undefined}if(!e.path){e.path="/"}return e}};var L={scheme:"https",domainHost:T.domainHost,parse:T.parse,serialize:T.serialize};function isSecure(e){return typeof e.secure==="boolean"?e.secure:String(e.scheme).toLowerCase()==="wss"}var q={scheme:"ws",domainHost:true,parse:function parse(e,r){var t=e;t.secure=isSecure(t);t.resourceName=(t.path||"/")+(t.query?"?"+t.query:"");t.path=undefined;t.query=undefined;return t},serialize:function serialize(e,r){if(e.port===(isSecure(e)?443:80)||e.port===""){e.port=undefined}if(typeof e.secure==="boolean"){e.scheme=e.secure?"wss":"ws";e.secure=undefined}if(e.resourceName){var t=e.resourceName.split("?"),s=a(t,2),i=s[0],o=s[1];e.path=i&&i!=="/"?i:undefined;e.query=o;e.resourceName=undefined}e.fragment=undefined;return e}};var z={scheme:"wss",domainHost:q.domainHost,parse:q.parse,serialize:q.serialize};var M={};var U=true;var V="[A-Za-z0-9\\-\\.\\_\\~"+(U?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]";var Q="[0-9A-Fa-f]";var K=subexp(subexp("%[EFef]"+Q+"%"+Q+Q+"%"+Q+Q)+"|"+subexp("%[89A-Fa-f]"+Q+"%"+Q+Q)+"|"+subexp("%"+Q+Q));var H="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";var J="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";var B=merge(J,'[\\"\\\\]');var Z="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";var G=new RegExp(V,"g");var Y=new RegExp(K,"g");var W=new RegExp(merge("[^]",H,"[\\.]",'[\\"]',B),"g");var X=new RegExp(merge("[^]",V,Z),"g");var ee=X;function decodeUnreserved(e){var r=pctDecChars(e);return!r.match(G)?e:r}var re={scheme:"mailto",parse:function parse$$1(e,r){var t=e;var a=t.to=t.path?t.path.split(","):[];t.path=undefined;if(t.query){var s=false;var i={};var o=t.query.split("&");for(var n=0,l=o.length;n{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},7136:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')}};var r={};function __nccwpck_require__(t){var a=r[t];if(a!==undefined){return a.exports}var s=r[t]={exports:{}};var i=true;try{e[t].call(s.exports,s,s.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(1489);module.exports=t})();
\ No newline at end of file
diff --git a/packages/compat/webpack/compiled/schema-utils3/license b/packages/compat/webpack/compiled/schema-utils3/license
deleted file mode 100644
index 8c11fc7289..0000000000
--- a/packages/compat/webpack/compiled/schema-utils3/license
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright JS Foundation and other contributors
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/compat/webpack/compiled/schema-utils3/package.json b/packages/compat/webpack/compiled/schema-utils3/package.json
deleted file mode 100644
index 30a7f365ab..0000000000
--- a/packages/compat/webpack/compiled/schema-utils3/package.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"schema-utils3","author":"webpack Contrib (https://github.com/webpack-contrib)","version":"3.1.1","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts"}
diff --git a/packages/compat/webpack/compiled/tapable/index.js b/packages/compat/webpack/compiled/tapable/index.js
deleted file mode 100644
index e213eb631b..0000000000
--- a/packages/compat/webpack/compiled/tapable/index.js
+++ /dev/null
@@ -1 +0,0 @@
-(()=>{"use strict";var e={410:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncParallelBailHookCodeFactory extends r{content({onError:e,onResult:t,onDone:n}){let o="";o+=`var _results = new Array(${this.options.taps.length});\n`;o+="var _checkDone = function() {\n";o+="for(var i = 0; i < _results.length; i++) {\n";o+="var item = _results[i];\n";o+="if(item === undefined) return false;\n";o+="if(item.result !== undefined) {\n";o+=t("item.result");o+="return true;\n";o+="}\n";o+="if(item.error) {\n";o+=e("item.error");o+="return true;\n";o+="}\n";o+="}\n";o+="return false;\n";o+="}\n";o+=this.callTapsParallel({onError:(e,t,n,o)=>{let r="";r+=`if(${e} < _results.length && ((_results.length = ${e+1}), (_results[${e}] = { error: ${t} }), _checkDone())) {\n`;r+=o(true);r+="} else {\n";r+=n();r+="}\n";return r},onResult:(e,t,n,o)=>{let r="";r+=`if(${e} < _results.length && (${t} !== undefined && (_results.length = ${e+1}), (_results[${e}] = { result: ${t} }), _checkDone())) {\n`;r+=o(true);r+="} else {\n";r+=n();r+="}\n";return r},onTap:(e,t,n,o)=>{let r="";if(e>0){r+=`if(${e} >= _results.length) {\n`;r+=n();r+="} else {\n"}r+=t();if(e>0)r+="}\n";return r},onDone:n});return o}}const s=new AsyncParallelBailHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncParallelBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncParallelBailHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncParallelBailHook.prototype=null;e.exports=AsyncParallelBailHook},598:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncParallelHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsParallel({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncParallelHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncParallelHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncParallelHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncParallelHook.prototype=null;e.exports=AsyncParallelHook},178:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncSeriesBailHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,onDone:o}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onResult:(e,n,o)=>`if(${n} !== undefined) {\n${t(n)}\n} else {\n${o()}}\n`,resultReturns:n,onDone:o})}}const s=new AsyncSeriesBailHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesBailHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesBailHook.prototype=null;e.exports=AsyncSeriesBailHook},97:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncSeriesHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncSeriesHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesHook.prototype=null;e.exports=AsyncSeriesHook},243:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncSeriesLoopHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsLooping({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncSeriesLoopHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesLoopHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesLoopHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesLoopHook.prototype=null;e.exports=AsyncSeriesLoopHook},969:(e,t,n)=>{const o=n(506);const r=n(507);class AsyncSeriesWaterfallHookCodeFactory extends r{content({onError:e,onResult:t,onDone:n}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onResult:(e,t,n)=>{let o="";o+=`if(${t} !== undefined) {\n`;o+=`${this._args[0]} = ${t};\n`;o+=`}\n`;o+=n();return o},onDone:()=>t(this._args[0])})}}const s=new AsyncSeriesWaterfallHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesWaterfallHook(e=[],t=undefined){if(e.length<1)throw new Error("Waterfall hooks must have at least one argument");const n=new o(e,t);n.constructor=AsyncSeriesWaterfallHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesWaterfallHook.prototype=null;e.exports=AsyncSeriesWaterfallHook},506:(e,t,n)=>{const o=n(837);const r=o.deprecate((()=>{}),"Hook.context is deprecated and will be removed");const CALL_DELEGATE=function(...e){this.call=this._createCall("sync");return this.call(...e)};const CALL_ASYNC_DELEGATE=function(...e){this.callAsync=this._createCall("async");return this.callAsync(...e)};const PROMISE_DELEGATE=function(...e){this.promise=this._createCall("promise");return this.promise(...e)};class Hook{constructor(e=[],t=undefined){this._args=e;this.name=t;this.taps=[];this.interceptors=[];this._call=CALL_DELEGATE;this.call=CALL_DELEGATE;this._callAsync=CALL_ASYNC_DELEGATE;this.callAsync=CALL_ASYNC_DELEGATE;this._promise=PROMISE_DELEGATE;this.promise=PROMISE_DELEGATE;this._x=undefined;this.compile=this.compile;this.tap=this.tap;this.tapAsync=this.tapAsync;this.tapPromise=this.tapPromise}compile(e){throw new Error("Abstract: should be overridden")}_createCall(e){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:e})}_tap(e,t,n){if(typeof t==="string"){t={name:t.trim()}}else if(typeof t!=="object"||t===null){throw new Error("Invalid tap options")}if(typeof t.name!=="string"||t.name===""){throw new Error("Missing name for tap")}if(typeof t.context!=="undefined"){r()}t=Object.assign({type:e,fn:n},t);t=this._runRegisterInterceptors(t);this._insert(t)}tap(e,t){this._tap("sync",e,t)}tapAsync(e,t){this._tap("async",e,t)}tapPromise(e,t){this._tap("promise",e,t)}_runRegisterInterceptors(e){for(const t of this.interceptors){if(t.register){const n=t.register(e);if(n!==undefined){e=n}}}return e}withOptions(e){const mergeOptions=t=>Object.assign({},e,typeof t==="string"?{name:t}:t);return{name:this.name,tap:(e,t)=>this.tap(mergeOptions(e),t),tapAsync:(e,t)=>this.tapAsync(mergeOptions(e),t),tapPromise:(e,t)=>this.tapPromise(mergeOptions(e),t),intercept:e=>this.intercept(e),isUsed:()=>this.isUsed(),withOptions:e=>this.withOptions(mergeOptions(e))}}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(e){this._resetCompilation();this.interceptors.push(Object.assign({},e));if(e.register){for(let t=0;t0){o--;const e=this.taps[o];this.taps[o+1]=e;const r=e.stage||0;if(t){if(t.has(e.name)){t.delete(e.name);continue}if(t.size>0){continue}}if(r>n){continue}o++;break}this.taps[o]=e}}Object.setPrototypeOf(Hook.prototype,null);e.exports=Hook},507:e=>{class HookCodeFactory{constructor(e){this.config=e;this.options=undefined;this._args=undefined}create(e){this.init(e);let t;switch(this.options.type){case"sync":t=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:e=>`throw ${e};\n`,onResult:e=>`return ${e};\n`,resultReturns:true,onDone:()=>"",rethrowIfPossible:true}));break;case"async":t=new Function(this.args({after:"_callback"}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:e=>`_callback(${e});\n`,onResult:e=>`_callback(null, ${e});\n`,onDone:()=>"_callback();\n"}));break;case"promise":let e=false;const n=this.contentWithInterceptors({onError:t=>{e=true;return`_error(${t});\n`},onResult:e=>`_resolve(${e});\n`,onDone:()=>"_resolve();\n"});let o="";o+='"use strict";\n';o+=this.header();o+="return new Promise((function(_resolve, _reject) {\n";if(e){o+="var _sync = true;\n";o+="function _error(_err) {\n";o+="if(_sync)\n";o+="_resolve(Promise.resolve().then((function() { throw _err; })));\n";o+="else\n";o+="_reject(_err);\n";o+="};\n"}o+=n;if(e){o+="_sync = false;\n"}o+="}));\n";t=new Function(this.args(),o);break}this.deinit();return t}setup(e,t){e._x=t.taps.map((e=>e.fn))}init(e){this.options=e;this._args=e.args.slice()}deinit(){this.options=undefined;this._args=undefined}contentWithInterceptors(e){if(this.options.interceptors.length>0){const t=e.onError;const n=e.onResult;const o=e.onDone;let r="";for(let e=0;e{let n="";for(let t=0;t{let t="";for(let n=0;n{let e="";for(let t=0;t0){e+="var _taps = this.taps;\n";e+="var _interceptors = this.interceptors;\n"}return e}needContext(){for(const e of this.options.taps)if(e.context)return true;return false}callTap(e,{onError:t,onResult:n,onDone:o,rethrowIfPossible:r}){let s="";let i=false;for(let t=0;te.type!=="sync"));const c=n||r;let a="";let l=o;let p=0;for(let n=this.options.taps.length-1;n>=0;n--){const r=n;const u=l!==o&&(this.options.taps[r].type!=="sync"||p++>20);if(u){p=0;a+=`function _next${r}() {\n`;a+=l();a+=`}\n`;l=()=>`${c?"return ":""}_next${r}();\n`}const f=l;const doneBreak=e=>{if(e)return"";return o()};const h=this.callTap(r,{onError:t=>e(r,t,f,doneBreak),onResult:t&&(e=>t(r,e,f,doneBreak)),onDone:!t&&f,rethrowIfPossible:s&&(i<0||rh}a+=l();return a}callTapsLooping({onError:e,onDone:t,rethrowIfPossible:n}){if(this.options.taps.length===0)return t();const o=this.options.taps.every((e=>e.type==="sync"));let r="";if(!o){r+="var _looper = (function() {\n";r+="var _loopAsync = false;\n"}r+="var _loop;\n";r+="do {\n";r+="_loop = false;\n";for(let e=0;e{let s="";s+=`if(${t} !== undefined) {\n`;s+="_loop = true;\n";if(!o)s+="if(_loopAsync) _looper();\n";s+=r(true);s+=`} else {\n`;s+=n();s+=`}\n`;return s},onDone:t&&(()=>{let e="";e+="if(!_loop) {\n";e+=t();e+="}\n";return e}),rethrowIfPossible:n&&o});r+="} while(_loop);\n";if(!o){r+="_loopAsync = true;\n";r+="});\n";r+="_looper();\n"}return r}callTapsParallel({onError:e,onResult:t,onDone:n,rethrowIfPossible:o,onTap:r=((e,t)=>t())}){if(this.options.taps.length<=1){return this.callTapsSeries({onError:e,onResult:t,onDone:n,rethrowIfPossible:o})}let s="";s+="do {\n";s+=`var _counter = ${this.options.taps.length};\n`;if(n){s+="var _done = (function() {\n";s+=n();s+="});\n"}for(let i=0;i{if(n)return"if(--_counter === 0) _done();\n";else return"--_counter;"};const doneBreak=e=>{if(e||!n)return"_counter = 0;\n";else return"_counter = 0;\n_done();\n"};s+="if(_counter <= 0) break;\n";s+=r(i,(()=>this.callTap(i,{onError:t=>{let n="";n+="if(_counter > 0) {\n";n+=e(i,t,done,doneBreak);n+="}\n";return n},onResult:t&&(e=>{let n="";n+="if(_counter > 0) {\n";n+=t(i,e,done,doneBreak);n+="}\n";return n}),onDone:!t&&(()=>done()),rethrowIfPossible:o})),done,doneBreak)}s+="} while(false);\n";return s}args({before:e,after:t}={}){let n=this._args;if(e)n=[e].concat(n);if(t)n=n.concat(t);if(n.length===0){return""}else{return n.join(", ")}}getTapFn(e){return`_x[${e}]`}getTap(e){return`_taps[${e}]`}getInterceptor(e){return`_interceptors[${e}]`}}e.exports=HookCodeFactory},876:(e,t,n)=>{const o=n(837);const defaultFactory=(e,t)=>t;class HookMap{constructor(e,t=undefined){this._map=new Map;this.name=t;this._factory=e;this._interceptors=[]}get(e){return this._map.get(e)}for(e){const t=this.get(e);if(t!==undefined){return t}let n=this._factory(e);const o=this._interceptors;for(let t=0;t{const o=n(506);class MultiHook{constructor(e,t=undefined){this.hooks=e;this.name=t}tap(e,t){for(const n of this.hooks){n.tap(e,t)}}tapAsync(e,t){for(const n of this.hooks){n.tapAsync(e,t)}}tapPromise(e,t){for(const n of this.hooks){n.tapPromise(e,t)}}isUsed(){for(const e of this.hooks){if(e.isUsed())return true}return false}intercept(e){for(const t of this.hooks){t.intercept(e)}}withOptions(e){return new MultiHook(this.hooks.map((t=>t.withOptions(e))),this.name)}}e.exports=MultiHook},130:(e,t,n)=>{const o=n(506);const r=n(507);class SyncBailHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,onDone:o,rethrowIfPossible:r}){return this.callTapsSeries({onError:(t,n)=>e(n),onResult:(e,n,o)=>`if(${n} !== undefined) {\n${t(n)};\n} else {\n${o()}}\n`,resultReturns:n,onDone:o,rethrowIfPossible:r})}}const s=new SyncBailHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncBailHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncBailHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncBailHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncBailHook.prototype=null;e.exports=SyncBailHook},856:(e,t,n)=>{const o=n(506);const r=n(507);class SyncHookCodeFactory extends r{content({onError:e,onDone:t,rethrowIfPossible:n}){return this.callTapsSeries({onError:(t,n)=>e(n),onDone:t,rethrowIfPossible:n})}}const s=new SyncHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncHook.prototype=null;e.exports=SyncHook},925:(e,t,n)=>{const o=n(506);const r=n(507);class SyncLoopHookCodeFactory extends r{content({onError:e,onDone:t,rethrowIfPossible:n}){return this.callTapsLooping({onError:(t,n)=>e(n),onDone:t,rethrowIfPossible:n})}}const s=new SyncLoopHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncLoopHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncLoopHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncLoopHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncLoopHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncLoopHook.prototype=null;e.exports=SyncLoopHook},844:(e,t,n)=>{const o=n(506);const r=n(507);class SyncWaterfallHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,rethrowIfPossible:o}){return this.callTapsSeries({onError:(t,n)=>e(n),onResult:(e,t,n)=>{let o="";o+=`if(${t} !== undefined) {\n`;o+=`${this._args[0]} = ${t};\n`;o+=`}\n`;o+=n();return o},onDone:()=>t(this._args[0]),doneReturns:n,rethrowIfPossible:o})}}const s=new SyncWaterfallHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncWaterfallHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncWaterfallHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncWaterfallHook(e=[],t=undefined){if(e.length<1)throw new Error("Waterfall hooks must have at least one argument");const n=new o(e,t);n.constructor=SyncWaterfallHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncWaterfallHook.prototype=null;e.exports=SyncWaterfallHook},837:e=>{e.exports=require("util")}};var t={};function __nccwpck_require__(n){var o=t[n];if(o!==undefined){return o.exports}var r=t[n]={exports:{}};var s=true;try{e[n](r,r.exports,__nccwpck_require__);s=false}finally{if(s)delete t[n]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n={};(()=>{var e=n;e.__esModule=true;e.SyncHook=__nccwpck_require__(856);e.SyncBailHook=__nccwpck_require__(130);e.SyncWaterfallHook=__nccwpck_require__(844);e.SyncLoopHook=__nccwpck_require__(925);e.AsyncParallelHook=__nccwpck_require__(598);e.AsyncParallelBailHook=__nccwpck_require__(410);e.AsyncSeriesHook=__nccwpck_require__(97);e.AsyncSeriesBailHook=__nccwpck_require__(178);e.AsyncSeriesLoopHook=__nccwpck_require__(243);e.AsyncSeriesWaterfallHook=__nccwpck_require__(969);e.HookMap=__nccwpck_require__(876);e.MultiHook=__nccwpck_require__(274)})();module.exports=n})();
\ No newline at end of file
diff --git a/packages/compat/webpack/compiled/tapable/license b/packages/compat/webpack/compiled/tapable/license
deleted file mode 100644
index 03c083cefe..0000000000
--- a/packages/compat/webpack/compiled/tapable/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License
-
-Copyright JS Foundation and other contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/packages/compat/webpack/compiled/tapable/package.json b/packages/compat/webpack/compiled/tapable/package.json
deleted file mode 100644
index 3bf8a40b03..0000000000
--- a/packages/compat/webpack/compiled/tapable/package.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"tapable","author":"Tobias Koppers @sokra","version":"2.2.1","license":"MIT","types":"./tapable.d.ts"}
diff --git a/packages/compat/webpack/compiled/tapable/tapable.d.ts b/packages/compat/webpack/compiled/tapable/tapable.d.ts
deleted file mode 100644
index 0201c9a820..0000000000
--- a/packages/compat/webpack/compiled/tapable/tapable.d.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-type FixedSizeArray = T extends 0
- ? void[]
- : ReadonlyArray & {
- 0: U;
- length: T;
- };
-type Measure = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
- ? T
- : never;
-type Append = {
- 0: [U];
- 1: [T[0], U];
- 2: [T[0], T[1], U];
- 3: [T[0], T[1], T[2], U];
- 4: [T[0], T[1], T[2], T[3], U];
- 5: [T[0], T[1], T[2], T[3], T[4], U];
- 6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
- 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
- 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
-}[Measure];
-type AsArray = T extends any[] ? T : [T];
-
-declare class UnsetAdditionalOptions {
- _UnsetAdditionalOptions: true
-}
-type IfSet = X extends UnsetAdditionalOptions ? {} : X;
-
-type Callback = (error: E | null, result?: T) => void;
-type InnerCallback = (error?: E | null | false, result?: T) => void;
-
-type FullTap = Tap & {
- type: "sync" | "async" | "promise",
- fn: Function
-}
-
-type Tap = TapOptions & {
- name: string;
-};
-
-type TapOptions = {
- before?: string;
- stage?: number;
-};
-
-interface HookInterceptor {
- name?: string;
- tap?: (tap: FullTap & IfSet) => void;
- call?: (...args: any[]) => void;
- loop?: (...args: any[]) => void;
- error?: (err: Error) => void;
- result?: (result: R) => void;
- done?: () => void;
- register?: (tap: FullTap & IfSet) => FullTap & IfSet;
-}
-
-type ArgumentNames = FixedSizeArray;
-
-declare class Hook {
- constructor(args?: ArgumentNames>, name?: string);
- name: string | undefined;
- taps: FullTap[];
- intercept(interceptor: HookInterceptor): void;
- isUsed(): boolean;
- callAsync(...args: Append, Callback>): void;
- promise(...args: AsArray): Promise;
- tap(options: string | Tap & IfSet, fn: (...args: AsArray) => R): void;
- withOptions(options: TapOptions & IfSet): Omit;
-}
-
-export class SyncHook extends Hook {
- call(...args: AsArray): R;
-}
-
-export class SyncBailHook extends SyncHook {}
-export class SyncLoopHook extends SyncHook {}
-export class SyncWaterfallHook extends SyncHook[0], AdditionalOptions> {}
-
-declare class AsyncHook extends Hook {
- tapAsync(
- options: string | Tap & IfSet,
- fn: (...args: Append, InnerCallback>) => void
- ): void;
- tapPromise(
- options: string | Tap & IfSet,
- fn: (...args: AsArray) => Promise
- ): void;
-}
-
-export class AsyncParallelHook extends AsyncHook {}
-export class AsyncParallelBailHook extends AsyncHook {}
-export class AsyncSeriesHook extends AsyncHook {}
-export class AsyncSeriesBailHook extends AsyncHook {}
-export class AsyncSeriesLoopHook extends AsyncHook {}
-export class AsyncSeriesWaterfallHook extends AsyncHook[0], AdditionalOptions> {}
-
-type HookFactory = (key: any, hook?: H) => H;
-
-interface HookMapInterceptor {
- factory?: HookFactory;
-}
-
-export class HookMap {
- constructor(factory: HookFactory, name?: string);
- name: string | undefined;
- get(key: any): H | undefined;
- for(key: any): H;
- intercept(interceptor: HookMapInterceptor): void;
-}
-
-export class MultiHook {
- constructor(hooks: H[], name?: string);
- name: string | undefined;
- tap(options: string | Tap, fn?: Function): void;
- tapAsync(options: string | Tap, fn?: Function): void;
- tapPromise(options: string | Tap, fn?: Function): void;
-}
diff --git a/packages/compat/webpack/modern.config.ts b/packages/compat/webpack/modern.config.ts
index 01b2b34e71..c3efdfdeee 100644
--- a/packages/compat/webpack/modern.config.ts
+++ b/packages/compat/webpack/modern.config.ts
@@ -1,3 +1,3 @@
-import baseConfig from '../../../scripts/modern.base.config';
+import { configForDualPackage } from '../../../scripts/modern.base.config';
-export default baseConfig;
+export default configForDualPackage;
diff --git a/packages/compat/webpack/package.json b/packages/compat/webpack/package.json
index 4719d09436..7d7d037cab 100644
--- a/packages/compat/webpack/package.json
+++ b/packages/compat/webpack/package.json
@@ -1,6 +1,6 @@
{
"name": "@rsbuild/webpack",
- "version": "0.6.13",
+ "version": "0.7.0-beta.5",
"homepage": "https://rsbuild.dev",
"repository": {
"type": "git",
@@ -8,22 +8,18 @@
"directory": "packages/compat/webpack"
},
"license": "MIT",
- "type": "commonjs",
+ "type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
- "default": "./dist/index.js"
- },
- "./plugin-css": {
- "types": "./dist/plugins/css.d.ts",
- "default": "./dist/plugins/css.js"
+ "import": "./dist/index.js",
+ "require": "./dist/index.cjs"
}
},
- "main": "./dist/index.js",
+ "main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"files": [
"static",
- "compiled",
"dist"
],
"scripts": {
@@ -33,9 +29,8 @@
"dependencies": {
"@rsbuild/core": "workspace:*",
"@rsbuild/shared": "workspace:*",
- "fast-glob": "^3.3.2",
- "globby": "^11.1.0",
"mini-css-extract-plugin": "2.8.1",
+ "copy-webpack-plugin": "9.1.0",
"postcss": "^8.4.38",
"tsconfig-paths-webpack-plugin": "4.1.0",
"webpack": "^5.91.0"
@@ -43,6 +38,9 @@
"devDependencies": {
"@scripts/test-helper": "workspace:*",
"@types/node": "18.x",
+ "ansi-escapes": "4.3.2",
+ "cli-truncate": "2.1.0",
+ "patch-console": "1.0.0",
"typescript": "^5.4.2"
},
"publishConfig": {
diff --git a/packages/compat/webpack/src/build.ts b/packages/compat/webpack/src/build.ts
index 32bdf2a3ff..ecf6f5ad31 100644
--- a/packages/compat/webpack/src/build.ts
+++ b/packages/compat/webpack/src/build.ts
@@ -1,17 +1,16 @@
+import { type Rspack, logger } from '@rsbuild/core';
import {
type BuildOptions,
type MultiStats,
- type Rspack,
type RspackConfig,
type Stats,
getNodeEnv,
- logger,
onCompileDone,
setNodeEnv,
} from '@rsbuild/shared';
import type { Configuration as WebpackConfig } from 'webpack';
// @ts-expect-error
-import WebpackMultiStats from 'webpack/lib/MultiStats';
+import WebpackMultiStats from 'webpack/lib/MultiStats.js';
import { createCompiler } from './createCompiler';
import { type InitConfigsOptions, initConfigs } from './initConfigs';
diff --git a/packages/compat/webpack/src/createCompiler.ts b/packages/compat/webpack/src/createCompiler.ts
index 1ed53a80da..a7cb62a966 100644
--- a/packages/compat/webpack/src/createCompiler.ts
+++ b/packages/compat/webpack/src/createCompiler.ts
@@ -1,21 +1,20 @@
+import { type Rspack, logger } from '@rsbuild/core';
import {
- type InternalContext,
- formatStats,
- getDevMiddleware,
- getStatsOptions,
-} from '@rsbuild/core/internal';
-import {
- type Rspack,
type RspackConfig,
type Stats,
debug,
isDev,
- logger,
onCompileDone,
} from '@rsbuild/shared';
// @ts-expect-error
-import WebpackMultiStats from 'webpack/lib/MultiStats';
+import WebpackMultiStats from 'webpack/lib/MultiStats.js';
import { type InitConfigsOptions, initConfigs } from './initConfigs';
+import {
+ type InternalContext,
+ formatStats,
+ getDevMiddleware,
+ getStatsOptions,
+} from './shared';
import type { WebpackConfig } from './types';
export async function createCompiler({
@@ -89,7 +88,7 @@ export async function createDevMiddleware(
}
return {
- devMiddleware: getDevMiddleware(compiler),
+ devMiddleware: await getDevMiddleware(compiler),
compiler,
};
}
diff --git a/packages/compat/webpack/src/initConfigs.ts b/packages/compat/webpack/src/initConfigs.ts
index f4c650f73e..1ba17d4e1b 100644
--- a/packages/compat/webpack/src/initConfigs.ts
+++ b/packages/compat/webpack/src/initConfigs.ts
@@ -1,7 +1,3 @@
-import {
- type InternalContext,
- initRsbuildConfig,
-} from '@rsbuild/core/internal';
import {
type CreateRsbuildOptions,
type InspectConfigOptions,
@@ -9,6 +5,7 @@ import {
isDebug,
} from '@rsbuild/shared';
import { inspectConfig } from './inspectConfig';
+import { type InternalContext, initRsbuildConfig } from './shared';
import type { WebpackConfig } from './types';
import { generateWebpackConfig } from './webpackConfig';
diff --git a/packages/compat/webpack/src/inspectConfig.ts b/packages/compat/webpack/src/inspectConfig.ts
index c1b479e5b9..fa9070e8fc 100644
--- a/packages/compat/webpack/src/inspectConfig.ts
+++ b/packages/compat/webpack/src/inspectConfig.ts
@@ -41,7 +41,7 @@ export async function inspectConfig({
pluginNames: string[];
} = {
...context.normalizedConfig!,
- pluginNames: pluginManager.plugins.map((p) => p.name),
+ pluginNames: pluginManager.getPlugins().map((p) => p.name),
};
const rawRsbuildConfig = await stringifyConfig(
diff --git a/packages/compat/webpack/src/plugin.ts b/packages/compat/webpack/src/plugin.ts
new file mode 100644
index 0000000000..db4186cf52
--- /dev/null
+++ b/packages/compat/webpack/src/plugin.ts
@@ -0,0 +1,125 @@
+import fs from 'node:fs';
+import {
+ type BundlerChain,
+ type ChainIdentifier,
+ type CopyPluginOptions,
+ type RsbuildPlugin,
+ type RsbuildTarget,
+ TARGET_ID_MAP,
+ isWebTarget,
+} from '@rsbuild/shared';
+
+async function applyTsConfigPathsPlugin({
+ chain,
+ CHAIN_ID,
+ mainFields,
+ extensions,
+ configFile,
+}: {
+ chain: BundlerChain;
+ CHAIN_ID: ChainIdentifier;
+ mainFields: (string | string[])[];
+ extensions: string[];
+ configFile: string;
+}) {
+ const { TsconfigPathsPlugin } = await import('tsconfig-paths-webpack-plugin');
+
+ chain.resolve
+ .plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS)
+ .use(TsconfigPathsPlugin, [
+ {
+ configFile,
+ extensions,
+ // https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
+ mainFields: mainFields as string[],
+ },
+ ]);
+}
+
+const getMainFields = (chain: BundlerChain, target: RsbuildTarget) => {
+ const mainFields = chain.resolve.mainFields.values();
+
+ if (mainFields.length) {
+ return mainFields;
+ }
+
+ if (isWebTarget(target)) {
+ return ['browser', 'module', 'main'];
+ }
+
+ return ['module', 'main'];
+};
+
+/**
+ * Handling differences between Webpack and Rspack
+ */
+export const pluginAdaptor = (): RsbuildPlugin => ({
+ name: 'rsbuild-webpack:adaptor',
+
+ setup(api) {
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
+ const config = api.getNormalizedConfig();
+
+ if (
+ api.context.tsconfigPath &&
+ config.source.aliasStrategy === 'prefer-tsconfig'
+ ) {
+ await applyTsConfigPathsPlugin({
+ chain,
+ CHAIN_ID,
+ configFile: api.context.tsconfigPath,
+ mainFields: getMainFields(chain, target),
+ extensions: chain.resolve.extensions.values(),
+ });
+ }
+
+ // enable progress bar for webpack by default
+ const progress = config.dev.progressBar ?? true;
+ if (progress) {
+ const { ProgressPlugin } = await import('./progress/ProgressPlugin');
+ chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
+ {
+ id: TARGET_ID_MAP[target],
+ ...(progress === true ? {} : progress),
+ },
+ ]);
+ }
+
+ const { copy } = config.output;
+ if (copy) {
+ const { default: CopyPlugin } = await import(
+ // @ts-expect-error copy-webpack-plugin does not provide types
+ 'copy-webpack-plugin'
+ );
+
+ const options: CopyPluginOptions = Array.isArray(copy)
+ ? { patterns: copy }
+ : copy;
+
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
+ }
+ });
+
+ api.modifyWebpackConfig(async (config) => {
+ const copyPlugin = config.plugins?.find(
+ (item) => item?.constructor.name === 'CopyPlugin',
+ ) as unknown as CopyPluginOptions;
+
+ if (copyPlugin) {
+ // If the pattern.context directory not exists, we should remove CopyPlugin.
+ // Otherwise the CopyPlugin will cause the webpack to re-compile.
+ const isContextNotExists = copyPlugin.patterns.every(
+ (pattern) =>
+ typeof pattern !== 'string' &&
+ pattern.context &&
+ !fs.existsSync(pattern.context),
+ );
+ if (isContextNotExists) {
+ config.plugins = config.plugins?.filter(
+ (item) => item?.constructor.name !== 'CopyPlugin',
+ );
+ }
+ }
+ });
+ },
+});
diff --git a/packages/compat/webpack/src/plugins/copy.ts b/packages/compat/webpack/src/plugins/copy.ts
deleted file mode 100644
index 0ff63f70ab..0000000000
--- a/packages/compat/webpack/src/plugins/copy.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import fs from 'node:fs';
-import type { CopyPluginOptions, RsbuildPlugin } from '@rsbuild/shared';
-
-export const pluginCopy = (): RsbuildPlugin => ({
- name: 'rsbuild-webpack:copy',
-
- setup(api) {
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
- const { copy } = config.output;
-
- if (!copy) {
- return;
- }
-
- const { default: CopyPlugin } = await import(
- '../../compiled/copy-webpack-plugin'
- );
-
- const options: CopyPluginOptions = Array.isArray(copy)
- ? { patterns: copy }
- : copy;
-
- chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
- });
-
- api.modifyWebpackConfig(async (config) => {
- const copyPlugin = config.plugins?.find(
- (item) => item?.constructor.name === 'CopyPlugin',
- ) as unknown as CopyPluginOptions;
-
- if (copyPlugin) {
- // If the pattern.context directory not exists, we should remove CopyPlugin.
- // Otherwise the CopyPlugin will cause the webpack to re-compile.
- const isContextNotExists = copyPlugin.patterns.every(
- (pattern) =>
- typeof pattern !== 'string' &&
- pattern.context &&
- !fs.existsSync(pattern.context),
- );
- if (isContextNotExists) {
- config.plugins = config.plugins?.filter(
- (item) => item?.constructor.name !== 'CopyPlugin',
- );
- }
- }
- });
- },
-});
diff --git a/packages/compat/webpack/src/plugins/css.ts b/packages/compat/webpack/src/plugins/css.ts
deleted file mode 100644
index b78ef8e90b..0000000000
--- a/packages/compat/webpack/src/plugins/css.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import {
- type BundlerChainRule,
- type CSSExtractOptions,
- CSS_REGEX,
- type ModifyChainUtils,
- type NormalizedConfig,
- type RsbuildContext,
- type RsbuildPlugin,
- getBrowserslistWithDefault,
- getCssLoaderOptions,
- getCssModuleLocalIdentName,
- getPostcssLoaderOptions,
- getSharedPkgCompiledPath,
- isUseCssExtract,
- mergeChainedOptions,
- resolvePackage,
-} from '@rsbuild/shared';
-
-export async function applyBaseCSSRule({
- rule,
- config,
- context,
- utils: { target, isProd, isServer, CHAIN_ID, isWebWorker },
- importLoaders = 1,
-}: {
- rule: BundlerChainRule;
- config: NormalizedConfig;
- context: RsbuildContext;
- utils: ModifyChainUtils;
- importLoaders?: number;
-}) {
- const browserslist = await getBrowserslistWithDefault(
- context.rootPath,
- config,
- target,
- );
-
- // 1. Check user config
- const enableExtractCSS = isUseCssExtract(config, target);
- const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
-
- // 2. Prepare loader options
- const localIdentName = getCssModuleLocalIdentName(config, isProd);
-
- const cssLoaderOptions = getCssLoaderOptions({
- config,
- importLoaders,
- isServer,
- isWebWorker,
- localIdentName,
- });
-
- // 3. Create webpack rule
- // Order: style-loader/mini-css-extract -> css-loader -> postcss-loader
- if (!isServer && !isWebWorker) {
- // use mini-css-extract-plugin loader
- if (enableExtractCSS) {
- const extraCSSOptions: Required =
- typeof config.tools.cssExtract === 'object'
- ? config.tools.cssExtract
- : {
- loaderOptions: {},
- pluginOptions: {},
- };
-
- rule
- .use(CHAIN_ID.USE.MINI_CSS_EXTRACT)
- .loader(require('mini-css-extract-plugin').loader)
- .options(extraCSSOptions.loaderOptions)
- .end();
- }
- // use style-loader
- else {
- const styleLoaderOptions = mergeChainedOptions({
- defaults: {},
- options: config.tools.styleLoader,
- });
-
- rule
- .use(CHAIN_ID.USE.STYLE)
- .loader(getSharedPkgCompiledPath('style-loader'))
- .options(styleLoaderOptions)
- .end();
- }
-
- // use css-modules-typescript-loader
- if (enableCSSModuleTS && cssLoaderOptions.modules) {
- rule
- .use(CHAIN_ID.USE.CSS_MODULES_TS)
- .loader(
- resolvePackage(
- '@rsbuild/shared/css-modules-typescript-loader',
- __dirname,
- ),
- )
- .options({
- modules: cssLoaderOptions.modules,
- })
- .end();
- }
- } else {
- rule
- .use(CHAIN_ID.USE.IGNORE_CSS)
- .loader(resolvePackage('@rsbuild/shared/ignore-css-loader', __dirname))
- .end();
- }
-
- rule
- .use(CHAIN_ID.USE.CSS)
- .loader(getSharedPkgCompiledPath('css-loader'))
- .options(cssLoaderOptions)
- .end();
-
- if (!isServer && !isWebWorker) {
- const postcssLoaderOptions = await getPostcssLoaderOptions({
- browserslist,
- config,
- root: context.rootPath,
- });
-
- rule
- .use(CHAIN_ID.USE.POSTCSS)
- .loader(getSharedPkgCompiledPath('postcss-loader'))
- .options(postcssLoaderOptions)
- .end();
- }
-
- // CSS imports should always be treated as sideEffects
- rule.merge({ sideEffects: true });
-
- // Enable preferRelative by default, which is consistent with the default behavior of css-loader
- // see: https://github.com/webpack-contrib/css-loader/blob/579fc13/src/plugins/postcss-import-parser.js#L234
- rule.resolve.preferRelative(true);
-}
-
-export const pluginCss = (): RsbuildPlugin => {
- return {
- name: 'rsbuild-webpack:css',
- setup(api) {
- api.modifyBundlerChain(async (chain, utils) => {
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.CSS);
- const config = api.getNormalizedConfig();
- rule.test(CSS_REGEX);
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- });
- });
- },
- };
-};
diff --git a/packages/compat/webpack/src/plugins/less.ts b/packages/compat/webpack/src/plugins/less.ts
deleted file mode 100644
index 3d7c2548a1..0000000000
--- a/packages/compat/webpack/src/plugins/less.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import {
- type FileFilterUtil,
- LESS_REGEX,
- type RsbuildPlugin,
- getLessLoaderOptions,
- getSharedPkgCompiledPath,
-} from '@rsbuild/shared';
-
-export type LessLoaderUtils = {
- addExcludes: FileFilterUtil;
-};
-
-export function pluginLess(): RsbuildPlugin {
- return {
- name: 'rsbuild-webpack:less',
- setup(api) {
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
- const { applyBaseCSSRule } = await import('./css');
-
- const { options, excludes } = getLessLoaderOptions(
- config.tools.less,
- config.output.sourceMap.css,
- api.context.rootPath,
- );
- const rule = chain.module
- .rule(utils.CHAIN_ID.RULE.LESS)
- .test(LESS_REGEX);
-
- for (const item of excludes) {
- rule.exclude.add(item);
- }
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- importLoaders: 2,
- });
-
- rule
- .use(utils.CHAIN_ID.USE.LESS)
- .loader(getSharedPkgCompiledPath('less-loader'))
- .options(options);
- });
- },
- };
-}
diff --git a/packages/compat/webpack/src/plugins/output.ts b/packages/compat/webpack/src/plugins/output.ts
deleted file mode 100644
index 7700b7d1c2..0000000000
--- a/packages/compat/webpack/src/plugins/output.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { posix } from 'node:path';
-import {
- type RsbuildPlugin,
- applyOutputPlugin,
- getDistPath,
- getFilename,
- isUseCssExtract,
- mergeChainedOptions,
-} from '@rsbuild/shared';
-
-export const pluginOutput = (): RsbuildPlugin => ({
- name: 'rsbuild-webpack:output',
-
- setup(api) {
- applyOutputPlugin(api);
-
- api.modifyBundlerChain(async (chain, { isProd, target, CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
-
- // css output
- if (isUseCssExtract(config, target)) {
- const { default: MiniCssExtractPlugin } = await import(
- 'mini-css-extract-plugin'
- );
- const extractPluginOptions = mergeChainedOptions({
- defaults: {},
- options: config.tools.cssExtract?.pluginOptions,
- });
-
- const cssPath = getDistPath(config, 'css');
- const cssAsyncPath = getDistPath(config, 'cssAsync');
- const cssFilename = getFilename(config, 'css', isProd);
-
- chain
- .plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)
- .use(MiniCssExtractPlugin, [
- {
- filename: posix.join(cssPath, cssFilename),
- chunkFilename: posix.join(cssAsyncPath, cssFilename),
- ignoreOrder: true,
- ...extractPluginOptions,
- },
- ]);
- }
- });
- },
-});
diff --git a/packages/compat/webpack/src/plugins/progress.ts b/packages/compat/webpack/src/plugins/progress.ts
deleted file mode 100644
index 523f60834c..0000000000
--- a/packages/compat/webpack/src/plugins/progress.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { type RsbuildPlugin, TARGET_ID_MAP } from '@rsbuild/shared';
-
-export const pluginProgress = (): RsbuildPlugin => ({
- name: 'rsbuild-webpack:progress',
- setup(api) {
- api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
- // enable progress bar for webpack by default
- const options = config.dev.progressBar ?? true;
-
- if (!options) {
- return;
- }
-
- const { ProgressPlugin } = await import('../progress/ProgressPlugin');
- chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
- {
- id: TARGET_ID_MAP[target],
- ...(options === true ? {} : options),
- },
- ]);
- });
- },
-});
diff --git a/packages/compat/webpack/src/plugins/resolve.ts b/packages/compat/webpack/src/plugins/resolve.ts
deleted file mode 100644
index 43d51c867d..0000000000
--- a/packages/compat/webpack/src/plugins/resolve.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import {
- type BundlerChain,
- type ChainIdentifier,
- type RsbuildPlugin,
- type RsbuildTarget,
- applyResolvePlugin,
- isWebTarget,
-} from '@rsbuild/shared';
-
-async function applyTsConfigPathsPlugin({
- chain,
- CHAIN_ID,
- mainFields,
- extensions,
- configFile,
-}: {
- chain: BundlerChain;
- CHAIN_ID: ChainIdentifier;
- mainFields: (string | string[])[];
- extensions: string[];
- configFile: string;
-}) {
- const { TsconfigPathsPlugin } = await import('tsconfig-paths-webpack-plugin');
-
- chain.resolve
- .plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS)
- .use(TsconfigPathsPlugin, [
- {
- configFile,
- extensions,
- // https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
- mainFields: mainFields as string[],
- },
- ]);
-}
-
-const getMainFields = (chain: BundlerChain, target: RsbuildTarget) => {
- const mainFields = chain.resolve.mainFields.values();
-
- if (mainFields.length) {
- return mainFields;
- }
-
- if (isWebTarget(target)) {
- return ['browser', 'module', 'main'];
- }
-
- return ['module', 'main'];
-};
-
-export const pluginResolve = (): RsbuildPlugin => ({
- name: 'rsbuild-webpack:resolve',
-
- setup(api) {
- applyResolvePlugin(api);
-
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
- const config = api.getNormalizedConfig();
-
- if (
- api.context.tsconfigPath &&
- config.source.aliasStrategy === 'prefer-tsconfig'
- ) {
- await applyTsConfigPathsPlugin({
- chain,
- CHAIN_ID,
- configFile: api.context.tsconfigPath,
- mainFields: getMainFields(chain, target),
- extensions: chain.resolve.extensions.values(),
- });
- }
- });
- },
-});
diff --git a/packages/compat/webpack/src/plugins/sass.ts b/packages/compat/webpack/src/plugins/sass.ts
deleted file mode 100644
index bb15430993..0000000000
--- a/packages/compat/webpack/src/plugins/sass.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import {
- type RsbuildPlugin,
- SASS_REGEX,
- getResolveUrlJoinFn,
- getSassLoaderOptions,
- getSharedPkgCompiledPath,
- patchCompilerGlobalLocation,
-} from '@rsbuild/shared';
-
-export function pluginSass(): RsbuildPlugin {
- return {
- name: 'rsbuild-webpack:sass',
- setup(api) {
- api.onAfterCreateCompiler(({ compiler }) => {
- patchCompilerGlobalLocation(compiler);
- });
-
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
- const { applyBaseCSSRule } = await import('./css');
-
- const { options, excludes } = getSassLoaderOptions(
- config.tools.sass,
- // source-maps required for loaders preceding resolve-url-loader
- true,
- );
- const rule = chain.module
- .rule(utils.CHAIN_ID.RULE.SASS)
- .test(SASS_REGEX);
-
- for (const item of excludes) {
- rule.exclude.add(item);
- }
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- // postcss-loader, resolve-url-loader, sass-loader
- importLoaders: 3,
- });
-
- rule
- .use(utils.CHAIN_ID.USE.RESOLVE_URL)
- .loader(getSharedPkgCompiledPath('resolve-url-loader'))
- .options({
- join: await getResolveUrlJoinFn(),
- // 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
- // it has performance regression issues in some scenarios,
- // so we need to disable the sourceMap option.
- sourceMap: false,
- })
- .end()
- .use(utils.CHAIN_ID.USE.SASS)
- .loader(getSharedPkgCompiledPath('sass-loader'))
- .options(options);
- });
- },
- };
-}
diff --git a/packages/compat/webpack/src/progress/helpers/bar.ts b/packages/compat/webpack/src/progress/helpers/bar.ts
index 340d8672b0..325140469e 100644
--- a/packages/compat/webpack/src/progress/helpers/bar.ts
+++ b/packages/compat/webpack/src/progress/helpers/bar.ts
@@ -1,5 +1,5 @@
import { color as colors } from '@rsbuild/shared';
-import cliTruncate from '../../../compiled/cli-truncate';
+import cliTruncate from 'cli-truncate';
import type { Props } from './type';
import { clamp } from './utils';
diff --git a/packages/compat/webpack/src/progress/helpers/bus.ts b/packages/compat/webpack/src/progress/helpers/bus.ts
index cb1e07f9c0..e043405fe4 100644
--- a/packages/compat/webpack/src/progress/helpers/bus.ts
+++ b/packages/compat/webpack/src/progress/helpers/bus.ts
@@ -1,7 +1,7 @@
import { Console } from 'node:console';
import { getProgressColor } from '@rsbuild/shared';
-import cliTruncate from '../../../compiled/cli-truncate';
-import patchConsole from '../../../compiled/patch-console';
+import cliTruncate from 'cli-truncate';
+import patchConsole from 'patch-console';
import { FULL_WIDTH, renderBar } from './bar';
import { create } from './log';
import type { LogUpdate } from './log';
diff --git a/packages/compat/webpack/src/progress/helpers/log.ts b/packages/compat/webpack/src/progress/helpers/log.ts
index d9765d236f..3b29ad32a1 100644
--- a/packages/compat/webpack/src/progress/helpers/log.ts
+++ b/packages/compat/webpack/src/progress/helpers/log.ts
@@ -1,5 +1,5 @@
import type { Writable } from 'node:stream';
-import ansiEscapes from '../../../compiled/ansi-escapes';
+import ansiEscapes from 'ansi-escapes';
export interface LogUpdate {
clear: () => void;
diff --git a/packages/compat/webpack/src/provider.ts b/packages/compat/webpack/src/provider.ts
index 60f1a4d286..f570c91b49 100644
--- a/packages/compat/webpack/src/provider.ts
+++ b/packages/compat/webpack/src/provider.ts
@@ -1,10 +1,3 @@
-import {
- createContext,
- createPublicContext,
- getPluginAPI,
- initRsbuildConfig,
- plugins,
-} from '@rsbuild/core/internal';
import {
type CreateCompiler,
type PreviewServerOptions,
@@ -12,6 +5,16 @@ import {
pickRsbuildConfig,
} from '@rsbuild/shared';
import { initConfigs } from './initConfigs';
+import {
+ createContext,
+ createDevServer,
+ createPublicContext,
+ getPluginAPI,
+ initRsbuildConfig,
+ plugins,
+ setCssExtractPlugin,
+ startProdServer,
+} from './shared';
export const webpackProvider: RsbuildProvider<'webpack'> = async ({
pluginManager,
@@ -23,6 +26,9 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
context.pluginAPI = pluginAPI;
+ const { default: cssExtractPlugin } = await import('mini-css-extract-plugin');
+ setCssExtractPlugin(cssExtractPlugin);
+
const createCompiler = (async () => {
const { createCompiler } = await import('./createCompiler');
const { webpackConfigs } = await initConfigs({
@@ -44,16 +50,15 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
async applyDefaultPlugins() {
const allPlugins = await Promise.all([
- plugins.basic?.(),
- plugins.entry?.(),
- plugins.cache?.(),
- plugins.target?.(),
- import('./plugins/output').then((m) => m.pluginOutput()),
- import('./plugins/resolve').then((m) => m.pluginResolve()),
- plugins.fileSize?.(),
- plugins.cleanOutput?.(),
+ plugins.basic(),
+ plugins.entry(),
+ plugins.cache(),
+ plugins.target(),
+ plugins.output(),
+ plugins.resolve(),
+ plugins.fileSize(),
+ plugins.cleanOutput(),
plugins.asset(),
- import('./plugins/copy').then((m) => m.pluginCopy()),
plugins.html(async (tags) => {
const result = await context.hooks.modifyHTMLTags.call(tags);
return result[0];
@@ -62,14 +67,13 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
plugins.moment(),
plugins.nodeAddons(),
plugins.define(),
- import('./plugins/progress').then((m) => m.pluginProgress()),
- import('./plugins/css').then((m) => m.pluginCss()),
- import('./plugins/sass').then((m) => m.pluginSass()),
- import('./plugins/less').then((m) => m.pluginLess()),
+ plugins.css(),
+ plugins.less(),
+ plugins.sass(),
plugins.bundleAnalyzer(),
plugins.rsdoctor(),
plugins.splitChunks(),
- plugins.startUrl?.(),
+ plugins.startUrl(),
plugins.inlineChunk(),
plugins.externals(),
plugins.performance(),
@@ -77,6 +81,7 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
plugins.server(),
plugins.moduleFederation(),
plugins.manifest(),
+ import('./plugin').then((m) => m.pluginAdaptor()),
]);
pluginManager.addPlugins(allPlugins);
@@ -92,7 +97,6 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
},
async createDevServer(options) {
- const { createDevServer } = await import('@rsbuild/core/internal');
const { createDevMiddleware } = await import('./createCompiler');
await initRsbuildConfig({ context, pluginManager });
return createDevServer(
@@ -103,7 +107,6 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
},
async startDevServer(options) {
- const { createDevServer } = await import('@rsbuild/core/internal');
const { createDevMiddleware } = await import('./createCompiler');
await initRsbuildConfig({
context,
@@ -123,7 +126,6 @@ export const webpackProvider: RsbuildProvider<'webpack'> = async ({
},
async preview(options?: PreviewServerOptions) {
- const { startProdServer } = await import('@rsbuild/core/internal');
await initRsbuildConfig({
context,
pluginManager,
diff --git a/packages/compat/webpack/src/shared.ts b/packages/compat/webpack/src/shared.ts
index 68ddf15d51..c73137c7c4 100644
--- a/packages/compat/webpack/src/shared.ts
+++ b/packages/compat/webpack/src/shared.ts
@@ -1,14 +1,33 @@
-import fs from 'node:fs';
-import { join } from 'node:path';
-import {
- type SharedCompiledPkgNames,
- getSharedPkgCompiledPath,
-} from '@rsbuild/shared';
+import { __internalHelper } from '@rsbuild/core';
-export const getCompiledPath = (packageName: string) => {
- const providerCompilerPath = join(__dirname, '../../compiled', packageName);
- if (fs.existsSync(providerCompilerPath)) {
- return providerCompilerPath;
- }
- return getSharedPkgCompiledPath(packageName as SharedCompiledPkgNames);
+const {
+ plugins,
+ createContext,
+ createPublicContext,
+ getPluginAPI,
+ getChainUtils,
+ initRsbuildConfig,
+ setCssExtractPlugin,
+ createDevServer,
+ startProdServer,
+ formatStats,
+ getDevMiddleware,
+ getStatsOptions,
+} = __internalHelper;
+
+export {
+ plugins,
+ createContext,
+ createPublicContext,
+ getPluginAPI,
+ getChainUtils,
+ initRsbuildConfig,
+ setCssExtractPlugin,
+ createDevServer,
+ startProdServer,
+ formatStats,
+ getDevMiddleware,
+ getStatsOptions,
};
+
+export type InternalContext = __internalHelper.InternalContext;
diff --git a/packages/compat/webpack/src/webpackConfig.ts b/packages/compat/webpack/src/webpackConfig.ts
index 25625cac7c..5d66326bff 100644
--- a/packages/compat/webpack/src/webpackConfig.ts
+++ b/packages/compat/webpack/src/webpackConfig.ts
@@ -1,7 +1,4 @@
-import {
- type InternalContext,
- getChainUtils as getBaseChainUtils,
-} from '@rsbuild/core/internal';
+import { __internalHelper } from '@rsbuild/core';
import {
type BundlerChain,
type ModifyWebpackChainUtils,
@@ -15,7 +12,10 @@ import {
modifyBundlerChain,
} from '@rsbuild/shared';
import type { RuleSetRule, WebpackPluginInstance } from 'webpack';
-import { getCompiledPath } from './shared';
+import {
+ type InternalContext,
+ getChainUtils as getBaseChainUtils,
+} from './shared';
import type { WebpackConfig } from './types';
async function modifyWebpackChain(
@@ -69,7 +69,6 @@ async function getChainUtils(
target: RsbuildTarget,
): Promise {
const { default: webpack } = await import('webpack');
- const { getHTMLPlugin } = await import('@rsbuild/core/internal');
const nameMap = {
web: 'client',
node: 'server',
@@ -81,8 +80,7 @@ async function getChainUtils(
...getBaseChainUtils(target),
name: nameMap[target] || '',
webpack,
- getCompiledPath,
- HtmlWebpackPlugin: getHTMLPlugin(),
+ HtmlWebpackPlugin: __internalHelper.getHTMLPlugin(),
};
}
@@ -142,13 +140,14 @@ export async function generateWebpackConfig({
context: InternalContext;
}) {
const chainUtils = await getChainUtils(target);
+ const { default: webpack } = await import('webpack');
const {
BannerPlugin,
DefinePlugin,
IgnorePlugin,
ProvidePlugin,
HotModuleReplacementPlugin,
- } = await import('webpack');
+ } = webpack;
const bundlerChain = await modifyBundlerChain(context, {
...chainUtils,
diff --git a/packages/compat/webpack/tests/__snapshots__/css.test.ts.snap b/packages/compat/webpack/tests/__snapshots__/css.test.ts.snap
deleted file mode 100644
index cf97f00383..0000000000
--- a/packages/compat/webpack/tests/__snapshots__/css.test.ts.snap
+++ /dev/null
@@ -1,154 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugin-css > should not apply postcss-loader when target is node 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.css\\$/,
- "use": [
- {
- "loader": "@rsbuild/shared/ignore-css-loader",
- },
- {
- "loader": "/packages/shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "exportOnlyLocals": true,
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- "namedExport": false,
- },
- "sourceMap": false,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugin-css > should override browserslist of autoprefixer when using output.overrideBrowserslist config 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.css\\$/,
- "use": [
- {
- "loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
- },
- {
- "loader": "/packages/shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- "namedExport": false,
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "config": false,
- "plugins": [
- {
- "browsers": [
- "Chrome 80",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "Chrome 80",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugin-css > should remove some postcss plugins based on browserslist 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.css\\$/,
- "use": [
- {
- "loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
- },
- {
- "loader": "/packages/shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- "namedExport": false,
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "config": false,
- "plugins": [
- {
- "browsers": [
- "Chrome 100",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "Chrome 100",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- ],
- },
- ],
- },
-}
-`;
diff --git a/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap b/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap
index eb591fc2bf..5c87166f0c 100644
--- a/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap
+++ b/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap
@@ -64,7 +64,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -91,7 +91,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -118,7 +118,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -145,7 +145,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -172,7 +172,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
},
{
- "loader": "/packages/shared/compiled/css-loader",
+ "loader": "/packages/core/compiled/css-loader",
"options": {
"importLoaders": 1,
"modules": {
@@ -185,7 +185,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
},
{
- "loader": "/packages/shared/compiled/postcss-loader",
+ "loader": "/packages/core/compiled/postcss-loader",
"options": {
"postcssOptions": {
"config": false,
@@ -222,15 +222,15 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"preferRelative": true,
},
"sideEffects": true,
- "test": /\\\\\\.s\\(\\?:a\\|c\\)ss\\$/,
+ "test": /\\\\\\.less\\$/,
"use": [
{
"loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
},
{
- "loader": "/packages/shared/compiled/css-loader",
+ "loader": "/packages/core/compiled/css-loader",
"options": {
- "importLoaders": 3,
+ "importLoaders": 2,
"modules": {
"auto": true,
"exportLocalsConvention": "camelCase",
@@ -241,7 +241,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
},
{
- "loader": "/packages/shared/compiled/postcss-loader",
+ "loader": "/packages/core/compiled/postcss-loader",
"options": {
"postcssOptions": {
"config": false,
@@ -272,19 +272,18 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
},
{
- "loader": "/packages/shared/compiled/resolve-url-loader",
+ "loader": "/packages/core/compiled/less-loader",
"options": {
- "join": [Function],
+ "implementation": "/packages/shared/compiled/less",
+ "lessOptions": {
+ "javascriptEnabled": true,
+ "paths": [
+ "/packages/compat/webpack/tests/node_modules",
+ ],
+ },
"sourceMap": false,
},
},
- {
- "loader": "/packages/shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/shared/compiled/sass",
- "sourceMap": true,
- },
- },
],
},
{
@@ -292,15 +291,15 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"preferRelative": true,
},
"sideEffects": true,
- "test": /\\\\\\.less\\$/,
+ "test": /\\\\\\.s\\(\\?:a\\|c\\)ss\\$/,
"use": [
{
"loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
},
{
- "loader": "/packages/shared/compiled/css-loader",
+ "loader": "/packages/core/compiled/css-loader",
"options": {
- "importLoaders": 2,
+ "importLoaders": 3,
"modules": {
"auto": true,
"exportLocalsConvention": "camelCase",
@@ -311,7 +310,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
},
{
- "loader": "/packages/shared/compiled/postcss-loader",
+ "loader": "/packages/core/compiled/postcss-loader",
"options": {
"postcssOptions": {
"config": false,
@@ -342,18 +341,19 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
},
{
- "loader": "/packages/shared/compiled/less-loader",
+ "loader": "/packages/core/compiled/resolve-url-loader",
"options": {
- "implementation": "/packages/shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- "paths": [
- "/packages/compat/webpack/tests/node_modules",
- ],
- },
+ "join": [Function],
"sourceMap": false,
},
},
+ {
+ "loader": "/packages/shared/compiled/sass-loader",
+ "options": {
+ "implementation": "/packages/shared/compiled/sass",
+ "sourceMap": true,
+ },
+ },
],
},
],
@@ -601,7 +601,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -628,7 +628,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -655,7 +655,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -682,7 +682,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
"parser": {
"dataUrlCondition": {
- "maxSize": 10000,
+ "maxSize": 4096,
},
},
"type": "asset",
@@ -709,7 +709,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
"loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
},
{
- "loader": "/packages/shared/compiled/css-loader",
+ "loader": "/packages/core/compiled/css-loader",
"options": {
"importLoaders": 1,
"modules": {
@@ -722,7 +722,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
},
{
- "loader": "/packages/shared/compiled/postcss-loader",
+ "loader": "/packages/core/compiled/postcss-loader",
"options": {
"postcssOptions": {
"config": false,
@@ -759,15 +759,15 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
"preferRelative": true,
},
"sideEffects": true,
- "test": /\\\\\\.s\\(\\?:a\\|c\\)ss\\$/,
+ "test": /\\\\\\.less\\$/,
"use": [
{
"loader": "/node_modules//mini-css-extract-plugin/dist/loader.js",
},
{
- "loader": "/packages/shared/compiled/css-loader",
+ "loader": "/packages/core/compiled/css-loader",
"options": {
- "importLoaders": 3,
+ "importLoaders": 2,
"modules": {
"auto": true,
"exportLocalsConvention": "camelCase",
@@ -778,7 +778,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
},
{
- "loader": "/packages/shared/compiled/postcss-loader",
+ "loader": "/packages/core/compiled/postcss-loader",
"options": {
"postcssOptions": {
"config": false,
@@ -809,19 +809,18 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
},
{
- "loader": "/packages/shared/compiled/resolve-url-loader",
+ "loader": "/packages/core/compiled/less-loader",
"options": {
- "join": [Function],
+ "implementation": "/packages/shared/compiled/less",
+ "lessOptions": {
+ "javascriptEnabled": true,
+ "paths": [
+ "