@powerlines/plugin-rolldown 0.7.115 → 0.7.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/powerlines/src/lib/contexts/context.cjs +1 -1
- package/dist/powerlines/src/lib/contexts/context.mjs +1 -1
- package/dist/powerlines/src/types/config.d.cts +12 -0
- package/dist/powerlines/src/types/config.d.mts +12 -1
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../typescript/ts-morph.cjs`),n=require(`../typescript/tsconfig.cjs`),r=require(`../config-file.cjs`),i=require(`../../internal/helpers/resolver.cjs`),a=require(`../../plugin-utils/helpers.cjs`),o=require(`../../plugin-utils/paths.cjs`),s=require(`../entry.cjs`),c=require(`../logger.cjs`),l=require(`../fs/vfs.cjs`),u=require(`../utilities/meta.cjs`);let d=require(`@stryke/convert/to-array`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/helpers/omit`),m=require(`@stryke/type-checks/is-string`),h=require(`@storm-software/config-tools/types`),g=require(`@stryke/fs/get-workspace-root`),_=require(`@stryke/fs/resolve`),v=require(`@stryke/path/append`),y=require(`@stryke/path/replace`),b=require(`@stryke/type-checks/is-set-object`),x=require(`@stryke/type-checks/is-set-string`),S=require(`@stryke/fs/json`),C=require(`@stryke/json/storm-json`),w=require(`@stryke/string-format/title-case`),T=require(`@stryke/fs/exists`),E=require(`@stryke/env/get-env-paths`),D=require(`@stryke/hash/hash-files`),O=require(`@stryke/hash/murmurhash`),k=require(`@stryke/helpers/get-unique`),A=require(`@stryke/http/fetch`),j=require(`@stryke/path/is-parent-path`),M=require(`@stryke/path/is-type`),N=require(`@stryke/path/join`),P=require(`@stryke/type-checks/is-null`),F=require(`@stryke/unique-id/uuid`),I=require(`bundle-require`),L=require(`flat-cache`),R=require(`oxc-parser`),z=require(`undici`);const B=new WeakMap,V=new WeakMap;(0,z.setGlobalDispatcher)(new z.Agent({keepAliveTimeout:1e4}).compose(z.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var H=class e{#e={};#t;#n=null;#r=(0,F.uuid)();#i=(0,F.uuid)();#a=Date.now();#o=null;#s;#c;#l;#u;#d;#f(e={}){return(0,f.default)({variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e},{output:e.framework?{artifactsPath:(0,N.joinPaths)(e.root??this.config.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,N.joinPaths)(e.root??this.config.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`}:{}})}static async from(t,n){let i=new e(await r.loadWorkspaceConfig(t,n.root));await i.withUserConfig(n);let a=await(0,_.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return s.resolveEntriesSync(this,this.#o?this.#o:(0,d.toArray)(this.config.entry))}set entry(e){this.#o=e}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,I.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=l.VirtualFileSystem.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,O.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,O.murmurhash)(this.config,{maxLength:u.CACHE_HASH_LENGTH})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){if(V.has({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`}))return V.get({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`});let e=(0,E.getEnvPaths)({orgId:`storm-software`,appId:this.config?.framework||`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot});return V.set({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`},e),e}get artifactsPath(){return(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,N.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,N.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,N.joinPaths)(this.envPaths.data,`projects`,u.getPrefixedProjectRootHash(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,N.joinPaths)(this.envPaths.cache,`projects`,(0,O.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,v.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,g.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=t.createProgram(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,L.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,L.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,O.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new z.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,A.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new z.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,O.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,R.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,I.match)(r,[e.find]));e&&(r=e.replacement)}else (0,b.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,I.match)(r,this.resolvePatterns)||(0,I.match)(r,this.config.build.noExternal))return;if((0,I.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,I.match)(r,this.config.build.noExternal))return;if((0,I.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){let r=(0,M.isAbsolute)(t)?t:(0,v.appendPath)(t,this.entryPath);return this.entry??=[],this.entry.push({name:n.name,file:r,input:n.input,output:n.output}),this.fs.write(r,e,(0,f.default)((0,p.omit)(n,[`name`]),{meta:{type:`entry`,properties:{name:n.name,output:n.output,"input.file":n.input?.file,"input.name":n.input?.name}}}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,M.isAbsolute)(n)?n:(0,N.joinPaths)(this.builtinsPath,n):(0,v.appendPath)(t,this.builtinsPath),e,(0,f.default)(r,{meta:{type:`builtin`}}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,T.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,S.readJsonFile)(e),this.workspaceConfig.repository??=(0,x.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(h.LogLevelLabel.FATAL,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}error(e){this.log(h.LogLevelLabel.ERROR,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}warn(e){this.log(h.LogLevelLabel.WARN,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}info(e){this.log(h.LogLevelLabel.INFO,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}debug(e){this.log(h.LogLevelLabel.DEBUG,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}trace(e){this.log(h.LogLevelLabel.TRACE,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}createLog(e=null){return c.createLog(e,{...this.config,logLevel:(0,P.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return c.extendLog(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,D.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,V.set({workspaceRoot:e.workspaceRoot,framework:`powerlines`},(0,E.getEnvPaths)({orgId:((0,b.isSetObject)(e.organization)?e.organization.name:e.organization)||`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot}))}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let c={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(B.has(c)){let e=B.get(c);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,N.joinPaths)(c.projectRoot,`project.json`);(0,T.existsSync)(t)&&(this.projectJson=await(0,S.readJsonFile)(t));let n=(0,N.joinPaths)(c.projectRoot,`package.json`);(0,T.existsSync)(n)&&(this.packageJson=await(0,S.readJsonFile)(n)),this.#n=await this.generateChecksum(c.projectRoot),this.resolver=i.createResolver({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:c.projectRoot,cacheDir:this.cachePath,mode:c.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:c.skipCache});let a=await r.loadUserConfigFile(c.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,c.command,c.mode,c.configFile,c.framework);this.mergeUserConfig(a.config),B.set(c,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=n.getTsconfigFilePath(this.workspaceConfig.workspaceRoot,c.projectRoot,e.tsconfig),(0,b.isSetObject)(e)&&(this.resolvedConfig=(0,f.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,v.appendPath)(`src`,c.projectRoot),output:(0,f.default)(e.output??{},{outputPath:c.projectRoot?(0,N.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,c.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,N.joinPaths)(c.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,N.joinPaths)(c.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:c.projectRoot,glob:`*.md`},{input:c.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=s.getUniqueEntries(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,w.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,k.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,k.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,k.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,k.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,k.getUnique)((0,d.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,N.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,N.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,k.getUniqueBy)(this.config.output.assets.map(e=>({glob:(0,b.isSetObject)(e)?e.glob:e,input:(0,m.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,j.isParentPath)(e.input,this.workspaceConfig.workspaceRoot)||e.input===this.workspaceConfig.workspaceRoot?e.input:(0,v.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,b.isSetObject)(e)&&e.output?(0,j.isParentPath)(e.output,this.workspaceConfig.workspaceRoot)?e.output:(0,v.appendPath)((0,N.joinPaths)(this.config.output.outputPath,(0,y.replacePath)((0,y.replacePath)(e.output,(0,y.replacePath)(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)),this.workspaceConfig.workspaceRoot):(0,v.appendPath)(this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,b.isSetObject)(e)&&e.ignore?(0,d.toArray)(e.ignore):void 0})),e=>`${e.input}-${e.glob}-${e.output}`),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=o.replacePathTokens(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=o.replacePathTokens(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>o.replacePathTokens(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:o.replacePathTokens(this,e.glob),ignore:e.ignore?e.ignore.map(e=>o.replacePathTokens(this,e)):void 0,input:o.replacePathTokens(this,e.input),output:o.replacePathTokens(this,e.output)}))),this.#s??=await l.VirtualFileSystem.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,f.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,p.omit)(e??{},[`entry`]),(0,p.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,k.getUnique)((0,d.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[])}};exports.PowerlinesContext=H;
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../typescript/ts-morph.cjs`),n=require(`../typescript/tsconfig.cjs`),r=require(`../config-file.cjs`),i=require(`../../internal/helpers/resolver.cjs`),a=require(`../../plugin-utils/helpers.cjs`),o=require(`../../plugin-utils/paths.cjs`),s=require(`../entry.cjs`),c=require(`../logger.cjs`),l=require(`../fs/vfs.cjs`),u=require(`../utilities/meta.cjs`);let d=require(`@stryke/convert/to-array`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/helpers/omit`),m=require(`@stryke/type-checks/is-string`),h=require(`@storm-software/config-tools/types`),g=require(`@stryke/fs/get-workspace-root`),_=require(`@stryke/fs/resolve`),v=require(`@stryke/path/append`),y=require(`@stryke/path/replace`),b=require(`@stryke/type-checks/is-set-object`),x=require(`@stryke/type-checks/is-set-string`),S=require(`@stryke/fs/json`),C=require(`@stryke/json/storm-json`),w=require(`@stryke/string-format/title-case`),T=require(`@stryke/fs/exists`),E=require(`@stryke/env/get-env-paths`),D=require(`@stryke/hash/hash-files`),O=require(`@stryke/hash/murmurhash`),k=require(`@stryke/helpers/get-unique`),A=require(`@stryke/http/fetch`),j=require(`@stryke/path/is-parent-path`),M=require(`@stryke/path/is-type`),N=require(`@stryke/path/join`),P=require(`@stryke/type-checks/is-null`),F=require(`@stryke/unique-id/uuid`),I=require(`bundle-require`),L=require(`flat-cache`),R=require(`oxc-parser`),z=require(`undici`);const B=new WeakMap,V=new WeakMap;(0,z.setGlobalDispatcher)(new z.Agent({keepAliveTimeout:1e4}).compose(z.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var H=class e{#e={};#t;#n=null;#r=(0,F.uuid)();#i=(0,F.uuid)();#a=Date.now();#o=null;#s;#c;#l;#u;#d;#f(e={}){return(0,f.default)({variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,compatibilityDate:e.compatibilityDate,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e},{output:e.framework?{artifactsPath:(0,N.joinPaths)(e.root??this.config.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,N.joinPaths)(e.root??this.config.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`}:{}})}static async from(t,n){let i=new e(await r.loadWorkspaceConfig(t,n.root));await i.withUserConfig(n);let a=await(0,_.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return s.resolveEntriesSync(this,this.#o?this.#o:(0,d.toArray)(this.config.entry))}set entry(e){this.#o=e}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,I.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=l.VirtualFileSystem.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,O.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,O.murmurhash)(this.config,{maxLength:u.CACHE_HASH_LENGTH})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){if(V.has({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`}))return V.get({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`});let e=(0,E.getEnvPaths)({orgId:`storm-software`,appId:this.config?.framework||`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot});return V.set({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`},e),e}get artifactsPath(){return(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,N.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,N.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,N.joinPaths)(this.envPaths.data,`projects`,u.getPrefixedProjectRootHash(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,N.joinPaths)(this.envPaths.cache,`projects`,(0,O.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,v.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,g.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=t.createProgram(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,L.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,L.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,O.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new z.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,A.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new z.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,O.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,R.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,I.match)(r,[e.find]));e&&(r=e.replacement)}else (0,b.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,I.match)(r,this.resolvePatterns)||(0,I.match)(r,this.config.build.noExternal))return;if((0,I.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,I.match)(r,this.config.build.noExternal))return;if((0,I.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){let r=(0,M.isAbsolute)(t)?t:(0,v.appendPath)(t,this.entryPath);return this.entry??=[],this.entry.push({name:n.name,file:r,input:n.input,output:n.output}),this.fs.write(r,e,(0,f.default)((0,p.omit)(n,[`name`]),{meta:{type:`entry`,properties:{name:n.name,output:n.output,"input.file":n.input?.file,"input.name":n.input?.name}}}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,M.isAbsolute)(n)?n:(0,N.joinPaths)(this.builtinsPath,n):(0,v.appendPath)(t,this.builtinsPath),e,(0,f.default)(r,{meta:{type:`builtin`}}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,N.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,T.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,S.readJsonFile)(e),this.workspaceConfig.repository??=(0,x.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(h.LogLevelLabel.FATAL,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}error(e){this.log(h.LogLevelLabel.ERROR,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}warn(e){this.log(h.LogLevelLabel.WARN,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}info(e){this.log(h.LogLevelLabel.INFO,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}debug(e){this.log(h.LogLevelLabel.DEBUG,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}trace(e){this.log(h.LogLevelLabel.TRACE,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}createLog(e=null){return c.createLog(e,{...this.config,logLevel:(0,P.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return c.extendLog(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,D.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,V.set({workspaceRoot:e.workspaceRoot,framework:`powerlines`},(0,E.getEnvPaths)({orgId:((0,b.isSetObject)(e.organization)?e.organization.name:e.organization)||`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot}))}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let c={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(B.has(c)){let e=B.get(c);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,N.joinPaths)(c.projectRoot,`project.json`);(0,T.existsSync)(t)&&(this.projectJson=await(0,S.readJsonFile)(t));let n=(0,N.joinPaths)(c.projectRoot,`package.json`);(0,T.existsSync)(n)&&(this.packageJson=await(0,S.readJsonFile)(n)),this.#n=await this.generateChecksum(c.projectRoot),this.resolver=i.createResolver({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:c.projectRoot,cacheDir:this.cachePath,mode:c.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:c.skipCache});let a=await r.loadUserConfigFile(c.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,c.command,c.mode,c.configFile,c.framework);this.mergeUserConfig(a.config),B.set(c,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=n.getTsconfigFilePath(this.workspaceConfig.workspaceRoot,c.projectRoot,e.tsconfig),(0,b.isSetObject)(e)&&(this.resolvedConfig=(0,f.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,v.appendPath)(`src`,c.projectRoot),output:(0,f.default)(e.output??{},{outputPath:c.projectRoot?(0,N.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,c.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,N.joinPaths)(c.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,N.joinPaths)(c.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:c.projectRoot,glob:`*.md`},{input:c.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=s.getUniqueEntries(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,w.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,k.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,k.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,k.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,k.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,k.getUnique)((0,d.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,N.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,N.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,k.getUniqueBy)(this.config.output.assets.map(e=>({glob:(0,b.isSetObject)(e)?e.glob:e,input:(0,m.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,j.isParentPath)(e.input,this.workspaceConfig.workspaceRoot)||e.input===this.workspaceConfig.workspaceRoot?e.input:(0,v.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,b.isSetObject)(e)&&e.output?(0,j.isParentPath)(e.output,this.workspaceConfig.workspaceRoot)?e.output:(0,v.appendPath)((0,N.joinPaths)(this.config.output.outputPath,(0,y.replacePath)((0,y.replacePath)(e.output,(0,y.replacePath)(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)),this.workspaceConfig.workspaceRoot):(0,v.appendPath)(this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,b.isSetObject)(e)&&e.ignore?(0,d.toArray)(e.ignore):void 0})),e=>`${e.input}-${e.glob}-${e.output}`),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=o.replacePathTokens(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=o.replacePathTokens(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>o.replacePathTokens(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:o.replacePathTokens(this,e.glob),ignore:e.ignore?e.ignore.map(e=>o.replacePathTokens(this,e)):void 0,input:o.replacePathTokens(this,e.input),output:o.replacePathTokens(this,e.output)}))),this.#s??=await l.VirtualFileSystem.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,f.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,p.omit)(e??{},[`entry`]),(0,p.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,k.getUnique)((0,d.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[])}};exports.PowerlinesContext=H;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createProgram as e}from"../typescript/ts-morph.mjs";import{getTsconfigFilePath as t}from"../typescript/tsconfig.mjs";import{loadUserConfigFile as n,loadWorkspaceConfig as r}from"../config-file.mjs";import{createResolver as i}from"../../internal/helpers/resolver.mjs";import{checkDedupe as a,isPlugin as o}from"../../plugin-utils/helpers.mjs";import{replacePathTokens as s}from"../../plugin-utils/paths.mjs";import{getUniqueEntries as c,resolveEntriesSync as l}from"../entry.mjs";import{createLog as u,extendLog as d}from"../logger.mjs";import{VirtualFileSystem as f}from"../fs/vfs.mjs";import{CACHE_HASH_LENGTH as p,PROJECT_ROOT_HASH_LENGTH as m,getPrefixedProjectRootHash as h}from"../utilities/meta.mjs";import{toArray as g}from"@stryke/convert/to-array";import _ from"defu";import{omit as v}from"@stryke/helpers/omit";import{isString as y}from"@stryke/type-checks/is-string";import{LogLevelLabel as b}from"@storm-software/config-tools/types";import{relativeToWorkspaceRoot as x}from"@stryke/fs/get-workspace-root";import{resolvePackage as S}from"@stryke/fs/resolve";import{appendPath as C}from"@stryke/path/append";import{replacePath as w}from"@stryke/path/replace";import{isSetObject as T}from"@stryke/type-checks/is-set-object";import{isSetString as E}from"@stryke/type-checks/is-set-string";import{readJsonFile as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{titleCase as k}from"@stryke/string-format/title-case";import{existsSync as A}from"@stryke/fs/exists";import{getEnvPaths as j}from"@stryke/env/get-env-paths";import{hashDirectory as M}from"@stryke/hash/hash-files";import{murmurhash as N}from"@stryke/hash/murmurhash";import{getUnique as P,getUniqueBy as F}from"@stryke/helpers/get-unique";import{fetchRequest as I}from"@stryke/http/fetch";import{isParentPath as L}from"@stryke/path/is-parent-path";import{isAbsolute as R}from"@stryke/path/is-type";import{joinPaths as z}from"@stryke/path/join";import{isNull as B}from"@stryke/type-checks/is-null";import{uuid as V}from"@stryke/unique-id/uuid";import{match as H,tsconfigPathsToRegExp as U}from"bundle-require";import{create as W}from"flat-cache";import{parse as G}from"oxc-parser";import{Agent as K,Response as q,interceptors as J,setGlobalDispatcher as Y}from"undici";const X=new WeakMap,Z=new WeakMap;Y(new K({keepAliveTimeout:1e4}).compose(J.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Q=class K{#e={};#t;#n=null;#r=V();#i=V();#a=Date.now();#o=null;#s;#c;#l;#u;#d;#f(e={}){return _({variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e},{output:e.framework?{artifactsPath:z(e.root??this.config.projectRoot,`.${e.framework??`powerlines`}`),dts:z(e.root??this.config.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`}:{}})}static async from(e,t){let n=new K(await r(e,t.root));await n.withUserConfig(t);let i=await S(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=i,n}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return l(this,this.#o?this.#o:g(this.config.entry))}set entry(e){this.#o=e}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=U(e?.options?.paths??{})}get fs(){return this.#s||=f.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:N({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:N(this.config,{maxLength:p})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){if(Z.has({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`}))return Z.get({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`});let e=j({orgId:`storm-software`,appId:this.config?.framework||`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot});return Z.set({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`},e),e}get artifactsPath(){return z(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return z(this.artifactsPath,`builtins`)}get entryPath(){return z(this.artifactsPath,`entry`)}get dataPath(){return z(this.envPaths.data,`projects`,h(this.config.name,this.meta.projectRootHash))}get cachePath(){return z(this.envPaths.cache,`projects`,N({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?C(this.config.output.dts,this.workspaceConfig.workspaceRoot):z(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return x(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=e(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=W({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=W({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=N({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new q(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await I(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new q(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=N({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await G(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>H(r,[e.find]));e&&(r=e.replacement)}else T(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if(H(r,this.resolvePatterns)||H(r,this.config.build.noExternal))return;if(H(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if(H(r,this.config.build.noExternal))return;if(H(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){let r=R(t)?t:C(t,this.entryPath);return this.entry??=[],this.entry.push({name:n.name,file:r,input:n.input,output:n.output}),this.fs.write(r,e,_(v(n,[`name`]),{meta:{type:`entry`,properties:{name:n.name,output:n.output,"input.file":n.input?.file,"input.name":n.input?.name}}}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?R(n)?n:z(this.builtinsPath,n):C(t,this.builtinsPath),e,_(r,{meta:{type:`builtin`}}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=z(this.workspaceConfig.workspaceRoot,`package.json`);if(!A(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await D(e),this.workspaceConfig.repository??=E(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(b.FATAL,y(e)?e:O.stringify(e))}error(e){this.log(b.ERROR,y(e)?e:O.stringify(e))}warn(e){this.log(b.WARN,y(e)?e:O.stringify(e))}info(e){this.log(b.INFO,y(e)?e:O.stringify(e))}debug(e){this.log(b.DEBUG,y(e)?e:O.stringify(e))}trace(e){this.log(b.TRACE,y(e)?e:O.stringify(e))}createLog(e=null){return u(e,{...this.config,logLevel:B(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return d(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await M(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,Z.set({workspaceRoot:e.workspaceRoot,framework:`powerlines`},j({orgId:(T(e.organization)?e.organization.name:e.organization)||`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot}))}resolvedConfig={};logFn;async init(e={},r={isHighPriority:!0}){let l={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(X.has(l)){let e=X.get(l);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=z(l.projectRoot,`project.json`);A(t)&&(this.projectJson=await D(t));let r=z(l.projectRoot,`package.json`);A(r)&&(this.packageJson=await D(r)),this.#n=await this.generateChecksum(l.projectRoot),this.resolver=i({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:l.projectRoot,cacheDir:this.cachePath,mode:l.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:l.skipCache});let a=await n(l.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,l.command,l.mode,l.configFile,l.framework);this.mergeUserConfig(a.config),X.set(l,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=t(this.workspaceConfig.workspaceRoot,l.projectRoot,e.tsconfig),T(e)&&(this.resolvedConfig=_({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},r.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||C(`src`,l.projectRoot),output:_(e.output??{},{outputPath:l.projectRoot?z(this.workspaceConfig?.directories?.build||`dist`,l.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:z(l.projectRoot,`.${e.framework??`powerlines`}`),dts:z(l.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:l.projectRoot,glob:`*.md`},{input:l.projectRoot,glob:`package.json`}]})},r.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=c(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=k(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=P(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=P(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=P(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=P(this.config.build.noExternal)),this.config.output.format=P(g(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=z(`dist`,this.config.projectRoot),this.config.output.buildPath??=z(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=F(this.config.output.assets.map(e=>({glob:T(e)?e.glob:e,input:y(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:L(e.input,this.workspaceConfig.workspaceRoot)||e.input===this.workspaceConfig.workspaceRoot?e.input:C(e.input,this.workspaceConfig.workspaceRoot),output:T(e)&&e.output?L(e.output,this.workspaceConfig.workspaceRoot)?e.output:C(z(this.config.output.outputPath,w(w(e.output,w(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)),this.workspaceConfig.workspaceRoot):C(this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:T(e)&&e.ignore?g(e.ignore):void 0})),e=>`${e.input}-${e.glob}-${e.output}`),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=s(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=s(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>s(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:s(this,e.glob),ignore:e.ignore?e.ignore.map(e=>s(this,e)):void 0,input:s(this,e.input),output:s(this,e.output)}))),this.#s??=await f.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=_({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},v(e??{},[`entry`]),v(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=P(g(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[])}};export{Q as PowerlinesContext};
|
|
1
|
+
import{createProgram as e}from"../typescript/ts-morph.mjs";import{getTsconfigFilePath as t}from"../typescript/tsconfig.mjs";import{loadUserConfigFile as n,loadWorkspaceConfig as r}from"../config-file.mjs";import{createResolver as i}from"../../internal/helpers/resolver.mjs";import{checkDedupe as a,isPlugin as o}from"../../plugin-utils/helpers.mjs";import{replacePathTokens as s}from"../../plugin-utils/paths.mjs";import{getUniqueEntries as c,resolveEntriesSync as l}from"../entry.mjs";import{createLog as u,extendLog as d}from"../logger.mjs";import{VirtualFileSystem as f}from"../fs/vfs.mjs";import{CACHE_HASH_LENGTH as p,PROJECT_ROOT_HASH_LENGTH as m,getPrefixedProjectRootHash as h}from"../utilities/meta.mjs";import{toArray as g}from"@stryke/convert/to-array";import _ from"defu";import{omit as v}from"@stryke/helpers/omit";import{isString as y}from"@stryke/type-checks/is-string";import{LogLevelLabel as b}from"@storm-software/config-tools/types";import{relativeToWorkspaceRoot as x}from"@stryke/fs/get-workspace-root";import{resolvePackage as S}from"@stryke/fs/resolve";import{appendPath as C}from"@stryke/path/append";import{replacePath as w}from"@stryke/path/replace";import{isSetObject as T}from"@stryke/type-checks/is-set-object";import{isSetString as E}from"@stryke/type-checks/is-set-string";import{readJsonFile as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{titleCase as k}from"@stryke/string-format/title-case";import{existsSync as A}from"@stryke/fs/exists";import{getEnvPaths as j}from"@stryke/env/get-env-paths";import{hashDirectory as M}from"@stryke/hash/hash-files";import{murmurhash as N}from"@stryke/hash/murmurhash";import{getUnique as P,getUniqueBy as F}from"@stryke/helpers/get-unique";import{fetchRequest as I}from"@stryke/http/fetch";import{isParentPath as L}from"@stryke/path/is-parent-path";import{isAbsolute as R}from"@stryke/path/is-type";import{joinPaths as z}from"@stryke/path/join";import{isNull as B}from"@stryke/type-checks/is-null";import{uuid as V}from"@stryke/unique-id/uuid";import{match as H,tsconfigPathsToRegExp as U}from"bundle-require";import{create as W}from"flat-cache";import{parse as G}from"oxc-parser";import{Agent as K,Response as q,interceptors as J,setGlobalDispatcher as Y}from"undici";const X=new WeakMap,Z=new WeakMap;Y(new K({keepAliveTimeout:1e4}).compose(J.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Q=class K{#e={};#t;#n=null;#r=V();#i=V();#a=Date.now();#o=null;#s;#c;#l;#u;#d;#f(e={}){return _({variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,compatibilityDate:e.compatibilityDate,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e},{output:e.framework?{artifactsPath:z(e.root??this.config.projectRoot,`.${e.framework??`powerlines`}`),dts:z(e.root??this.config.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`}:{}})}static async from(e,t){let n=new K(await r(e,t.root));await n.withUserConfig(t);let i=await S(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=i,n}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return l(this,this.#o?this.#o:g(this.config.entry))}set entry(e){this.#o=e}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=U(e?.options?.paths??{})}get fs(){return this.#s||=f.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:N({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:N(this.config,{maxLength:p})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){if(Z.has({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`}))return Z.get({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`});let e=j({orgId:`storm-software`,appId:this.config?.framework||`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot});return Z.set({workspaceRoot:this.workspaceConfig.workspaceRoot,framework:this.config?.framework||`powerlines`},e),e}get artifactsPath(){return z(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return z(this.artifactsPath,`builtins`)}get entryPath(){return z(this.artifactsPath,`entry`)}get dataPath(){return z(this.envPaths.data,`projects`,h(this.config.name,this.meta.projectRootHash))}get cachePath(){return z(this.envPaths.cache,`projects`,N({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?C(this.config.output.dts,this.workspaceConfig.workspaceRoot):z(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return x(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=e(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=W({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=W({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=N({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new q(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await I(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new q(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=N({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await G(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>H(r,[e.find]));e&&(r=e.replacement)}else T(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if(H(r,this.resolvePatterns)||H(r,this.config.build.noExternal))return;if(H(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if(H(r,this.config.build.noExternal))return;if(H(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){let r=R(t)?t:C(t,this.entryPath);return this.entry??=[],this.entry.push({name:n.name,file:r,input:n.input,output:n.output}),this.fs.write(r,e,_(v(n,[`name`]),{meta:{type:`entry`,properties:{name:n.name,output:n.output,"input.file":n.input?.file,"input.name":n.input?.name}}}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?R(n)?n:z(this.builtinsPath,n):C(t,this.builtinsPath),e,_(r,{meta:{type:`builtin`}}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=z(this.workspaceConfig.workspaceRoot,`package.json`);if(!A(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await D(e),this.workspaceConfig.repository??=E(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(b.FATAL,y(e)?e:O.stringify(e))}error(e){this.log(b.ERROR,y(e)?e:O.stringify(e))}warn(e){this.log(b.WARN,y(e)?e:O.stringify(e))}info(e){this.log(b.INFO,y(e)?e:O.stringify(e))}debug(e){this.log(b.DEBUG,y(e)?e:O.stringify(e))}trace(e){this.log(b.TRACE,y(e)?e:O.stringify(e))}createLog(e=null){return u(e,{...this.config,logLevel:B(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return d(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await M(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,Z.set({workspaceRoot:e.workspaceRoot,framework:`powerlines`},j({orgId:(T(e.organization)?e.organization.name:e.organization)||`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot}))}resolvedConfig={};logFn;async init(e={},r={isHighPriority:!0}){let l={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(X.has(l)){let e=X.get(l);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=z(l.projectRoot,`project.json`);A(t)&&(this.projectJson=await D(t));let r=z(l.projectRoot,`package.json`);A(r)&&(this.packageJson=await D(r)),this.#n=await this.generateChecksum(l.projectRoot),this.resolver=i({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:l.projectRoot,cacheDir:this.cachePath,mode:l.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:l.skipCache});let a=await n(l.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,l.command,l.mode,l.configFile,l.framework);this.mergeUserConfig(a.config),X.set(l,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=t(this.workspaceConfig.workspaceRoot,l.projectRoot,e.tsconfig),T(e)&&(this.resolvedConfig=_({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},r.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||C(`src`,l.projectRoot),output:_(e.output??{},{outputPath:l.projectRoot?z(this.workspaceConfig?.directories?.build||`dist`,l.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:z(l.projectRoot,`.${e.framework??`powerlines`}`),dts:z(l.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:l.projectRoot,glob:`*.md`},{input:l.projectRoot,glob:`package.json`}]})},r.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=c(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=k(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=P(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=P(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=P(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=P(this.config.build.noExternal)),this.config.output.format=P(g(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=z(`dist`,this.config.projectRoot),this.config.output.buildPath??=z(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=F(this.config.output.assets.map(e=>({glob:T(e)?e.glob:e,input:y(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:L(e.input,this.workspaceConfig.workspaceRoot)||e.input===this.workspaceConfig.workspaceRoot?e.input:C(e.input,this.workspaceConfig.workspaceRoot),output:T(e)&&e.output?L(e.output,this.workspaceConfig.workspaceRoot)?e.output:C(z(this.config.output.outputPath,w(w(e.output,w(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)),this.workspaceConfig.workspaceRoot):C(this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:T(e)&&e.ignore?g(e.ignore):void 0})),e=>`${e.input}-${e.glob}-${e.output}`),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=s(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=s(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>s(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:s(this,e.glob),ignore:e.ignore?e.ignore.map(e=>s(this,e)):void 0,input:s(this,e.input),output:s(this,e.output)}))),this.#s??=await f.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=_({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},v(e??{},[`entry`]),v(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=P(g(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[])}};export{Q as PowerlinesContext};
|
|
@@ -10,6 +10,7 @@ import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
|
10
10
|
import { StormWorkspaceConfig } from "@storm-software/config/types";
|
|
11
11
|
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
12
12
|
import { AssetGlob } from "@stryke/types/file";
|
|
13
|
+
import { DateString } from "compatx";
|
|
13
14
|
|
|
14
15
|
//#region ../powerlines/src/types/config.d.ts
|
|
15
16
|
|
|
@@ -238,6 +239,17 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
238
239
|
* If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
|
|
239
240
|
*/
|
|
240
241
|
description?: string;
|
|
242
|
+
/**
|
|
243
|
+
* The date to use for compatibility checks
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* This date can be used by plugins and build processes to determine compatibility with certain features or APIs. It is recommended to set this date to the date when the project was last known to be compatible with the desired features or APIs.
|
|
247
|
+
*
|
|
248
|
+
* @see https://developers.cloudflare.com/pages/platform/compatibility-dates/
|
|
249
|
+
* @see https://docs.netlify.com/configure-builds/get-started/#set-a-compatibility-date
|
|
250
|
+
* @see https://github.com/unjs/compatx
|
|
251
|
+
*/
|
|
252
|
+
compatibilityDate?: DateString;
|
|
241
253
|
/**
|
|
242
254
|
* The log level to use for the Powerlines processes.
|
|
243
255
|
*
|
|
@@ -6,13 +6,13 @@ import { TSConfig } from "./tsconfig.mjs";
|
|
|
6
6
|
import { PluginContext } from "./context.mjs";
|
|
7
7
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
8
8
|
import { transformAsync } from "@babel/core";
|
|
9
|
-
import "c12";
|
|
10
9
|
import { PreviewOptions } from "vite";
|
|
11
10
|
import { MaybePromise } from "@stryke/types/base";
|
|
12
11
|
import { Format } from "@storm-software/build-tools/types";
|
|
13
12
|
import { StormWorkspaceConfig } from "@storm-software/config/types";
|
|
14
13
|
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
15
14
|
import { AssetGlob } from "@stryke/types/file";
|
|
15
|
+
import { DateString } from "compatx";
|
|
16
16
|
|
|
17
17
|
//#region ../powerlines/src/types/config.d.ts
|
|
18
18
|
type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
|
|
@@ -240,6 +240,17 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
240
240
|
* If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
|
|
241
241
|
*/
|
|
242
242
|
description?: string;
|
|
243
|
+
/**
|
|
244
|
+
* The date to use for compatibility checks
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* This date can be used by plugins and build processes to determine compatibility with certain features or APIs. It is recommended to set this date to the date when the project was last known to be compatible with the desired features or APIs.
|
|
248
|
+
*
|
|
249
|
+
* @see https://developers.cloudflare.com/pages/platform/compatibility-dates/
|
|
250
|
+
* @see https://docs.netlify.com/configure-builds/get-started/#set-a-compatibility-date
|
|
251
|
+
* @see https://github.com/unjs/compatx
|
|
252
|
+
*/
|
|
253
|
+
compatibilityDate?: DateString;
|
|
243
254
|
/**
|
|
244
255
|
* The log level to use for the Powerlines processes.
|
|
245
256
|
*
|
|
@@ -32,7 +32,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> &
|
|
|
32
32
|
/**
|
|
33
33
|
* The resolved options for the Powerlines project configuration.
|
|
34
34
|
*/
|
|
35
|
-
type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
|
|
35
|
+
type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
|
|
36
36
|
/**
|
|
37
37
|
* The configuration options that were provided inline to the Powerlines CLI.
|
|
38
38
|
*/
|
|
@@ -33,7 +33,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> &
|
|
|
33
33
|
/**
|
|
34
34
|
* The resolved options for the Powerlines project configuration.
|
|
35
35
|
*/
|
|
36
|
-
type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
|
|
36
|
+
type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
|
|
37
37
|
/**
|
|
38
38
|
* The configuration options that were provided inline to the Powerlines CLI.
|
|
39
39
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-rolldown",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.117",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -152,15 +152,15 @@
|
|
|
152
152
|
"@stryke/types": "^0.10.28",
|
|
153
153
|
"defu": "^6.1.4",
|
|
154
154
|
"jiti": "^2.6.1",
|
|
155
|
-
"powerlines": "^0.36.
|
|
155
|
+
"powerlines": "^0.36.13",
|
|
156
156
|
"rolldown": "1.0.0-beta.53",
|
|
157
157
|
"unplugin": "3.0.0-beta.3"
|
|
158
158
|
},
|
|
159
159
|
"devDependencies": {
|
|
160
|
-
"@powerlines/nx": "^0.11.
|
|
161
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
160
|
+
"@powerlines/nx": "^0.11.39",
|
|
161
|
+
"@powerlines/plugin-plugin": "^0.12.60",
|
|
162
162
|
"@types/node": "^24.10.4"
|
|
163
163
|
},
|
|
164
164
|
"publishConfig": { "access": "public" },
|
|
165
|
-
"gitHead": "
|
|
165
|
+
"gitHead": "483677f34524b653a72b313c463081c800043753"
|
|
166
166
|
}
|