diff --git a/package.json b/package.json index 0f6330f3a3..d26a7a75f3 100644 --- a/package.json +++ b/package.json @@ -262,5 +262,10 @@ "node": ">=18.17.0", "pnpm": "8.15.7" }, - "packageManager": "pnpm@8.15.7" + "packageManager": "pnpm@8.15.7", + "pnpm": { + "patchedDependencies": { + "webpack-sources@3.2.3": "patches/webpack-sources@3.2.3.patch" + } + } } diff --git a/packages/next/src/build/webpack-build/impl.ts b/packages/next/src/build/webpack-build/impl.ts index 39ff87a40a..2a03f3d216 100644 --- a/packages/next/src/build/webpack-build/impl.ts +++ b/packages/next/src/build/webpack-build/impl.ts @@ -1,4 +1,5 @@ import type { webpack } from 'next/dist/compiled/webpack/webpack' +import { stringBufferUtils } from 'next/dist/compiled/webpack-sources3' import { red } from '../../lib/picocolors' import formatWebpackMessages from '../../client/components/react-dev-overlay/internal/helpers/format-webpack-messages' import { nonNullable } from '../../lib/non-nullable' @@ -185,6 +186,11 @@ export async function webpackBuildImpl( debug(`starting compiler`, compilerName) // We run client and server compilation separately to optimize for memory usage await runWebpackSpan.traceAsyncFn(async () => { + if (config.experimental.webpackMemoryOptimizations) { + stringBufferUtils.disableDualStringBufferCaching() + stringBufferUtils.enableStringInterning() + } + // Run the server compilers first and then the client // compiler to track the boundary of server/client components. let clientResult: SingleCompilerResult | null = null @@ -254,6 +260,9 @@ export async function webpackBuildImpl( } } + if (config.experimental.webpackMemoryOptimizations) { + stringBufferUtils.disableStringInterning() + } inputFileSystem?.purge?.() result = { diff --git a/packages/next/src/compiled/webpack-sources3/index.js b/packages/next/src/compiled/webpack-sources3/index.js index 312dd73c26..65e809aa0b 100644 --- a/packages/next/src/compiled/webpack-sources3/index.js +++ b/packages/next/src/compiled/webpack-sources3/index.js @@ -1 +1 @@ -(function(){var e={449:function(e,t,n){"use strict";const s=n(68);const r=n(823);const i=n(296);const u=n(323);const mapToBufferedMap=e=>{if(typeof e!=="object"||!e)return e;const t=Object.assign({},e);if(e.mappings){t.mappings=Buffer.from(e.mappings,"utf-8")}if(e.sourcesContent){t.sourcesContent=e.sourcesContent.map((e=>e&&Buffer.from(e,"utf-8")))}return t};const bufferedMapToMap=e=>{if(typeof e!=="object"||!e)return e;const t=Object.assign({},e);if(e.mappings){t.mappings=e.mappings.toString("utf-8")}if(e.sourcesContent){t.sourcesContent=e.sourcesContent.map((e=>e&&e.toString("utf-8")))}return t};class CachedSource extends s{constructor(e,t){super();this._source=e;this._cachedSourceType=t?t.source:undefined;this._cachedSource=undefined;this._cachedBuffer=t?t.buffer:undefined;this._cachedSize=t?t.size:undefined;this._cachedMaps=t?t.maps:new Map;this._cachedHashUpdate=t?t.hash:undefined}getCachedData(){const e=new Map;for(const t of this._cachedMaps){let n=t[1];if(n.bufferedMap===undefined){n.bufferedMap=mapToBufferedMap(this._getMapFromCacheEntry(n))}e.set(t[0],{map:undefined,bufferedMap:n.bufferedMap})}if(this._cachedSource){this.buffer()}return{buffer:this._cachedBuffer,source:this._cachedSourceType!==undefined?this._cachedSourceType:typeof this._cachedSource==="string"?true:Buffer.isBuffer(this._cachedSource)?false:undefined,size:this._cachedSize,maps:e,hash:this._cachedHashUpdate}}originalLazy(){return this._source}original(){if(typeof this._source==="function")this._source=this._source();return this._source}source(){const e=this._getCachedSource();if(e!==undefined)return e;return this._cachedSource=this.original().source()}_getMapFromCacheEntry(e){if(e.map!==undefined){return e.map}else if(e.bufferedMap!==undefined){return e.map=bufferedMapToMap(e.bufferedMap)}}_getCachedSource(){if(this._cachedSource!==undefined)return this._cachedSource;if(this._cachedBuffer&&this._cachedSourceType!==undefined){return this._cachedSource=this._cachedSourceType?this._cachedBuffer.toString("utf-8"):this._cachedBuffer}}buffer(){if(this._cachedBuffer!==undefined)return this._cachedBuffer;if(this._cachedSource!==undefined){if(Buffer.isBuffer(this._cachedSource)){return this._cachedBuffer=this._cachedSource}return this._cachedBuffer=Buffer.from(this._cachedSource,"utf-8")}if(typeof this.original().buffer==="function"){return this._cachedBuffer=this.original().buffer()}const e=this.source();if(Buffer.isBuffer(e)){return this._cachedBuffer=e}return this._cachedBuffer=Buffer.from(e,"utf-8")}size(){if(this._cachedSize!==undefined)return this._cachedSize;if(this._cachedBuffer!==undefined){return this._cachedSize=this._cachedBuffer.length}const e=this._getCachedSource();if(e!==undefined){return this._cachedSize=Buffer.byteLength(e)}return this._cachedSize=this.original().size()}sourceAndMap(e){const t=e?JSON.stringify(e):"{}";const n=this._cachedMaps.get(t);if(n!==undefined){const e=this._getMapFromCacheEntry(n);return{source:this.source(),map:e}}let s=this._getCachedSource();let r;if(s!==undefined){r=this.original().map(e)}else{const t=this.original().sourceAndMap(e);s=t.source;r=t.map;this._cachedSource=s}this._cachedMaps.set(t,{map:r,bufferedMap:undefined});return{source:s,map:r}}streamChunks(e,t,n,s){const o=e?JSON.stringify(e):"{}";if(this._cachedMaps.has(o)&&(this._cachedBuffer!==undefined||this._cachedSource!==undefined)){const{source:u,map:o}=this.sourceAndMap(e);if(o){return r(u,o,t,n,s,!!(e&&e.finalSource),true)}else{return i(u,t,n,s,!!(e&&e.finalSource))}}const{result:f,source:c,map:a}=u(this.original(),e,t,n,s);this._cachedSource=c;this._cachedMaps.set(o,{map:a,bufferedMap:undefined});return f}map(e){const t=e?JSON.stringify(e):"{}";const n=this._cachedMaps.get(t);if(n!==undefined){return this._getMapFromCacheEntry(n)}const s=this.original().map(e);this._cachedMaps.set(t,{map:s,bufferedMap:undefined});return s}updateHash(e){if(this._cachedHashUpdate!==undefined){for(const t of this._cachedHashUpdate)e.update(t);return}const t=[];let n=undefined;const s={update:e=>{if(typeof e==="string"&&e.length<10240){if(n===undefined){n=e}else{n+=e;if(n.length>102400){t.push(Buffer.from(n));n=undefined}}}else{if(n!==undefined){t.push(Buffer.from(n));n=undefined}t.push(e)}}};this.original().updateHash(s);if(n!==undefined){t.push(Buffer.from(n))}for(const n of t)e.update(n);this._cachedHashUpdate=t}}e.exports=CachedSource},160:function(e,t,n){"use strict";const s=n(68);class CompatSource extends s{static from(e){return e instanceof s?e:new CompatSource(e)}constructor(e){super();this._sourceLike=e}source(){return this._sourceLike.source()}buffer(){if(typeof this._sourceLike.buffer==="function"){return this._sourceLike.buffer()}return super.buffer()}size(){if(typeof this._sourceLike.size==="function"){return this._sourceLike.size()}return super.size()}map(e){if(typeof this._sourceLike.map==="function"){return this._sourceLike.map(e)}return super.map(e)}sourceAndMap(e){if(typeof this._sourceLike.sourceAndMap==="function"){return this._sourceLike.sourceAndMap(e)}return super.sourceAndMap(e)}updateHash(e){if(typeof this._sourceLike.updateHash==="function"){return this._sourceLike.updateHash(e)}if(typeof this._sourceLike.map==="function"){throw new Error("A Source-like object with a 'map' method must also provide an 'updateHash' method")}e.update(this.buffer())}}e.exports=CompatSource},23:function(e,t,n){"use strict";const s=n(68);const r=n(188);const i=n(467);const{getMap:u,getSourceAndMap:o}=n(940);const f=new WeakSet;class ConcatSource extends s{constructor(){super();this._children=[];for(let e=0;e{const g=n+r;const S=n===1?s+u:s;if(h){if(n!==1||s!==0){t(undefined,r+1,u,-1,-1,-1,-1)}h=false}const m=i<0||i>=d.length?-1:d[i];const A=l<0||l>=p.length?-1:p[l];_=m<0?0:n;if(c){if(e!==undefined)a+=e;if(m>=0){t(undefined,g,S,m,o,f,A)}}else{if(m<0){t(e,g,S,-1,-1,-1,-1)}else{t(e,g,S,m,o,f,A)}}}),((e,t,s)=>{let r=o.get(t);if(r===undefined){o.set(t,r=o.size);n(r,t,s)}d[e]=r}),((e,t)=>{let n=f.get(t);if(n===undefined){f.set(t,n=f.size);s(n,t)}p[e]=n}));if(m!==undefined)a+=m;if(h){if(g!==1||S!==0){t(undefined,r+1,u,-1,-1,-1,-1);h=false}}if(g>1){u=S}else{u+=S}h=h||c&&_===g;r+=g-1}return{generatedLine:r+1,generatedColumn:u,source:c?a:undefined}}updateHash(e){if(!this._isOptimized)this._optimize();e.update("ConcatSource");for(const t of this._children){t.updateHash(e)}}_optimize(){const e=[];let t=undefined;let n=undefined;const addStringToRawSources=e=>{if(n===undefined){n=e}else if(Array.isArray(n)){n.push(e)}else{n=[typeof n==="string"?n:n.source(),e]}};const addSourceToRawSources=e=>{if(n===undefined){n=e}else if(Array.isArray(n)){n.push(e.source())}else{n=[typeof n==="string"?n:n.source(),e.source()]}};const mergeRawSources=()=>{if(Array.isArray(n)){const t=new r(n.join(""));f.add(t);e.push(t)}else if(typeof n==="string"){const t=new r(n);f.add(t);e.push(t)}else{e.push(n)}};for(const s of this._children){if(typeof s==="string"){if(t===undefined){t=s}else{t+=s}}else{if(t!==undefined){addStringToRawSources(t);t=undefined}if(f.has(s)){addSourceToRawSources(s)}else{if(n!==undefined){mergeRawSources();n=undefined}e.push(s)}}}if(t!==undefined){addStringToRawSources(t)}if(n!==undefined){mergeRawSources()}this._children=e;this._isOptimized=true}}e.exports=ConcatSource},326:function(e,t,n){"use strict";const{getMap:s,getSourceAndMap:r}=n(940);const i=n(144);const u=n(865);const o=n(68);const f=n(289);class OriginalSource extends o{constructor(e,t){super();const n=Buffer.isBuffer(e);this._value=n?undefined:e;this._valueAsBuffer=n?e:undefined;this._name=t}getName(){return this._name}source(){if(this._value===undefined){this._value=this._valueAsBuffer.toString("utf-8")}return this._value}buffer(){if(this._valueAsBuffer===undefined){this._valueAsBuffer=Buffer.from(this._value,"utf-8")}return this._valueAsBuffer}map(e){return s(this,e)}sourceAndMap(e){return r(this,e)}streamChunks(e,t,n,s){if(this._value===undefined){this._value=this._valueAsBuffer.toString("utf-8")}n(0,this._name,this._value);const r=!!(e&&e.finalSource);if(!e||e.columns!==false){const e=f(this._value);let n=1;let s=0;if(e!==null){for(const i of e){const e=i.endsWith("\n");if(e&&i.length===1){if(!r)t(i,n,s,-1,-1,-1,-1)}else{const e=r?undefined:i;t(e,n,s,0,n,s,-1)}if(e){n++;s=0}else{s+=i.length}}}return{generatedLine:n,generatedColumn:s,source:r?this._value:undefined}}else if(r){const e=u(this._value);const{generatedLine:n,generatedColumn:s}=e;if(s===0){for(let e=1;e{if(s!==0){s+=u}else if(e!==undefined){if(o||i<0){e=r+e}else if(u>0){t(r,n,s,-1,-1,-1,-1);s+=u}}else if(!o){s+=u}t(e,n,s,i,f,c,a)}),n,s);return{generatedLine:c,generatedColumn:a===0?0:u+a,source:h!==undefined?r+h.replace(f,"\n"+r):undefined}}updateHash(e){e.update("PrefixSource");this._source.updateHash(e);e.update(this._prefix)}}e.exports=PrefixSource},188:function(e,t,n){"use strict";const s=n(296);const r=n(68);class RawSource extends r{constructor(e,t=false){super();const n=Buffer.isBuffer(e);if(!n&&typeof e!=="string"){throw new TypeError("argument 'value' must be either string of Buffer")}this._valueIsBuffer=!t&&n;this._value=t&&n?undefined:e;this._valueAsBuffer=n?e:undefined;this._valueAsString=n?undefined:e}isBuffer(){return this._valueIsBuffer}source(){if(this._value===undefined){this._value=this._valueAsBuffer.toString("utf-8")}return this._value}buffer(){if(this._valueAsBuffer===undefined){this._valueAsBuffer=Buffer.from(this._value,"utf-8")}return this._valueAsBuffer}map(e){return null}streamChunks(e,t,n,r){if(this._value===undefined){this._value=Buffer.from(this._valueAsBuffer,"utf-8")}if(this._valueAsString===undefined){this._valueAsString=typeof this._value==="string"?this._value:this._value.toString("utf-8")}return s(this._valueAsString,t,n,r,!!(e&&e.finalSource))}updateHash(e){if(this._valueAsBuffer===undefined){this._valueAsBuffer=Buffer.from(this._value,"utf-8")}e.update("RawSource");e.update(this._valueAsBuffer)}}e.exports=RawSource},633:function(e,t,n){"use strict";const{getMap:s,getSourceAndMap:r}=n(940);const i=n(467);const u=n(68);const o=n(144);const f=typeof process==="object"&&process.versions&&typeof process.versions.v8==="string"&&!/^[0-6]\./.test(process.versions.v8);const c=536870912;class Replacement{constructor(e,t,n,s){this.start=e;this.end=t;this.content=n;this.name=s;if(!f){this.index=-1}}}class ReplaceSource extends u{constructor(e,t){super();this._source=e;this._name=t;this._replacements=[];this._isSorted=true}getName(){return this._name}getReplacements(){this._sortReplacements();return this._replacements}replace(e,t,n,s){if(typeof n!=="string")throw new Error("insertion must be a string, but is a "+typeof n);this._replacements.push(new Replacement(e,t,n,s));this._isSorted=false}insert(e,t,n){if(typeof t!=="string")throw new Error("insertion must be a string, but is a "+typeof t+": "+t);this._replacements.push(new Replacement(e,e-1,t,n));this._isSorted=false}source(){if(this._replacements.length===0){return this._source.source()}let e=this._source.source();let t=0;const n=[];this._sortReplacements();for(const s of this._replacements){const r=Math.floor(s.start);const i=Math.floor(s.end+1);if(te.index=t));this._replacements.sort((function(e,t){const n=e.start-t.start;if(n!==0)return n;const s=e.end-t.end;if(s!==0)return s;return e.index-t.index}))}this._isSorted=true}streamChunks(e,t,n,s){this._sortReplacements();const r=this._replacements;let u=0;let f=0;let a=-1;let h=f{let r=e<_.length?_[e]:undefined;if(r===undefined)return false;if(typeof r==="string"){r=o(r);_[e]=r}const i=t<=r.length?r[t-1]:null;if(i===null)return false;return i.slice(n,n+s.length)===s};let{generatedLine:m,generatedColumn:A}=i(this._source,Object.assign({},e,{finalSource:false}),((e,n,i,_,m,A,M)=>{let B=0;let v=u+e.length;if(a>u){if(a>=v){const t=n+l;if(e.endsWith("\n")){l--;if(p===t){d+=i}}else if(p===t){d-=e.length}else{d=-e.length;p=t}u=v;return}B=a-u;if(checkOriginalContent(_,m,A,e.slice(0,B))){A+=B}u+=B;const t=n+l;if(p===t){d-=B}else{d=-B;p=t}i+=B}if(hu){const n=h-u;const s=e.slice(B,B+n);t(s,C,i+(C===p?d:0),_,m,A,M<0||M>=S.length?-1:S[M]);i+=n;B+=n;u=h;if(checkOriginalContent(_,m,A,s)){A+=s.length}}const{content:b,name:O}=r[f];let y=o(b);let w=M;if(_>=0&&O){let e=g.get(O);if(e===undefined){e=g.size;g.set(O,e);s(e,O)}w=e}for(let e=0;e0){if(a>=v){let t=n+l;if(e.endsWith("\n")){l--;if(p===t){d+=i}}else if(p===t){d-=e.length-B}else{d=B-e.length;p=t}u=v;return}const t=n+l;if(checkOriginalContent(_,m,A,e.slice(B,B+x))){A+=x}B+=x;u+=x;if(p===t){d-=x}else{d=-x;p=t}i+=x}}while(h{while(_.length{let n=g.get(t);if(n===undefined){n=g.size;g.set(t,n);s(n,t)}S[e]=n}));let M="";for(;f{const t=e&&e.columns===false;return t?createLinesOnlyMappingsSerializer():createFullMappingsSerializer()};const createFullMappingsSerializer=()=>{let e=1;let s=0;let r=0;let i=1;let u=0;let o=0;let f=false;let c=false;let a=true;return(h,l,d,p,_,g)=>{if(f&&e===h){if(d===r&&p===i&&_===u&&!c&&g<0){return""}}else{if(d<0){return""}}let S;if(e{const s=e>>>31&1;const r=e>>31;const i=e+r^r;let u=i<<1|s;for(;;){const e=u&31;u>>=5;if(u===0){S+=t[e];break}else{S+=t[e|n]}}};writeValue(l-s);s=l;if(d>=0){f=true;if(d===r){S+="A"}else{writeValue(d-r);r=d}writeValue(p-i);i=p;if(_===u){S+="A"}else{writeValue(_-u);u=_}if(g>=0){writeValue(g-o);o=g;c=true}else{c=false}}else{f=false}return S}};const createLinesOnlyMappingsSerializer=()=>{let e=0;let s=1;let r=0;let i=1;return(u,o,f,c,a,h)=>{if(f<0){return""}if(e===u){return""}let l;const writeValue=e=>{const s=e>>>31&1;const r=e>>31;const i=e+r^r;let u=i<<1|s;for(;;){const e=u&31;u>>=5;if(u===0){l+=t[e];break}else{l+=t[e|n]}}};e=u;if(u===s+1){s=u;if(f===r){r=f;if(c===i+1){i=c;return";AACA"}else{l=";AA";writeValue(c-i);i=c;return l+"A"}}else{l=";A";writeValue(f-r);r=f;writeValue(c-i);i=c;return l+"A"}}else{l=";".repeat(u-s);s=u;if(f===r){r=f;if(c===i+1){i=c;return l+"AACA"}else{l+="AA";writeValue(c-i);i=c;return l+"A"}}else{l+="A";writeValue(f-r);r=f;writeValue(c-i);i=c;return l+"A"}}}};e.exports=createMappingsSerializer},940:function(e,t,n){"use strict";const s=n(398);t.getSourceAndMap=(e,t)=>{let n="";let r="";let i=[];let u=[];let o=[];const f=s(t);const{source:c}=e.streamChunks(Object.assign({},t,{finalSource:true}),((e,t,s,i,u,o,c)=>{if(e!==undefined)n+=e;r+=f(t,s,i,u,o,c)}),((e,t,n)=>{while(i.length{while(o.length0?{version:3,file:"x",mappings:r,sources:i,sourcesContent:u.length>0?u:undefined,names:o}:null}};t.getMap=(e,t)=>{let n="";let r=[];let i=[];let u=[];const o=s(t);e.streamChunks(Object.assign({},t,{source:false,finalSource:true}),((e,t,s,r,i,u,f)=>{n+=o(t,s,r,i,u,f)}),((e,t,n)=>{while(r.length{while(u.length0?{version:3,file:"x",mappings:n,sources:r,sourcesContent:i.length>0?i:undefined,names:u}:null}},865:function(e){"use strict";const t="\n".charCodeAt(0);const getGeneratedSourceInfo=e=>{if(e===undefined){return{}}const n=e.lastIndexOf("\n");if(n===-1){return{generatedLine:1,generatedColumn:e.length,source:e}}let s=2;for(let r=0;r{if(t<0)return null;const{sourceRoot:n,sources:s}=e;const r=s[t];if(!n)return r;if(n.endsWith("/"))return n+r;return n+"/"+r};e.exports=getSource},298:function(e){"use strict";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const n=32;const s=64;const r=s|1;const i=s|2;const u=31;const o=new Uint8Array("z".charCodeAt(0)+1);{o.fill(i);for(let e=0;e{const i=new Uint32Array([0,0,1,0,0]);let c=0;let a=0;let h=0;let l=1;let d=-1;for(let p=0;pf)continue;const g=o[_];if((g&s)!==0){if(i[0]>d){if(c===1){t(l,i[0],-1,-1,-1,-1)}else if(c===4){t(l,i[0],i[1],i[2],i[3],-1)}else if(c===5){t(l,i[0],i[1],i[2],i[3],i[4])}d=i[0]}c=0;if(g===r){l++;i[0]=0;d=-1}}else if((g&n)===0){a|=g<>1):a>>1;i[c++]+=e;h=0;a=0}else{a|=(g&u)<{const t=[];const n=e.length;let s=0;for(;s{const t=e.length;if(t===0)return null;const n=[];let s=0;for(;s=t)break e;n=e.charCodeAt(s)}while(n===59||n===32||n===123||n===125||n===13||n===9){if(++s>=t)break e;n=e.charCodeAt(s)}if(n===10){s++}}n.push(e.slice(r,s))}return n};e.exports=splitIntoPotentialTokens},323:function(e,t,n){"use strict";const s=n(398);const r=n(467);const streamAndGetSourceAndMap=(e,t,n,i,u)=>{let o="";let f="";let c=[];let a=[];let h=[];const l=s(Object.assign({},t,{columns:true}));const d=!!(t&&t.finalSource);const{generatedLine:p,generatedColumn:_,source:g}=r(e,t,((e,t,s,r,i,u,c)=>{if(e!==undefined)o+=e;f+=l(t,s,r,i,u,c);return n(d?undefined:e,t,s,r,i,u,c)}),((e,t,n)=>{while(c.length{while(h.length0?{version:3,file:"x",mappings:f,sources:c,sourcesContent:a.length>0?a:undefined,names:h}:null}};e.exports=streamAndGetSourceAndMap},467:function(e,t,n){"use strict";const s=n(296);const r=n(823);e.exports=(e,t,n,i,u)=>{if(typeof e.streamChunks==="function"){return e.streamChunks(t,n,i,u)}else{const o=e.sourceAndMap(t);if(o.map){return r(o.source,o.map,n,i,u,!!(t&&t.finalSource),!!(t&&t.columns!==false))}else{return s(o.source,n,i,u,!!(t&&t.finalSource))}}}},701:function(e,t,n){"use strict";const s=n(823);const r=n(144);const streamChunksOfCombinedSourceMap=(e,t,n,i,u,o,f,c,a,h,l)=>{let d=new Map;let p=new Map;const _=[];const g=[];const S=[];let m=-2;const A=[];const M=[];const B=[];const v=[];const C=[];const b=[];const O=[];const findInnerMapping=(e,t)=>{if(e>O.length)return-1;const{mappingsData:n}=O[e-1];let s=0;let r=n.length/5;while(s>1;if(n[e*5]<=t){s=e+1}else{r=e}}if(s===0)return-1;return s-1};return s(e,t,((t,s,u,h,l,y,w)=>{if(h===m){const m=findInnerMapping(l,y);if(m!==-1){const{chunks:e,mappingsData:n}=O[l-1];const i=m*5;const o=n[i+1];const h=n[i+2];let _=n[i+3];let x=n[i+4];if(o>=0){const l=e[m];const O=n[i];const z=y-O;if(z>0){let e=o=0){L=x=0){let e=v[o];if(e===undefined){const t=B[o];e=t?r(t):null;v[o]=e}if(e!==null){const t=S[w];const n=h<=e.length?e[h-1].slice(_,_+t.length):"";if(t===n){L=w=_.length?-1:_[h];if(x<0){f(t,s,u,-1,-1,-1,-1)}else{let e=-1;if(w>=0&&w{if(t===n){m=e;if(i!==undefined)r=i;else i=r;_[e]=-2;s(r,u,((e,t,n,s,r,i,u)=>{while(O.length{B[e]=n;v[e]=undefined;A[e]=-2;M[e]=[t,n]}),((e,t)=>{C[e]=-2;b[e]=t}),false,l)}else{let n=d.get(t);if(n===undefined){d.set(t,n=d.size);c(n,t,r)}_[e]=n}}),((e,t)=>{g[e]=-2;S[e]=t}),h,l)};e.exports=streamChunksOfCombinedSourceMap},296:function(e,t,n){"use strict";const s=n(865);const r=n(144);const streamChunksOfRawSource=(e,t,n,s)=>{let i=1;const u=r(e);let o;for(o of u){t(o,i,0,-1,-1,-1,-1);i++}return u.length===0||o.endsWith("\n")?{generatedLine:u.length+1,generatedColumn:0}:{generatedLine:u.length,generatedColumn:o.length}};e.exports=(e,t,n,r,i)=>i?s(e):streamChunksOfRawSource(e,t,n,r)},823:function(e,t,n){"use strict";const s=n(865);const r=n(577);const i=n(298);const u=n(144);const streamChunksOfSourceMapFull=(e,t,n,s,o)=>{const f=u(e);if(f.length===0){return{generatedLine:1,generatedColumn:0}}const{sources:c,sourcesContent:a,names:h,mappings:l}=t;for(let e=0;e{if(A&&S<=f.length){let s;const r=S;const i=m;const u=f[S-1];if(e!==S){s=u.slice(m);S++;m=0}else{s=u.slice(m,t);m=t}if(s){n(s,r,i,M,B,v,C)}A=false}if(e>S&&m>0){if(S<=f.length){const e=f[S-1].slice(m);n(e,S,m,-1,-1,-1,-1)}S++;m=0}while(e>S){if(S<=f.length){n(f[S-1],S,0,-1,-1,-1,-1)}S++}if(t>m){if(S<=f.length){const e=f[S-1].slice(m,t);n(e,S,m,-1,-1,-1,-1)}m=t}if(s>=0&&(e<_||e===_&&t{const f=u(e);if(f.length===0){return{generatedLine:1,generatedColumn:0}}const{sources:c,sourcesContent:a,mappings:h}=t;for(let e=0;e{if(s<0||ef.length){return}while(e>l){if(l<=f.length){n(f[l-1],l,0,-1,-1,-1,-1)}l++}if(e<=f.length){n(f[e-1],e,0,s,r,i,-1);l++}};i(h,onMapping);for(;l<=f.length;l++){n(f[l-1],l,0,-1,-1,-1,-1)}const d=f[f.length-1];const p=d.endsWith("\n");const _=p?f.length+1:f.length;const g=p?0:d.length;return{generatedLine:_,generatedColumn:g}};const streamChunksOfSourceMapFinal=(e,t,n,u,o)=>{const f=s(e);const{generatedLine:c,generatedColumn:a}=f;if(c===1&&a===0)return f;const{sources:h,sourcesContent:l,names:d,mappings:p}=t;for(let e=0;e{if(e>=c&&(t>=a||e>c)){return}if(s>=0){n(undefined,e,t,s,r,i,u);_=e}else if(_===e){n(undefined,e,t,-1,-1,-1,-1);_=0}};i(p,onMapping);return f};const streamChunksOfSourceMapLinesFinal=(e,t,n,u,o)=>{const f=s(e);const{generatedLine:c,generatedColumn:a}=f;if(c===1&&a===0){return{generatedLine:1,generatedColumn:0}}const{sources:h,sourcesContent:l,mappings:d}=t;for(let e=0;e{if(s>=0&&_<=e&&e<=p){n(undefined,e,0,s,r,i,-1);_=e+1}};i(d,onMapping);return f};e.exports=(e,t,n,s,r,i,u)=>{if(u){return i?streamChunksOfSourceMapFinal(e,t,n,s,r):streamChunksOfSourceMapFull(e,t,n,s,r)}else{return i?streamChunksOfSourceMapLinesFinal(e,t,n,s,r):streamChunksOfSourceMapLinesFull(e,t,n,s,r)}}},591:function(e,t,n){const defineExport=(e,n)=>{let s;Object.defineProperty(t,e,{get:()=>{if(n!==undefined){s=n();n=undefined}return s},configurable:true})};defineExport("Source",(()=>n(68)));defineExport("RawSource",(()=>n(188)));defineExport("OriginalSource",(()=>n(326)));defineExport("SourceMapSource",(()=>n(753)));defineExport("CachedSource",(()=>n(449)));defineExport("ConcatSource",(()=>n(23)));defineExport("ReplaceSource",(()=>n(633)));defineExport("PrefixSource",(()=>n(759)));defineExport("SizeOnlySource",(()=>n(201)));defineExport("CompatSource",(()=>n(160)))}};var t={};function __nccwpck_require__(n){var s=t[n];if(s!==undefined){return s.exports}var r=t[n]={exports:{}};var i=true;try{e[n](r,r.exports,__nccwpck_require__);i=false}finally{if(i)delete t[n]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(591);module.exports=n})(); \ No newline at end of file +(function(){var e={747:function(e,t,n){"use strict";const s=n(462);const r=n(17);const i=n(73);const u=n(976);const mapToBufferedMap=e=>{if(typeof e!=="object"||!e)return e;const t=Object.assign({},e);if(e.mappings){t.mappings=Buffer.from(e.mappings,"utf-8")}if(e.sourcesContent){t.sourcesContent=e.sourcesContent.map((e=>e&&Buffer.from(e,"utf-8")))}return t};const bufferedMapToMap=e=>{if(typeof e!=="object"||!e)return e;const t=Object.assign({},e);if(e.mappings){t.mappings=e.mappings.toString("utf-8")}if(e.sourcesContent){t.sourcesContent=e.sourcesContent.map((e=>e&&e.toString("utf-8")))}return t};class CachedSource extends s{constructor(e,t){super();this._source=e;this._cachedSourceType=t?t.source:undefined;this._cachedSource=undefined;this._cachedBuffer=t?t.buffer:undefined;this._cachedSize=t?t.size:undefined;this._cachedMaps=t?t.maps:new Map;this._cachedHashUpdate=t?t.hash:undefined}getCachedData(){const e=new Map;for(const t of this._cachedMaps){let n=t[1];if(n.bufferedMap===undefined){n.bufferedMap=mapToBufferedMap(this._getMapFromCacheEntry(n))}e.set(t[0],{map:undefined,bufferedMap:n.bufferedMap})}if(this._cachedSource){this.buffer()}return{buffer:this._cachedBuffer,source:this._cachedSourceType!==undefined?this._cachedSourceType:typeof this._cachedSource==="string"?true:Buffer.isBuffer(this._cachedSource)?false:undefined,size:this._cachedSize,maps:e,hash:this._cachedHashUpdate}}originalLazy(){return this._source}original(){if(typeof this._source==="function")this._source=this._source();return this._source}source(){const e=this._getCachedSource();if(e!==undefined)return e;return this._cachedSource=this.original().source()}_getMapFromCacheEntry(e){if(e.map!==undefined){return e.map}else if(e.bufferedMap!==undefined){return e.map=bufferedMapToMap(e.bufferedMap)}}_getCachedSource(){if(this._cachedSource!==undefined)return this._cachedSource;if(this._cachedBuffer&&this._cachedSourceType!==undefined){return this._cachedSource=this._cachedSourceType?this._cachedBuffer.toString("utf-8"):this._cachedBuffer}}buffer(){if(this._cachedBuffer!==undefined)return this._cachedBuffer;if(this._cachedSource!==undefined){if(Buffer.isBuffer(this._cachedSource)){return this._cachedBuffer=this._cachedSource}return this._cachedBuffer=Buffer.from(this._cachedSource,"utf-8")}if(typeof this.original().buffer==="function"){return this._cachedBuffer=this.original().buffer()}const e=this.source();if(Buffer.isBuffer(e)){return this._cachedBuffer=e}return this._cachedBuffer=Buffer.from(e,"utf-8")}size(){if(this._cachedSize!==undefined)return this._cachedSize;if(this._cachedBuffer!==undefined){return this._cachedSize=this._cachedBuffer.length}const e=this._getCachedSource();if(e!==undefined){return this._cachedSize=Buffer.byteLength(e)}return this._cachedSize=this.original().size()}sourceAndMap(e){const t=e?JSON.stringify(e):"{}";const n=this._cachedMaps.get(t);if(n!==undefined){const e=this._getMapFromCacheEntry(n);return{source:this.source(),map:e}}let s=this._getCachedSource();let r;if(s!==undefined){r=this.original().map(e)}else{const t=this.original().sourceAndMap(e);s=t.source;r=t.map;this._cachedSource=s}this._cachedMaps.set(t,{map:r,bufferedMap:undefined});return{source:s,map:r}}streamChunks(e,t,n,s){const f=e?JSON.stringify(e):"{}";if(this._cachedMaps.has(f)&&(this._cachedBuffer!==undefined||this._cachedSource!==undefined)){const{source:u,map:f}=this.sourceAndMap(e);if(f){return r(u,f,t,n,s,!!(e&&e.finalSource),true)}else{return i(u,t,n,s,!!(e&&e.finalSource))}}const{result:o,source:c,map:a}=u(this.original(),e,t,n,s);this._cachedSource=c;this._cachedMaps.set(f,{map:a,bufferedMap:undefined});return o}map(e){const t=e?JSON.stringify(e):"{}";const n=this._cachedMaps.get(t);if(n!==undefined){return this._getMapFromCacheEntry(n)}const s=this.original().map(e);this._cachedMaps.set(t,{map:s,bufferedMap:undefined});return s}updateHash(e){if(this._cachedHashUpdate!==undefined){for(const t of this._cachedHashUpdate)e.update(t);return}const t=[];let n=undefined;const s={update:e=>{if(typeof e==="string"&&e.length<10240){if(n===undefined){n=e}else{n+=e;if(n.length>102400){t.push(Buffer.from(n));n=undefined}}}else{if(n!==undefined){t.push(Buffer.from(n));n=undefined}t.push(e)}}};this.original().updateHash(s);if(n!==undefined){t.push(Buffer.from(n))}for(const n of t)e.update(n);this._cachedHashUpdate=t}}e.exports=CachedSource},683:function(e,t,n){"use strict";const s=n(462);class CompatSource extends s{static from(e){return e instanceof s?e:new CompatSource(e)}constructor(e){super();this._sourceLike=e}source(){return this._sourceLike.source()}buffer(){if(typeof this._sourceLike.buffer==="function"){return this._sourceLike.buffer()}return super.buffer()}size(){if(typeof this._sourceLike.size==="function"){return this._sourceLike.size()}return super.size()}map(e){if(typeof this._sourceLike.map==="function"){return this._sourceLike.map(e)}return super.map(e)}sourceAndMap(e){if(typeof this._sourceLike.sourceAndMap==="function"){return this._sourceLike.sourceAndMap(e)}return super.sourceAndMap(e)}updateHash(e){if(typeof this._sourceLike.updateHash==="function"){return this._sourceLike.updateHash(e)}if(typeof this._sourceLike.map==="function"){throw new Error("A Source-like object with a 'map' method must also provide an 'updateHash' method")}e.update(this.buffer())}}e.exports=CompatSource},816:function(e,t,n){"use strict";const s=n(462);const r=n(351);const i=n(718);const{getMap:u,getSourceAndMap:f}=n(754);const o=new WeakSet;class ConcatSource extends s{constructor(){super();this._children=[];for(let e=0;e{const _=n+r;const S=n===1?s+u:s;if(h){if(n!==1||s!==0){t(undefined,r+1,u,-1,-1,-1,-1)}h=false}const m=i<0||i>=d.length?-1:d[i];const A=l<0||l>=p.length?-1:p[l];g=m<0?0:n;if(c){if(e!==undefined)a+=e;if(m>=0){t(undefined,_,S,m,f,o,A)}}else{if(m<0){t(e,_,S,-1,-1,-1,-1)}else{t(e,_,S,m,f,o,A)}}}),((e,t,s)=>{let r=f.get(t);if(r===undefined){f.set(t,r=f.size);n(r,t,s)}d[e]=r}),((e,t)=>{let n=o.get(t);if(n===undefined){o.set(t,n=o.size);s(n,t)}p[e]=n}));if(m!==undefined)a+=m;if(h){if(_!==1||S!==0){t(undefined,r+1,u,-1,-1,-1,-1);h=false}}if(_>1){u=S}else{u+=S}h=h||c&&g===_;r+=_-1}return{generatedLine:r+1,generatedColumn:u,source:c?a:undefined}}updateHash(e){if(!this._isOptimized)this._optimize();e.update("ConcatSource");for(const t of this._children){t.updateHash(e)}}_optimize(){const e=[];let t=undefined;let n=undefined;const addStringToRawSources=e=>{if(n===undefined){n=e}else if(Array.isArray(n)){n.push(e)}else{n=[typeof n==="string"?n:n.source(),e]}};const addSourceToRawSources=e=>{if(n===undefined){n=e}else if(Array.isArray(n)){n.push(e.source())}else{n=[typeof n==="string"?n:n.source(),e.source()]}};const mergeRawSources=()=>{if(Array.isArray(n)){const t=new r(n.join(""));o.add(t);e.push(t)}else if(typeof n==="string"){const t=new r(n);o.add(t);e.push(t)}else{e.push(n)}};for(const s of this._children){if(typeof s==="string"){if(t===undefined){t=s}else{t+=s}}else{if(t!==undefined){addStringToRawSources(t);t=undefined}if(o.has(s)){addSourceToRawSources(s)}else{if(n!==undefined){mergeRawSources();n=undefined}e.push(s)}}}if(t!==undefined){addStringToRawSources(t)}if(n!==undefined){mergeRawSources()}this._children=e;this._isOptimized=true}}e.exports=ConcatSource},573:function(e,t,n){"use strict";const{getMap:s,getSourceAndMap:r}=n(754);const i=n(266);const u=n(316);const f=n(462);const o=n(709);class OriginalSource extends f{constructor(e,t){super();const n=Buffer.isBuffer(e);this._value=n?undefined:e;this._valueAsBuffer=n?e:undefined;this._name=t}getName(){return this._name}source(){if(this._value===undefined){this._value=this._valueAsBuffer.toString("utf-8")}return this._value}buffer(){if(this._valueAsBuffer===undefined){this._valueAsBuffer=Buffer.from(this._value,"utf-8")}return this._valueAsBuffer}map(e){return s(this,e)}sourceAndMap(e){return r(this,e)}streamChunks(e,t,n,s){if(this._value===undefined){this._value=this._valueAsBuffer.toString("utf-8")}n(0,this._name,this._value);const r=!!(e&&e.finalSource);if(!e||e.columns!==false){const e=o(this._value);let n=1;let s=0;if(e!==null){for(const i of e){const e=i.endsWith("\n");if(e&&i.length===1){if(!r)t(i,n,s,-1,-1,-1,-1)}else{const e=r?undefined:i;t(e,n,s,0,n,s,-1)}if(e){n++;s=0}else{s+=i.length}}}return{generatedLine:n,generatedColumn:s,source:r?this._value:undefined}}else if(r){const e=u(this._value);const{generatedLine:n,generatedColumn:s}=e;if(s===0){for(let e=1;e{if(s!==0){s+=u}else if(e!==undefined){if(f||i<0){e=r+e}else if(u>0){t(r,n,s,-1,-1,-1,-1);s+=u}}else if(!f){s+=u}t(e,n,s,i,o,c,a)}),n,s);return{generatedLine:c,generatedColumn:a===0?0:u+a,source:h!==undefined?r+h.replace(o,"\n"+r):undefined}}updateHash(e){e.update("PrefixSource");this._source.updateHash(e);e.update(this._prefix)}}e.exports=PrefixSource},351:function(e,t,n){"use strict";const s=n(73);const{internString:r,isDualStringBufferCachingEnabled:i}=n(912);const u=n(462);class RawSource extends u{constructor(e,t=false){super();const n=Buffer.isBuffer(e);if(!n&&typeof e!=="string"){throw new TypeError("argument 'value' must be either string of Buffer")}this._valueIsBuffer=!t&&n;this._value=t&&n?undefined:typeof e==="string"?r(e):e;this._valueAsBuffer=n?e:undefined;this._valueAsString=n?undefined:r(e)}isBuffer(){return this._valueIsBuffer}source(){if(this._value===undefined){const e=r(this._valueAsBuffer.toString("utf-8"));if(i()){this._value=e}return e}return this._value}buffer(){if(this._valueAsBuffer===undefined){const e=Buffer.from(this._value,"utf-8");if(i()){this._valueAsBuffer=e}return e}return this._valueAsBuffer}map(e){return null}streamChunks(e,t,n,u){if(this._value===undefined&&i()){this._value=Buffer.from(this._valueAsBuffer,"utf-8")}let f=this._valueAsString;if(f===undefined){f=typeof this._value==="string"?this._value:r(this._value.toString("utf-8"));if(i()){this._valueAsString=f}}return s(f,t,n,u,!!(e&&e.finalSource))}updateHash(e){e.update("RawSource");e.update(this.buffer())}}e.exports=RawSource},742:function(e,t,n){"use strict";const{getMap:s,getSourceAndMap:r}=n(754);const i=n(718);const u=n(462);const f=n(266);const o=typeof process==="object"&&process.versions&&typeof process.versions.v8==="string"&&!/^[0-6]\./.test(process.versions.v8);const c=536870912;class Replacement{constructor(e,t,n,s){this.start=e;this.end=t;this.content=n;this.name=s;if(!o){this.index=-1}}}class ReplaceSource extends u{constructor(e,t){super();this._source=e;this._name=t;this._replacements=[];this._isSorted=true}getName(){return this._name}getReplacements(){this._sortReplacements();return this._replacements}replace(e,t,n,s){if(typeof n!=="string")throw new Error("insertion must be a string, but is a "+typeof n);this._replacements.push(new Replacement(e,t,n,s));this._isSorted=false}insert(e,t,n){if(typeof t!=="string")throw new Error("insertion must be a string, but is a "+typeof t+": "+t);this._replacements.push(new Replacement(e,e-1,t,n));this._isSorted=false}source(){if(this._replacements.length===0){return this._source.source()}let e=this._source.source();let t=0;const n=[];this._sortReplacements();for(const s of this._replacements){const r=Math.floor(s.start);const i=Math.floor(s.end+1);if(te.index=t));this._replacements.sort((function(e,t){const n=e.start-t.start;if(n!==0)return n;const s=e.end-t.end;if(s!==0)return s;return e.index-t.index}))}this._isSorted=true}streamChunks(e,t,n,s){this._sortReplacements();const r=this._replacements;let u=0;let o=0;let a=-1;let h=o{let r=e{let B=0;let b=u+e.length;if(a>u){if(a>=b){const t=n+l;if(e.endsWith("\n")){l--;if(p===t){d+=i}}else if(p===t){d-=e.length}else{d=-e.length;p=t}u=b;return}B=a-u;if(checkOriginalContent(g,m,A,e.slice(0,B))){A+=B}u+=B;const t=n+l;if(p===t){d-=B}else{d=-B;p=t}i+=B}if(hu){const n=h-u;const s=e.slice(B,B+n);t(s,C,i+(C===p?d:0),g,m,A,M<0||M>=S.length?-1:S[M]);i+=n;B+=n;u=h;if(checkOriginalContent(g,m,A,s)){A+=s.length}}const{content:v,name:y}=r[o];let O=f(v);let w=M;if(g>=0&&y){let e=_.get(y);if(e===undefined){e=_.size;_.set(y,e);s(e,y)}w=e}for(let e=0;e0){if(a>=b){let t=n+l;if(e.endsWith("\n")){l--;if(p===t){d+=i}}else if(p===t){d-=e.length-B}else{d=B-e.length;p=t}u=b;return}const t=n+l;if(checkOriginalContent(g,m,A,e.slice(B,B+x))){A+=x}B+=x;u+=x;if(p===t){d-=x}else{d=-x;p=t}i+=x}}while(h{while(g.length{let n=_.get(t);if(n===undefined){n=_.size;_.set(t,n);s(n,t)}S[e]=n}));let M="";for(;o{const t=e&&e.columns===false;return t?createLinesOnlyMappingsSerializer():createFullMappingsSerializer()};const createFullMappingsSerializer=()=>{let e=1;let s=0;let r=0;let i=1;let u=0;let f=0;let o=false;let c=false;let a=true;return(h,l,d,p,g,_)=>{if(o&&e===h){if(d===r&&p===i&&g===u&&!c&&_<0){return""}}else{if(d<0){return""}}let S;if(e{const s=e>>>31&1;const r=e>>31;const i=e+r^r;let u=i<<1|s;for(;;){const e=u&31;u>>=5;if(u===0){S+=t[e];break}else{S+=t[e|n]}}};writeValue(l-s);s=l;if(d>=0){o=true;if(d===r){S+="A"}else{writeValue(d-r);r=d}writeValue(p-i);i=p;if(g===u){S+="A"}else{writeValue(g-u);u=g}if(_>=0){writeValue(_-f);f=_;c=true}else{c=false}}else{o=false}return S}};const createLinesOnlyMappingsSerializer=()=>{let e=0;let s=1;let r=0;let i=1;return(u,f,o,c,a,h)=>{if(o<0){return""}if(e===u){return""}let l;const writeValue=e=>{const s=e>>>31&1;const r=e>>31;const i=e+r^r;let u=i<<1|s;for(;;){const e=u&31;u>>=5;if(u===0){l+=t[e];break}else{l+=t[e|n]}}};e=u;if(u===s+1){s=u;if(o===r){r=o;if(c===i+1){i=c;return";AACA"}else{l=";AA";writeValue(c-i);i=c;return l+"A"}}else{l=";A";writeValue(o-r);r=o;writeValue(c-i);i=c;return l+"A"}}else{l=";".repeat(u-s);s=u;if(o===r){r=o;if(c===i+1){i=c;return l+"AACA"}else{l+="AA";writeValue(c-i);i=c;return l+"A"}}else{l+="A";writeValue(o-r);r=o;writeValue(c-i);i=c;return l+"A"}}}};e.exports=createMappingsSerializer},754:function(e,t,n){"use strict";const s=n(139);t.getSourceAndMap=(e,t)=>{let n="";let r="";let i=[];let u=[];let f=[];const o=s(t);const{source:c}=e.streamChunks(Object.assign({},t,{finalSource:true}),((e,t,s,i,u,f,c)=>{if(e!==undefined)n+=e;r+=o(t,s,i,u,f,c)}),((e,t,n)=>{while(i.length{while(f.length0?{version:3,file:"x",mappings:r,sources:i,sourcesContent:u.length>0?u:undefined,names:f}:null}};t.getMap=(e,t)=>{let n="";let r=[];let i=[];let u=[];const f=s(t);e.streamChunks(Object.assign({},t,{source:false,finalSource:true}),((e,t,s,r,i,u,o)=>{n+=f(t,s,r,i,u,o)}),((e,t,n)=>{while(r.length{while(u.length0?{version:3,file:"x",mappings:n,sources:r,sourcesContent:i.length>0?i:undefined,names:u}:null}},316:function(e){"use strict";const t="\n".charCodeAt(0);const getGeneratedSourceInfo=e=>{if(e===undefined){return{}}const n=e.lastIndexOf("\n");if(n===-1){return{generatedLine:1,generatedColumn:e.length,source:e}}let s=2;for(let r=0;r{if(t<0)return null;const{sourceRoot:n,sources:s}=e;const r=s[t];if(!n)return r;if(n.endsWith("/"))return n+r;return n+"/"+r};e.exports=getSource},894:function(e){"use strict";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const n=32;const s=64;const r=s|1;const i=s|2;const u=31;const f=new Uint8Array("z".charCodeAt(0)+1);{f.fill(i);for(let e=0;e{const i=new Uint32Array([0,0,1,0,0]);let c=0;let a=0;let h=0;let l=1;let d=-1;for(let p=0;po)continue;const _=f[g];if((_&s)!==0){if(i[0]>d){if(c===1){t(l,i[0],-1,-1,-1,-1)}else if(c===4){t(l,i[0],i[1],i[2],i[3],-1)}else if(c===5){t(l,i[0],i[1],i[2],i[3],i[4])}d=i[0]}c=0;if(_===r){l++;i[0]=0;d=-1}}else if((_&n)===0){a|=_<>1):a>>1;i[c++]+=e;h=0;a=0}else{a|=(_&u)<{const t=[];const n=e.length;let s=0;for(;s{const t=e.length;if(t===0)return null;const n=[];let s=0;for(;s=t)break e;n=e.charCodeAt(s)}while(n===59||n===32||n===123||n===125||n===13||n===9){if(++s>=t)break e;n=e.charCodeAt(s)}if(n===10){s++}}n.push(e.slice(r,s))}return n};e.exports=splitIntoPotentialTokens},976:function(e,t,n){"use strict";const s=n(139);const r=n(718);const streamAndGetSourceAndMap=(e,t,n,i,u)=>{let f="";let o="";let c=[];let a=[];let h=[];const l=s(Object.assign({},t,{columns:true}));const d=!!(t&&t.finalSource);const{generatedLine:p,generatedColumn:g,source:_}=r(e,t,((e,t,s,r,i,u,c)=>{if(e!==undefined)f+=e;o+=l(t,s,r,i,u,c);return n(d?undefined:e,t,s,r,i,u,c)}),((e,t,n)=>{while(c.length{while(h.length0?{version:3,file:"x",mappings:o,sources:c,sourcesContent:a.length>0?a:undefined,names:h}:null}};e.exports=streamAndGetSourceAndMap},718:function(e,t,n){"use strict";const s=n(73);const r=n(17);e.exports=(e,t,n,i,u)=>{if(typeof e.streamChunks==="function"){return e.streamChunks(t,n,i,u)}else{const f=e.sourceAndMap(t);if(f.map){return r(f.source,f.map,n,i,u,!!(t&&t.finalSource),!!(t&&t.columns!==false))}else{return s(f.source,n,i,u,!!(t&&t.finalSource))}}}},673:function(e,t,n){"use strict";const s=n(17);const r=n(266);const streamChunksOfCombinedSourceMap=(e,t,n,i,u,f,o,c,a,h,l)=>{let d=new Map;let p=new Map;const g=[];const _=[];const S=[];let m=-2;const A=[];const M=[];const B=[];const b=[];const C=[];const v=[];const y=[];const findInnerMapping=(e,t)=>{if(e>y.length)return-1;const{mappingsData:n}=y[e-1];let s=0;let r=n.length/5;while(s>1;if(n[e*5]<=t){s=e+1}else{r=e}}if(s===0)return-1;return s-1};return s(e,t,((t,s,u,h,l,O,w)=>{if(h===m){const m=findInnerMapping(l,O);if(m!==-1){const{chunks:e,mappingsData:n}=y[l-1];const i=m*5;const f=n[i+1];const h=n[i+2];let g=n[i+3];let x=n[i+4];if(f>=0){const l=e[m];const y=n[i];const z=O-y;if(z>0){let e=f=0){L=x=0){let e=b[f];if(e===undefined){const t=B[f];e=t?r(t):null;b[f]=e}if(e!==null){const t=S[w];const n=h<=e.length?e[h-1].slice(g,g+t.length):"";if(t===n){L=w<_.length?_[w]:-2;if(L===-2){const e=S[w];if(e){let t=p.get(e);if(t===undefined){p.set(e,t=p.size);a(t,e)}L=t}else{L=-1}_[w]=L}}}}o(t,s,u,k,h,g,L);return}}if(f){o(t,s,u,-1,-1,-1,-1);return}else{if(g[h]===-2){let t=d.get(n);if(t===undefined){d.set(e,t=d.size);c(t,n,i)}g[h]=t}}}const x=h<0||h>=g.length?-1:g[h];if(x<0){o(t,s,u,-1,-1,-1,-1)}else{let e=-1;if(w>=0&&w<_.length){e=_[w];if(e===-2){const t=S[w];let n=p.get(t);if(n===undefined){p.set(t,n=p.size);a(n,t)}e=n;_[w]=e}}o(t,s,u,x,l,O,e)}}),((e,t,r)=>{if(t===n){m=e;if(i!==undefined)r=i;else i=r;g[e]=-2;s(r,u,((e,t,n,s,r,i,u)=>{while(y.length{B[e]=n;b[e]=undefined;A[e]=-2;M[e]=[t,n]}),((e,t)=>{C[e]=-2;v[e]=t}),false,l)}else{let n=d.get(t);if(n===undefined){d.set(t,n=d.size);c(n,t,r)}g[e]=n}}),((e,t)=>{_[e]=-2;S[e]=t}),h,l)};e.exports=streamChunksOfCombinedSourceMap},73:function(e,t,n){"use strict";const s=n(316);const r=n(266);const streamChunksOfRawSource=(e,t,n,s)=>{let i=1;const u=r(e);let f;for(f of u){t(f,i,0,-1,-1,-1,-1);i++}return u.length===0||f.endsWith("\n")?{generatedLine:u.length+1,generatedColumn:0}:{generatedLine:u.length,generatedColumn:f.length}};e.exports=(e,t,n,r,i)=>i?s(e):streamChunksOfRawSource(e,t,n,r)},17:function(e,t,n){"use strict";const s=n(316);const r=n(274);const i=n(894);const u=n(266);const streamChunksOfSourceMapFull=(e,t,n,s,f)=>{const o=u(e);if(o.length===0){return{generatedLine:1,generatedColumn:0}}const{sources:c,sourcesContent:a,names:h,mappings:l}=t;for(let e=0;e{if(A&&S<=o.length){let s;const r=S;const i=m;const u=o[S-1];if(e!==S){s=u.slice(m);S++;m=0}else{s=u.slice(m,t);m=t}if(s){n(s,r,i,M,B,b,C)}A=false}if(e>S&&m>0){if(S<=o.length){const e=o[S-1].slice(m);n(e,S,m,-1,-1,-1,-1)}S++;m=0}while(e>S){if(S<=o.length){n(o[S-1],S,0,-1,-1,-1,-1)}S++}if(t>m){if(S<=o.length){const e=o[S-1].slice(m,t);n(e,S,m,-1,-1,-1,-1)}m=t}if(s>=0&&(e{const o=u(e);if(o.length===0){return{generatedLine:1,generatedColumn:0}}const{sources:c,sourcesContent:a,mappings:h}=t;for(let e=0;e{if(s<0||eo.length){return}while(e>l){if(l<=o.length){n(o[l-1],l,0,-1,-1,-1,-1)}l++}if(e<=o.length){n(o[e-1],e,0,s,r,i,-1);l++}};i(h,onMapping);for(;l<=o.length;l++){n(o[l-1],l,0,-1,-1,-1,-1)}const d=o[o.length-1];const p=d.endsWith("\n");const g=p?o.length+1:o.length;const _=p?0:d.length;return{generatedLine:g,generatedColumn:_}};const streamChunksOfSourceMapFinal=(e,t,n,u,f)=>{const o=s(e);const{generatedLine:c,generatedColumn:a}=o;if(c===1&&a===0)return o;const{sources:h,sourcesContent:l,names:d,mappings:p}=t;for(let e=0;e{if(e>=c&&(t>=a||e>c)){return}if(s>=0){n(undefined,e,t,s,r,i,u);g=e}else if(g===e){n(undefined,e,t,-1,-1,-1,-1);g=0}};i(p,onMapping);return o};const streamChunksOfSourceMapLinesFinal=(e,t,n,u,f)=>{const o=s(e);const{generatedLine:c,generatedColumn:a}=o;if(c===1&&a===0){return{generatedLine:1,generatedColumn:0}}const{sources:h,sourcesContent:l,mappings:d}=t;for(let e=0;e{if(s>=0&&g<=e&&e<=p){n(undefined,e,0,s,r,i,-1);g=e+1}};i(d,onMapping);return o};e.exports=(e,t,n,s,r,i,u)=>{if(u){return i?streamChunksOfSourceMapFinal(e,t,n,s,r):streamChunksOfSourceMapFull(e,t,n,s,r)}else{return i?streamChunksOfSourceMapLinesFinal(e,t,n,s,r):streamChunksOfSourceMapLinesFull(e,t,n,s,r)}}},912:function(e){"use strict";let t=true;function isDualStringBufferCachingEnabled(){return t}function enableDualStringBufferCaching(){t=true}function disableDualStringBufferCaching(){t=false}const n=new Map;function internString(e){if(!isStringInterningEnabled()||!e||typeof e!=="string"){return e}let t=n.get(e);if(t===undefined){t=e;n.set(e,t)}return t}let s=0;function isStringInterningEnabled(){return s>0}function enableStringInterning(){s++}function disableStringInterning(){if(--s<=0){n.clear();s=0}}e.exports={disableDualStringBufferCaching:disableDualStringBufferCaching,disableStringInterning:disableStringInterning,enableDualStringBufferCaching:enableDualStringBufferCaching,enableStringInterning:enableStringInterning,internString:internString,isDualStringBufferCachingEnabled:isDualStringBufferCachingEnabled}},913:function(e,t,n){const defineExport=(e,n)=>{let s;Object.defineProperty(t,e,{get:()=>{if(n!==undefined){s=n();n=undefined}return s},configurable:true})};defineExport("Source",(()=>n(462)));defineExport("RawSource",(()=>n(351)));defineExport("OriginalSource",(()=>n(573)));defineExport("SourceMapSource",(()=>n(582)));defineExport("CachedSource",(()=>n(747)));defineExport("ConcatSource",(()=>n(816)));defineExport("ReplaceSource",(()=>n(742)));defineExport("PrefixSource",(()=>n(86)));defineExport("SizeOnlySource",(()=>n(188)));defineExport("CompatSource",(()=>n(683)));defineExport("stringBufferUtils",(()=>n(912)))}};var t={};function __nccwpck_require__(n){var s=t[n];if(s!==undefined){return s.exports}var r=t[n]={exports:{}};var i=true;try{e[n](r,r.exports,__nccwpck_require__);i=false}finally{if(i)delete t[n]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(913);module.exports=n})(); \ No newline at end of file diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index 5fbcf7832e..462d97f194 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -365,6 +365,7 @@ export const configSchema: zod.ZodType = z.lazy(() => .optional(), typedRoutes: z.boolean().optional(), webpackBuildWorker: z.boolean().optional(), + webpackMemoryOptimizations: z.boolean().optional(), turbo: z .object({ loaders: z.record(z.string(), z.array(zTurboLoaderItem)).optional(), diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 3331a94304..08c554b9bf 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -372,6 +372,15 @@ export interface ExperimentalConfig { */ webpackBuildWorker?: boolean + /** + * Enables optimizations to reduce memory usage in Webpack. This reduces the max size of the heap + * but may increase compile times slightly. + * Valid values are: + * - `false`: Disable Webpack memory optimizations (default). + * - `true`: Enables Webpack memory optimizations. + */ + webpackMemoryOptimizations?: boolean + /** * */ @@ -961,6 +970,7 @@ export const defaultConfig: NextConfig = { process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ), webpackBuildWorker: undefined, + webpackMemoryOptimizations: false, optimizeServerReact: true, useEarlyImport: false, staleTimes: { diff --git a/packages/next/types/$$compiled.internal.d.ts b/packages/next/types/$$compiled.internal.d.ts index 099d00d76d..18d4b9f961 100644 --- a/packages/next/types/$$compiled.internal.d.ts +++ b/packages/next/types/$$compiled.internal.d.ts @@ -450,6 +450,16 @@ declare module 'next/dist/compiled/zod' { declare module 'mini-css-extract-plugin' declare module 'next/dist/compiled/loader-utils3' +declare module 'next/dist/compiled/webpack-sources3' { + interface StringBufferUtils { + disableDualStringBufferCaching: () => boolean + disableStringInterning: () => boolean + enableDualStringBufferCaching: () => boolean + enableStringInterning: () => boolean + } + export let stringBufferUtils: StringBufferUtils +} + declare module 'next/dist/compiled/webpack/webpack' { import type webpackSources from 'webpack-sources1' export function init(): void diff --git a/patches/webpack-sources@3.2.3.patch b/patches/webpack-sources@3.2.3.patch new file mode 100644 index 0000000000..65ca678dd6 --- /dev/null +++ b/patches/webpack-sources@3.2.3.patch @@ -0,0 +1,218 @@ +diff --git a/lib/RawSource.js b/lib/RawSource.js +index 098d317..06e6b8f 100644 +--- a/lib/RawSource.js ++++ b/lib/RawSource.js +@@ -6,6 +6,10 @@ + "use strict"; + + const streamChunksOfRawSource = require("./helpers/streamChunksOfRawSource"); ++const { ++ internString, ++ isDualStringBufferCachingEnabled ++} = require("./helpers/stringBufferUtils"); + const Source = require("./Source"); + + class RawSource extends Source { +@@ -17,8 +21,13 @@ class RawSource extends Source { + } + this._valueIsBuffer = !convertToString && isBuffer; +- this._value = convertToString && isBuffer ? undefined : value; ++ this._value = ++ convertToString && isBuffer ++ ? undefined ++ : typeof value === "string" ++ ? internString(value) ++ : value; + this._valueAsBuffer = isBuffer ? value : undefined; +- this._valueAsString = isBuffer ? undefined : value; ++ this._valueAsString = isBuffer ? undefined : internString(value); + } + + isBuffer() { +@@ -27,14 +36,22 @@ class RawSource extends Source { + + source() { + if (this._value === undefined) { +- this._value = this._valueAsBuffer.toString("utf-8"); ++ const value = internString(this._valueAsBuffer.toString("utf-8")); ++ if (isDualStringBufferCachingEnabled()) { ++ this._value = value; ++ } ++ return value; + } + return this._value; + } + + buffer() { + if (this._valueAsBuffer === undefined) { +- this._valueAsBuffer = Buffer.from(this._value, "utf-8"); ++ const value = Buffer.from(this._value, "utf-8"); ++ if (isDualStringBufferCachingEnabled()) { ++ this._valueAsBuffer = value; ++ } ++ return value; + } + return this._valueAsBuffer; + } +@@ -51,17 +68,21 @@ class RawSource extends Source { + * @returns {void} + */ + streamChunks(options, onChunk, onSource, onName) { +- if (this._value === undefined) { ++ if (this._value === undefined && isDualStringBufferCachingEnabled()) { + this._value = Buffer.from(this._valueAsBuffer, "utf-8"); + } +- if (this._valueAsString === undefined) { +- this._valueAsString = ++ let strValue = this._valueAsString; ++ if (strValue === undefined) { ++ strValue = + typeof this._value === "string" + ? this._value +- : this._value.toString("utf-8"); ++ : internString(this._value.toString("utf-8")); ++ if (isDualStringBufferCachingEnabled()) { ++ this._valueAsString = strValue; ++ } + } + return streamChunksOfRawSource( +- this._valueAsString, ++ strValue, + onChunk, + onSource, + onName, +@@ -70,11 +91,8 @@ class RawSource extends Source { + } + + updateHash(hash) { +- if (this._valueAsBuffer === undefined) { +- this._valueAsBuffer = Buffer.from(this._value, "utf-8"); +- } + hash.update("RawSource"); +- hash.update(this._valueAsBuffer); ++ hash.update(this.buffer()); + } + } + +diff --git a/lib/helpers/stringBufferUtils.js b/lib/helpers/stringBufferUtils.js +new file mode 100644 +index 0000000..3b210f1 +--- /dev/null ++++ b/lib/helpers/stringBufferUtils.js +@@ -0,0 +1,107 @@ ++/* ++ MIT License http://www.opensource.org/licenses/mit-license.php ++ Author Mark Knichel @mknichel ++*/ ++ ++"use strict"; ++ ++let dualStringBufferCaching = true; ++ ++/** ++ * @returns {boolean} Whether the optimization to cache copies of both the ++ * string and buffer version of source content is enabled. This is enabled by ++ * default to improve performance but can consume more memory since values are ++ * stored twice. ++ */ ++function isDualStringBufferCachingEnabled() { ++ return dualStringBufferCaching; ++} ++ ++/** ++ * Enables an optimization to save both string and buffer in memory to avoid ++ * repeat conversions between the two formats when they are requested. This ++ * is enabled by default. This option can improve performance but can consume ++ * additional memory since values are stored twice. ++ * ++ * @returns {void} ++ */ ++function enableDualStringBufferCaching() { ++ dualStringBufferCaching = true; ++} ++ ++/** ++ * Disables the optimization to save both string and buffer in memory. This ++ * may increase performance but should reduce memory usage in the Webpack ++ * compiler. ++ * ++ * @returns {void} ++ */ ++function disableDualStringBufferCaching() { ++ dualStringBufferCaching = false; ++} ++ ++const interningStringMap = new Map(); ++ ++/** ++ * Saves the string in a map to ensure that only one copy of the string exists ++ * in memory at a given time. This is controlled by {@link enableStringInterning} ++ * and {@link disableStringInterning}. Callers are expect to manage the memory ++ * of the interned strings by calling {@link disableStringInterning} after the ++ * compiler no longer needs to save the interned memory. ++ * ++ * @param {string} str A string to be interned. ++ * @returns {string} The original string or a reference to an existing string ++ * of the same value if it has already been interned. ++ */ ++function internString(str) { ++ if (!isStringInterningEnabled() || !str || typeof str !== "string") { ++ return str; ++ } ++ let internedString = interningStringMap.get(str); ++ if (internedString === undefined) { ++ internedString = str; ++ interningStringMap.set(str, internedString); ++ } ++ return internedString; ++} ++ ++let enableStringInterningRefCount = 0; ++ ++function isStringInterningEnabled() { ++ return enableStringInterningRefCount > 0; ++} ++ ++/** ++ * Enables a memory optimization to avoid repeat copies of the same string in ++ * memory by caching a single reference to the string. This can reduce memory ++ * usage if the same string is repeated many times in the compiler, such as ++ * when Webpack layers are used with the same files. ++ * ++ * @returns {void} ++ */ ++function enableStringInterning() { ++ enableStringInterningRefCount++; ++} ++ ++/** ++ * Disables string interning. This should be called to free the memory used by ++ * the interned strings after the compiler no longer needs to reuse the ++ * interned strings such as at the end of the compilation. ++ * ++ * @returns {void} ++ */ ++function disableStringInterning() { ++ if (--enableStringInterningRefCount <= 0) { ++ interningStringMap.clear(); ++ enableStringInterningRefCount = 0; ++ } ++} ++ ++module.exports = { ++ disableDualStringBufferCaching, ++ disableStringInterning, ++ enableDualStringBufferCaching, ++ enableStringInterning, ++ internString, ++ isDualStringBufferCachingEnabled ++}; +diff --git a/lib/index.js b/lib/index.js +index 0c11c2f..86a7234 100644 +--- a/lib/index.js ++++ b/lib/index.js +@@ -28,3 +28,4 @@ defineExport("ReplaceSource", () => require("./ReplaceSource")); + defineExport("PrefixSource", () => require("./PrefixSource")); + defineExport("SizeOnlySource", () => require("./SizeOnlySource")); + defineExport("CompatSource", () => require("./CompatSource")); ++defineExport("stringBufferUtils", () => require("./helpers/stringBufferUtils")); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2214a23a0..9204414de1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,11 @@ overrides: react-is: 19.0.0-rc-81c5ff2e04-20240521 scheduler: 0.25.0-rc-81c5ff2e04-20240521 +patchedDependencies: + webpack-sources@3.2.3: + hash: exarmjd4pnde4auoeobjrmju54 + path: patches/webpack-sources@3.2.3.patch + importers: .: @@ -1449,7 +1454,7 @@ importers: version: /webpack-sources@1.4.3 webpack-sources3: specifier: npm:webpack-sources@3.2.3 - version: /webpack-sources@3.2.3 + version: /webpack-sources@3.2.3(patch_hash=exarmjd4pnde4auoeobjrmju54) ws: specifier: 8.2.3 version: 8.2.3 @@ -25273,9 +25278,10 @@ packages: source-map: 0.6.1 dev: true - /webpack-sources@3.2.3: + /webpack-sources@3.2.3(patch_hash=exarmjd4pnde4auoeobjrmju54): resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} engines: {node: '>=10.13.0'} + patched: true /webpack-stats-plugin@1.1.0: resolution: {integrity: sha512-D0meHk1WYryUbuCnWJuomJFAYvqs0rxv/JFu1XJT1YYpczdgnP1/vz+u/5Z31jrTxT6dJSxCg+TuKTgjhoZS6g==} @@ -25314,7 +25320,7 @@ packages: tapable: 2.2.0 terser-webpack-plugin: 5.3.10(@swc/core@1.5.7)(webpack@5.90.0) watchpack: 2.4.0 - webpack-sources: 3.2.3 + webpack-sources: 3.2.3(patch_hash=exarmjd4pnde4auoeobjrmju54) transitivePeerDependencies: - '@swc/core' - esbuild