@moneko/core 3.1.0-beta.0 → 3.1.0-beta.2

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/lib/cleanup.js CHANGED
@@ -1 +1 @@
1
- import{existsSync as o,readdirSync as r,rmdirSync as t,statSync as i,unlinkSync as f}from"fs";import{join as s}from"path";import{cacheDir as c}from"./process-env.js";process.on("exit",function(){!function c(e){o(e)&&(r(e).forEach(o=>{let r=s(e,o);i(r).isDirectory()?c(r):f(r)}),t(e))}(c)});
1
+ import{existsSync as o,readdirSync as t,rmdirSync as r,statSync as i,unlinkSync as c}from"fs";import{join as f}from"path";import m from"./paths.js";process.on("exit",function(){!function m(p){o(p)&&(t(p).forEach(o=>{let t=f(p,o);i(t).isDirectory()?m(t):c(t)}),r(p))}(m.cachePath)});
package/lib/common.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,PUBLICPATH as i}from"./config.js";import r from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import m from"./module.config.js";import{CUSTOMCONFIG as u,PACKAGENAME as f,PROGRAMPATH as d,hasEslintConfig as h,hasStylelintConfig as y,isDev as j,isLibrary as g,isMicro as b}from"./process-env.js";import{seo as w}from"./seo.js";import{resolveNodeModulesPath as x,resolveProgramPath as k}from"./utils.js";import v from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:$,SourceMapDevToolPlugin:D,WatchIgnorePlugin:N}=n,P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(d),B=!1,E=!1;for(let e=0,t=A.length;e<t;e++)S.includes(A[e])&&(E=!0),P.includes(A[e])&&(B=!0);B||(B=h),E||(E=y);let M=E?(await import("stylelint-webpack-plugin")).default:null,T=B?(await import("eslint-webpack-plugin")).default:null,_=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:k(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:f,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${f}`,pathinfo:j,clean:!0,publicPath:i,asyncChunks:!0};let K={main:x("@app/entry")};l.entry&&("string"==typeof l.entry?K=l.entry:Object.keys(l.entry)&&Object.assign(K,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let L=l.basename.split("/").filter(Boolean).length,F=`${Array(L).fill("..").join("/")+(L?"/":"")}404.html`,{pathSegmentsToKeep:J=L,path:R=F}=l.fixBrowserRouter||{},V=!1;l.cacheDirectory&&(V={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${u||"default"}-${j?"development":"production"}`});export const clientConfig={entry:K,stats:"errors-only",cache:V,infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new O,...c,T&&new T({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),M&&new M({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(p),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${J||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(_),b&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new $({"process.env":JSON.stringify({...l.env,// mf 需要 isDev
2
- NODE_ENV:process.env.NODE_ENV})}),new N({paths:[/\.d\.ts$/]}),l.sourceMap&&new D(l.sourceMap),l.bar&&new o(l.bar),new r({done:()=>{!j&&l.seo&&w(),l.done?.(),j||setTimeout(()=>{process.exit(0)},2e3)}}),new v(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:l.externals,output:outputConfig};
1
+ import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,PUBLICPATH as r}from"./config.js";import i from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as m}from"./module-federation.js";import c from"./module.config.js";import u from"./paths.js";import{CUSTOMCONFIG as f,PACKAGENAME as h,hasEslintConfig as d,hasStylelintConfig as j,isDev as y,isLibrary as g,isMicro as b}from"./process-env.js";import{seo as w}from"./seo.js";import{resolveNodeModulesPath as x,resolveProgramPath as k}from"./utils.js";import v from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:$,SourceMapDevToolPlugin:P,WatchIgnorePlugin:D}=o,N=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(u.programPath),B=!1,E=!1;for(let e=0,t=A.length;e<t;e++)S.includes(A[e])&&(E=!0),N.includes(A[e])&&(B=!0);B||(B=d),E||(E=j);let M=E?(await import("stylelint-webpack-plugin")).default:null,T=B?(await import("eslint-webpack-plugin")).default:null,_=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:k(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:y,clean:!0,publicPath:r,asyncChunks:!0};let K={main:x("@app/entry")};l.entry&&("string"==typeof l.entry?K=l.entry:Object.keys(l.entry)&&Object.assign(K,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let L=l.basename.split("/").filter(Boolean).length,F=`${Array(L).fill("..").join("/")+(L?"/":"")}404.html`,{pathSegmentsToKeep:J=L,path:R=F}=l.fixBrowserRouter||{},V=!1;l.cacheDirectory&&(V={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${y?"development":"production"}`});export const clientConfig={entry:K,stats:"errors-only",cache:V,infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new O,...m,T&&new T({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),M&&new M({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(p),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${J||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(_),b&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new $({"process.env":JSON.stringify({...l.env,// mf 需要 isDev
2
+ NODE_ENV:process.env.NODE_ENV})}),new D({paths:[/\.d\.ts$/]}),l.sourceMap&&new P(l.sourceMap),l.bar&&new n(l.bar),new i({done:()=>{!y&&l.seo&&w(),l.done?.(),y||setTimeout(()=>{process.exit(0)},2e3)}}),new v(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:c,externals:l.externals,output:outputConfig};
package/lib/config.js CHANGED
@@ -1 +1 @@
1
- import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as a,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as u,pkgName as p}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as f}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site",backstage:"backstage",micro:"micro",library:"library"};let g=["@moneko/core",`@moneko/${a}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={library:{"@":f("site"),"@pkg":f("components"),[c]:f("components")},mobile:{},site:{},backstage:{},micro:{}},b={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},basename:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":f("src")},x[n]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${m}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${p}/template/index.html`,favicon:`./node_modules/${p}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:g,css:g,js:g,media:g,fonts:g},mdx:{jsxImportSource:u,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{}};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let y=b,w=null,C={},k={};try{w=o(m,"./config/index.ts"),e(w,t.R_OK)}catch(e){w=null}if(w)try{let e=(await h(w,"index")).default;C=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}if(l){let s=null;try{s=o(m,`./config/${l}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,l)).default;k=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}}"tsc"===(y=i(y,C,k)).compiler&&y.minifier&&(y.minifier.js||Object.assign(y.minifier,{js:{type:"terser"}}),y.minifier.css||Object.assign(y.minifier,{css:{type:"cssnano"}})),!1===y.devtool&&(y.sourceMap=!1),!1===y.sourceMap&&(y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=y;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
1
+ import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import a from"./paths.js";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as c,PACKAGENAME as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as f}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site",backstage:"backstage",micro:"micro",library:"library"};let g=["@moneko/core",`@moneko/${c}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],b={library:{"@":f("site"),"@pkg":f("components"),[m]:f("components")},mobile:{},site:{},backstage:{},micro:{}},x={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},basename:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":f("src")},b[n]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:a.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${u}/template/index.html`,favicon:`node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:g,css:g,js:g,media:g,fonts:g},mdx:{jsxImportSource:p,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{}};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let y=x,C=null,w={},k={};try{C=a.defaultConfigPath,e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;w=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}if(l){let o=null;try{o=`${a.programPath}/config/${l}.ts`,e(o,t.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await h(o,l)).default;k=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}}"tsc"===(y=i(y,w,k)).compiler&&y.minifier&&(y.minifier.js||Object.assign(y.minifier,{js:{type:"terser"}}),y.minifier.css||Object.assign(y.minifier,{css:{type:"cssnano"}})),!1===y.devtool&&(y.sourceMap=!1),!1===y.sourceMap&&(y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=y;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
package/lib/coverage.js CHANGED
@@ -1,3 +1,3 @@
1
- import{accessSync as e,constants as r,readFileSync as c}from"fs";import{join as o}from"path";import{Parser as t}from"xml2js";import{PACKAGENAME as a,PROGRAMPATH as i,isLibrary as s}from"./process-env.js";export const coverage={};if(s)try{let s=o(i,"./coverage/clover.xml");e(s,r.R_OK);let m=new t({explicitArray:!1,async:!1}),p=c(s,{encoding:"utf-8"});// eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- m.parseString(p,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}});// eslint-disable-next-line no-empty
1
+ import{accessSync as e,constants as r,readFileSync as c}from"fs";import{Parser as o}from"xml2js";import t from"./paths.js";import{PACKAGENAME as a,isLibrary as s}from"./process-env.js";export const coverage={};if(s)try{e(t.coveragePath,r.R_OK);let s=new o({explicitArray:!1,async:!1}),i=c(t.coveragePath,{encoding:"utf-8"});// eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ s.parseString(i,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}});// eslint-disable-next-line no-empty
3
3
  }catch(e){}
package/lib/has-pkg.js CHANGED
@@ -1 +1 @@
1
- import{accessSync as o,constants as r}from"fs";import t from"path";import{PROGRAMPATH as e}from"./process-env.js";export function hasPkg(m){let n=!1;try{let p=t.join(e,`./node_modules/${m}/package.json`);o(p,r.R_OK),n=!0}catch(o){n=!1}return n}
1
+ import{accessSync as o,constants as r}from"fs";import t from"./paths.js";export function hasPkg(a){let e=!1;try{o(`${t.programPath}/node_modules/${a}/package.json`,r.R_OK),e=!0}catch(o){e=!1}return e}
@@ -1 +1 @@
1
- import e from"path";import{merge as t}from"webpack-merge";import i from"./app.js";import{CONFIG as o}from"./config.js";import{PACKAGENAME as a,PROGRAMPATH as p,pkgName as r}from"./process-env.js";let{template:m,favicon:n,...l}=Object.assign({template:`./node_modules/${r}/template/index.html`,favicon:`./node_modules/${r}/template/favicon.ico`},o.htmlPluginOption||{}),s=t({title:o.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:i.description||""},tags:[],template:e.join(p,m),favicon:e.join(p,n)},l);export default s;
1
+ import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,pkgName as r}from"./process-env.js";let{template:p,favicon:m,...n}=Object.assign({template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`},i.htmlPluginOption||{}),l=e({title:i.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:t.description||""},tags:[],template:`${o.programPath}/${p}`,favicon:`${o.programPath}/${m}`},n);export default l;
@@ -1,3 +1,3 @@
1
- import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as l}from"./config.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modify-vars.js";import{FRAMEWORK as i,__dirname as n,isDev as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:e(n,"./loader/css-unicode.cjs")},x=m?l:"../",g={loader:s.loader,options:{publicPath:"/"!==x?x:"../"}},$=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};c&&(g="style-loader");let j=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(u),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],b=["components","example","mock","site","src","server"].map(f),w=[g,c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
1
+ import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as r}from"./config.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modify-vars.js";import i from"./paths.js";import{FRAMEWORK as n,isDev as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:e(i.corePath,"./loader/css-unicode.cjs")},x=m?r:"../",g={loader:s.loader,options:{publicPath:"/"!==x?x:"../"}},$=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};c&&(g="style-loader");let j=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(u),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],h=["components","example","mock","site","src","server"].map(f),b=[g,c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
2
2
  auto:e=>{for(let s=0,o=j.length;s<o;s++)if(e&&e?.includes(j[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
3
- localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),h={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(c)},k=b.concat(t.rulesInclude?.media?.map(u)||[]),I=b.concat(t.rulesInclude?.fonts?.map(u)||[]),O=b.concat(t.rulesInclude?.less?.map(u)||[]),B=b.concat(t.rulesInclude?.css?.map(u)||[]),L=b.concat(t.rulesInclude?.js?.map(u)||[]),M={rules:[{test:/\.mdx?$/i,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(n,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/i,type:"webassembly/async"},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:k},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)},include:k},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:k},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:w,include:O},{test:/\.css$/i,use:[g,"css-loader",$,y].filter(Boolean),include:B},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,h].filter(Boolean),include:L},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,h,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default M;
3
+ localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(c)},k=h.concat(t.rulesInclude?.media?.map(u)||[]),I=h.concat(t.rulesInclude?.fonts?.map(u)||[]),O=h.concat(t.rulesInclude?.less?.map(u)||[]),B=h.concat(t.rulesInclude?.css?.map(u)||[]),L=h.concat(t.rulesInclude?.js?.map(u)||[]),M={rules:[{test:/\.mdx?$/i,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(i.corePath,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/i,type:"webassembly/async"},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:k},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)},include:k},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:k},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:b,include:O},{test:/\.css$/i,use:[g,"css-loader",$,y].filter(Boolean),include:B},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,w].filter(Boolean),include:L},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:h,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default M;
package/lib/paths.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ corePath: string;
3
+ programPath: string;
4
+ webpackCachePath: string;
5
+ cachePath: string;
6
+ swcCachePath: string;
7
+ defaultConfigPath: string;
8
+ coveragePath: string;
9
+ pagesPath: string;
10
+ componentsPath: string;
11
+ };
12
+ export default _default;
package/lib/paths.js ADDED
@@ -0,0 +1 @@
1
+ import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let c=process.cwd(),t=`${c}/node_modules/.cache/.mo`;e(t)||o(t,{recursive:!0});export default{corePath:a.fileURLToPath(new URL(".",import.meta.url)),programPath:c,webpackCachePath:`${c}/node_modules/.temp_cache`,cachePath:t,swcCachePath:`${c}/node_modules/.cache/.swc/`,defaultConfigPath:`${c}/config/index.ts`,coveragePath:`${c}/coverage/clover.xml`,pagesPath:`${c}/src/pages`,componentsPath:`${c}/components`};
@@ -1,5 +1,4 @@
1
1
  import type { AppType, Framework } from '../typings/global.js';
2
- export declare const __dirname: string;
3
2
  export declare const APPTYPE: AppType;
4
3
  export declare const FRAMEWORK: Framework;
5
4
  export declare const isLibrary: boolean;
@@ -9,12 +8,10 @@ export declare const isSolid: boolean;
9
8
  export declare const jsxImportSource: string;
10
9
  export declare const createElement: string;
11
10
  export declare const FRAMEWORKNAME: string;
12
- export declare const PROGRAMPATH: string;
13
11
  export declare const PACKAGENAME: string;
14
12
  export declare const PACKAGEVERSION: string;
15
13
  export declare const pkgName: string;
16
14
  export declare const isDev: boolean;
17
- export declare const cacheDir: string;
18
15
  export declare const CUSTOMCONFIG: string | undefined;
19
16
  export declare const hasEslintConfig: boolean;
20
17
  export declare const hasStylelintConfig: boolean;
@@ -1 +1 @@
1
- import{existsSync as e,mkdirSync as o,readFileSync as t}from"fs";import{join as r}from"path";import s from"url";import n from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let c=t(r(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(c).name;export const isDev="development"===process.env.NODE_ENV;export const cacheDir=r(PROGRAMPATH,"./node_modules/.cache/.mo/");e(cacheDir)||o(cacheDir,{recursive:!0});export const CUSTOMCONFIG=process.env.npm_config_config||n.config;let p=Object.keys(process.env);export const hasEslintConfig=-1!==p.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==p.findIndex(e=>e.startsWith("npm_package_stylelint_"));
1
+ import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let s=e(o.corePath,{encoding:"utf-8"});export const pkgName=JSON.parse(s).name;export const isDev="development"===process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||t.config;let n=Object.keys(process.env);export const hasEslintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_stylelint_"));
package/lib/routes.js CHANGED
@@ -1,4 +1,4 @@
1
- let e,t;import{readFileSync as r,readdirSync as o,statSync as n}from"fs";import{join as s,relative as i}from"path";import{watch as a}from"chokidar";import{load as p}from"js-yaml";import{hasCustomRouter as l}from"./config.js";import c from"./object-listener.js";import{FRAMEWORK as m,FRAMEWORKNAME as u,PROGRAMPATH as f,createElement as d,isLibrary as x,isReact as g,isSolid as h}from"./process-env.js";let $=/^---\n([\s\S]+?)\n---\n/,j=h?"component":"element";function O(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function b(e,t){let{regex:a,alia:l,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let f=s(e,u),d=n(f);if(d.isDirectory()){let e=b(f,{...t,base:c});if(e.length>0){let t={},r={path:O(u),key:O(i(c,f))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),n=e.splice(o,1)[0];e.length?Object.assign(t,!h&&n,{children:[h&&{...n,path:r.path===n.path?"/":n.path},...e].filter(Boolean)}):Object.assign(t,n)}o.push(Object.assign(t,r))}}else if(a.test(f)){let e=r(f,{encoding:"utf-8"}),t=function(e){let t=e.match($);return t&&t[1]?t[1].trim():null}(e),n=t?p(t):{},a=i(c,f),u=O(a);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...n}},l&&{[j]:`rr(() => import(/* webpackChunkName: '${a}' */'${s(l,a)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,n=e.split(" ").pop()||"jsx";r[n]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace($,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let y=s(f,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let T=`${h?"() => ":""}${d}(SuspenseComp, { comp: $1 })`,k=`import { ${d} } from "${u}";import SuspenseComp from "@app/suspense";${g?'import prefix from "@app/prefix-router";':""}`;l&&(k+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(m)||(T="$1",k="");export let routes=[];function E(e){return`${k}const routes = [{ path: "/", children: [${h?'{ path: "/" },':""} ${e}] }];const _routes = ${l?'merge([...routes, ...customRouter], "path")':"routes"};export default ${g?"prefix(_routes)":"_routes"};`}function S(e,t,r){let o=a(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}let D=s(f,"./src/pages");x?(// router
2
- S(y,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(y,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,T).slice(1,-1);Object.assign(route.data,{data:E(t)})},100)}),// demos
3
- S(y,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};b(y,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)})):// router
4
- S(D,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(D,{regex:/index\.tsx?$/,alia:"@/pages"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,T).slice(1,-1);Object.assign(route.data,{data:E(t)})},100)});
1
+ let e,t;import{readFileSync as r,readdirSync as o,statSync as n}from"fs";import{join as s,relative as a}from"path";import{watch as i}from"chokidar";import{load as p}from"js-yaml";import{hasCustomRouter as l}from"./config.js";import c from"./object-listener.js";import m from"./paths.js";import{FRAMEWORK as u,FRAMEWORKNAME as f,createElement as d,isLibrary as g,isReact as h,isSolid as x}from"./process-env.js";let $=/^---\n([\s\S]+?)\n---\n/,j=x?"component":"element";function O(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function b(e,t){let{regex:i,alia:l,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let f=s(e,u),d=n(f);if(d.isDirectory()){let e=b(f,{...t,base:c});if(e.length>0){let t={},r={path:O(u),key:O(a(c,f))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),n=e.splice(o,1)[0];e.length?Object.assign(t,!x&&n,{children:[x&&{...n,path:r.path===n.path?"/":n.path},...e].filter(Boolean)}):Object.assign(t,n)}o.push(Object.assign(t,r))}}else if(i.test(f)){let e=r(f,{encoding:"utf-8"}),t=function(e){let t=e.match($);return t&&t[1]?t[1].trim():null}(e),n=t?p(t):{},i=a(c,f),u=O(i);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...n}},l&&{[j]:`rr(() => import(/* webpackChunkName: '${i}' */'${s(l,i)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,n=e.split(" ").pop()||"jsx";r[n]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace($,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let y=`${x?"() => ":""}${d}(SuspenseComp, { comp: $1 })`,T=`import { ${d} } from "${f}";import SuspenseComp from "@app/suspense";${h?'import prefix from "@app/prefix-router";':""}`;l&&(T+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(u)||(y="$1",T="");export let routes=[];function k(e){return`${T}const routes = [{ path: "/", children: [${x?'{ path: "/" },':""} ${e}] }];const _routes = ${l?'merge([...routes, ...customRouter], "path")':"routes"};export default ${h?"prefix(_routes)":"_routes"};`}function E(e,t,r){let o=i(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}g?(// router
2
+ E(m.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(m.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,y).slice(1,-1);Object.assign(route.data,{data:k(t)})},100)}),// demos
3
+ E(m.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};b(m.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)})):// router
4
+ E(m.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(m.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,y).slice(1,-1);Object.assign(route.data,{data:k(t)})},100)});
package/lib/seo.js CHANGED
@@ -1,2 +1,2 @@
1
- import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as s}from"path";import{CONFIG as e}from"./config.js";import{routes as i}from"./routes.js";import{resolveProgramPath as m}from"./utils.js";import{outputConfig as p}from"./common.js";function n(t,o){try{r(t,o,"utf-8")}catch(t){//
2
- }}export const seo=()=>{let{domain:r,nojekyll:f,path:c}=e.seo||{};if(!r)return;let a=e.basename,h=a.endsWith("/")?a:`${a}/`,l=c&&m(c)||p?.path||process.cwd();t(l)||o(l),n(s(l,"CNAME"),r),n(s(l,"robots"),`Sitemap: https://${r}${h}sitemap.txt`);let u=[];!function t(o){o.forEach(o=>{u.push(`https://${r}${h}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(i),n(s(l,"sitemap.txt"),u.join("\n")),f&&n(s(l,".nojekyll"),"")};
1
+ import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as m}from"path";import{outputConfig as s}from"./common.js";import{CONFIG as i}from"./config.js";import e from"./paths.js";import{routes as p}from"./routes.js";import{resolveProgramPath as n}from"./utils.js";function a(t,o){try{r(t,o,"utf-8")}catch(t){//
2
+ }}export const seo=()=>{let{domain:r,nojekyll:f,path:h}=i.seo||{};if(!r)return;let c=i.basename,l=c.endsWith("/")?c:`${c}/`,j=h&&n(h)||s?.path||e.programPath;t(j)||o(j),a(m(j,"CNAME"),r),a(m(j,"robots"),`Sitemap: https://${r}${l}sitemap.txt`);let u=[];!function t(o){o.forEach(o=>{u.push(`https://${r}${l}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(p),a(m(j,"sitemap.txt"),u.join("\n")),f&&a(m(j,".nojekyll"),"")};
package/lib/swcrc.js CHANGED
@@ -1,3 +1,2 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import{isReact as r,isSolid as s,jsxImportSource as t}from"./process-env.js";// swc polyfill 策略,会复用 babel 链路,但效率比 babel 低
2
- let n={env:{targets:{chrome:"58",ie:"11"},// targets: ['last 2 version', '> 0.5%', 'ie 11', 'not dead'],
3
- mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((c=!1)=>{let a={module:{type:"es6",ignoreDynamic:!0,strict:!0,strictMode:!0,lazy:!0,noInterop:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:r&&c,development:c,importSource:t},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],s&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0},i=Object.assign(a,!c&&n);return o.swcrc&&(i=e(i,"function"==typeof o.swcrc?o.swcrc(c):o.swcrc)),i});
1
+ import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import{isReact as t,isSolid as s,jsxImportSource as n}from"./process-env.js";// swc polyfill 策略,会复用 babel 链路,但效率比 babel 低
2
+ let a={env:{targets:[">0.3%","defaults","supports es6-module","maintained node versions"],mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((p=!1)=>{let c={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0,topLevelAwait:!0,importMeta:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:t&&p,development:p,importSource:n},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),t=r.length;o<t;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],s&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0},i=Object.assign(c,!p&&a);return o.swcrc&&(i=e(i,"function"==typeof o.swcrc?o.swcrc(p):o.swcrc)),i});
package/lib/utils.js CHANGED
@@ -1,14 +1,14 @@
1
- import{readFileSync as e,writeFileSync as t}from"fs";import{join as o,resolve as r}from"path";import{transformFileSync as n}from"@swc/core";import{cacheDir as c}from"./process-env.js";import s from"./resolver-sync.js";let p=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;/** 获取导出标识
1
+ import{readFileSync as t,writeFileSync as e}from"fs";import{resolve as o}from"path";import{transformFileSync as r}from"@swc/core";import n from"./paths.js";import c from"./resolver-sync.js";let s=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;/** 获取导出标识
2
2
  * @param {string} path 文件地址
3
3
  * @returns {string[]} 包含的标识
4
- */export function getExportTokens(t){let o;let r=e(t,{encoding:"utf-8"}),n=[];for(;o=p.exec(r);)n.includes(o[1])||n.push(o[1]);return n}let u={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return n(e,u).code||"{}"}export function readConf(e,r){let n=o(c,`${r}.mjs`);return t(n,tfc(e),"utf-8"),import(n)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}/** 位于项目根目录下的位置
4
+ */export function getExportTokens(e){let o;let r=t(e,{encoding:"utf-8"}),n=[];for(;o=s.exec(r);)n.includes(o[1])||n.push(o[1]);return n}let p={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(t){return r(t,p).code||"{}"}export function readConf(t,o){let r=`${n.cachePath}/${o}.mjs`;return e(r,tfc(t),"utf-8"),import(r)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}/** 位于项目根目录下的位置
5
5
  * @param {string} src 路径
6
6
  * @returns {string} 位于项目根目录下的位置
7
- */export function resolveProgramPath(e){return r(process.cwd(),`./${e}`)}/** 位于项目根目录node_modules下的位置
7
+ */export function resolveProgramPath(t){return o(n.programPath,`./${t}`)}/** 位于项目根目录node_modules下的位置
8
8
  * @param {string} src 路径
9
9
  * @returns {string} 位于项目根目录node_modules下的位置
10
- */export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);/** 获取模块真实入口位置
10
+ */export const resolveNodeModulesPath=t=>resolveProgramPath(`node_modules/${t}`);/** 获取模块真实入口位置
11
11
  * @param {string} url 路径
12
12
  * @returns {string} 模块真实入口路径
13
- */export const realResolve=e=>s.resolveSync({},process.cwd(),e)||e;export function isObject(e){let t=typeof e;return null!==e&&("object"==t||"function"==t)}// eslint-disable-next-line no-unused-vars
14
- export function isFunction(e){if(!isObject(e))return!1;let t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t||"[object GeneratorFunction]"==t||"[object Proxy]"==t}
13
+ */export const realResolve=t=>c.resolveSync({},n.programPath,t)||t;export function isObject(t){let e=typeof t;return null!==t&&("object"==e||"function"==e)}// eslint-disable-next-line no-unused-vars
14
+ export function isFunction(t){if(!isObject(t))return!1;let e=Object.prototype.toString.call(t);return"[object Function]"==e||"[object AsyncFunction]"==e||"[object GeneratorFunction]"==e||"[object Proxy]"==e}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.1.0-beta.0",
3
+ "version": "3.1.0-beta.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",