sdin
Version:
JavaScript package builder.
2 lines • 3.21 kB
JavaScript
import i from"@babel/runtime/helpers/defineProperty";function r(e,t){var s,i=Object.keys(e);return Object.getOwnPropertySymbols&&(s=Object.getOwnPropertySymbols(e),t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)),i}function s(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?r(Object(s),!0).forEach(function(t){i(e,t,s[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):r(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}import{asyncForEach as t,filterNotNone as a}from"../utils/array";import{keyBy as o}from"lodash";import{joinPosix as n,resolvePosixSlash as l}from"../utils/path";import{SdinConfigError as h}from"../tools/errors";import{getDependenceVersion as e}from"../utils/npm";import{ABSOLUTE_URL_PATH_EXP as p}from"../tools/check";import{matchRegExpOrThrow as u}from"../utils/check";import{SdinAbstractModule as c}from"./abstract-module";import{SdinApplicationPage as m}from"./application-page";import{yellow as d}from"../utils/print";class E extends c{constructor(t,e){super(t,e,"csr",""),this.title=null!=(t=e.title)?t:null,this.path=l(null!=(t=e.path)?t:this.name,!0,!0),this.astSrc=this.withRoot(e.astSrc||"pro/assets"),this.astPath=l(e.astPath||"ast",!1,!0),this.minify=null==(t=e.minify)||t,this.uglify=null==(t=e.uglify)||t,this.sourceMap=null!=(t=e.sourceMap)?t:this.minify||this.uglify,this.externals=e.externals||{},this.sassModule=null==(t=e.sassModule)||t,this.mixinClass=null==(t=e.mixinClass)||t,this.babelIncludes=a(e.babelIncludes),this.babelExcludes=[/node_modules/,...a(e.babelExcludes)],this.rawRule=e.rawRule||{},this.fontRule=e.fontRule||{},this.imageRule=e.imageRule||{},this.audioRule=e.audioRule||{},this.videoRule=e.videoRule||{},this.rules=a(e.rules),this.devLog=null!=(t=e.devLog)&&t,this.devEmoji=null!=(t=e.devEmoji)?t:"⚡",this.devPort=e.devPort||8080,this.devProxies=a(e.devProxies),this.datas=s(s(s({},this.parent.datas),this.params.datas),{},{SDIN_MODULE_ENV:"unknown",SDIN_MODULE_TYPE:this.type,SDIN_MODULE_MODE:this.mode,SDIN_MODULE_NAME:this.name,SDIN_MODULE_TITLE:this.title,SDIN_MODULE_PATH:this.path,SDIN_MODULE_ASSETS_PATH:this.path+this.astPath}),this.pages=this.createPages(e.pages);t=o(this.pages,"name");this.index=t[e.index||"index"],this.error=t[e.error||"error"]}createPages(t){var e,s=[],i={};for(e of a(t)){var r=new m(this.ancestor,this,e);if(i[r.name])throw new h(h.MODULE_NAME_IS_REPEATED,"Module ".concat(d(this.name),' Page name "').concat(d(r.name),'" is repeated.'));s.push(r),i[r.name]=!0}return s}async validate(){if(await super.validate(),await t(this.pages,t=>t.validate()),u("module ".concat(d(this.name)," path"),this.path,p),["react","react-dom"].some(t=>!e(this.pkg,t)))throw new h(h.ABSENT_PACKAGE_DEPENDENCE,"please install react、react-dom dependence.")}withPath(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return n(this.path,...e)}setEnv(e){this.datas.SDIN_MODULE_ENV=e,this.pages.forEach(t=>t.datas.SDIN_MODULE_ENV=e)}}export{E as SdinApplicationModule};
//# sourceMappingURL=application-module.js.map