2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var next_swc_loader_patch_exports={};__export(next_swc_loader_patch_exports,{default:()=>swcLoader,pitch:()=>pitch,raw:()=>raw});module.exports=__toCommonJS(next_swc_loader_patch_exports);var import_node_path=require("path"),import_swc=require("next/dist/build/swc"),import_options=require("next/dist/build/swc/options"),mockCurrentTraceSpan={traceChild:name=>mockCurrentTraceSpan,traceAsyncFn:async fn=>fn()};async function loaderTransform(parentTrace,source,inputSourceMap){let filename=this.resourcePath,loaderOptions=this.getOptions()||{},{isServer,rootDir,pagesDir,appDir,hasReactRefresh,nextConfig,jsConfig,supportedBrowsers,swcCacheDir,serverComponents,isReactServerLayer}=loaderOptions,isPageFile=filename.startsWith(pagesDir),relativeFilePathFromRoot=(0,import_node_path.relative)(rootDir,filename),programmaticOptions={...(0,import_options.getLoaderSWCOptions)({pagesDir,appDir,filename,isServer,isPageFile,development:this.mode==="development",hasReactRefresh,modularizeImports:nextConfig?.modularizeImports,optimizePackageImports:nextConfig?.experimental?.optimizePackageImports,swcPlugins:nextConfig?.experimental?.swcPlugins,compilerOptions:nextConfig?.compiler,optimizeServerReact:nextConfig?.experimental?.optimizeServerReact,jsConfig,supportedBrowsers,swcCacheDir,relativeFilePathFromRoot,serverComponents,isReactServerLayer}),filename,inputSourceMap:inputSourceMap&&typeof inputSourceMap=="object"?JSON.stringify(inputSourceMap):void 0,sourceMaps:this.sourceMap,inlineSourcesContent:this.sourceMap,sourceFileName:filename};return programmaticOptions.env.bugfixes=!0,programmaticOptions.inputSourceMap||delete programmaticOptions.inputSourceMap,this.mode&&programmaticOptions.jsc&&programmaticOptions.jsc.transform&&programmaticOptions.jsc.transform.react&&!Object.prototype.hasOwnProperty.call(programmaticOptions.jsc.transform.react,"development")&&(programmaticOptions.jsc.transform.react.development=this.mode==="development"),parentTrace.traceChild("next-swc-transform").traceAsyncFn(()=>(0,import_swc.transform)(source,programmaticOptions).then(output=>{if(output.eliminatedPackages&&this.eliminatedPackages)for(let pkg of JSON.parse(output.eliminatedPackages))this.eliminatedPackages.add(pkg);return[output.code,output.map?JSON.parse(output.map):void 0]}))}var EXCLUDED_PATHS=/[\\/](cache[\\/][^\\/]+\.zip[\\/]node_modules|__virtual__)[\\/]/g;function pitch(){let callback=this.async();(async()=>{if(!process.versions.pnp&&!EXCLUDED_PATHS.test(this.resourcePath)&&this.loaders.length-1===this.loaderIndex&&(0,import_node_path.isAbsolute)(this.resourcePath)&&!await(0,import_swc.isWasm)()){let loaderSpan=mockCurrentTraceSpan.traceChild("next-swc-loader");return this.addDependency(this.resourcePath),loaderSpan.traceAsyncFn(()=>loaderTransform.call(this,loaderSpan))}return null})().then(r=>r?callback(null,...r):(callback(),null),callback)}function swcLoader(inputSource,inputSourceMap){let loaderSpan=mockCurrentTraceSpan.traceChild("next-swc-loader"),callback=this.async();loaderSpan.traceAsyncFn(()=>loaderTransform.call(this,loaderSpan,inputSource,inputSourceMap)).then(([transformedSource,outputSourceMap])=>{callback(null,transformedSource,outputSourceMap||inputSourceMap)},err=>{callback(err)})}var raw=!0;0&&(module.exports={pitch,raw});
|