@moneko/core 3.0.0-beta.8 → 3.0.0-beta.80
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 +1 -0
- package/{build → lib}/common.d.ts +1 -1
- package/lib/common.js +12 -0
- package/{build → lib}/coverage.d.ts +1 -1
- package/{build → lib}/coverage.js +1 -1
- package/{build → lib}/done.d.ts +2 -7
- package/lib/done.js +1 -0
- package/lib/envFlags.js +1 -0
- package/lib/esm.d.ts +1 -0
- package/lib/esm.js +1 -0
- package/lib/frontmatter-loader.cjs +6 -0
- package/lib/generate-api.d.ts +1 -0
- package/lib/generate-api.js +1 -0
- package/lib/html-add-entry-attr.js +1 -0
- package/{build → lib}/html-plugin-option.d.ts +1 -1
- package/lib/html-plugin-option.js +1 -0
- package/lib/index.d.ts +4 -36
- package/lib/index.js +1 -1
- package/lib/modifyVars.js +1 -0
- package/lib/module-federation.js +1 -0
- package/lib/module.config.js +1 -0
- package/lib/net.d.ts +3 -0
- package/lib/net.js +1 -0
- package/{build → lib}/process-env.d.ts +9 -3
- package/lib/process-env.js +1 -0
- package/lib/routes.d.ts +1 -0
- package/lib/routes.js +1 -0
- package/lib/seo.js +1 -0
- package/{build → lib}/swcrc.d.ts +1 -1
- package/lib/swcrc.js +1 -0
- package/{build → lib}/tsloader.config.d.ts +1 -1
- package/lib/tsloader.config.js +1 -0
- package/{build → lib}/utils.d.ts +9 -4
- package/lib/utils.js +1 -0
- package/lib/virtual-module-plugin.d.ts +11 -0
- package/lib/virtual-module-plugin.js +1 -0
- package/{build → lib}/webpack.common.d.ts +4 -0
- package/lib/webpack.common.js +1 -0
- package/lib/webpack.dev.js +4 -0
- package/lib/webpack.prod.d.ts +3 -0
- package/lib/webpack.prod.js +1 -0
- package/package.json +28 -38
- package/template/index.html +38 -1
- package/typings/global.d.ts +38 -20
- package/build/common.js +0 -12
- package/build/done.js +0 -1
- package/build/envFlags.js +0 -1
- package/build/html-add-entry-attr.js +0 -1
- package/build/html-plugin-option.js +0 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -1
- package/build/modifyVars.js +0 -1
- package/build/module-federation.js +0 -1
- package/build/module.config.js +0 -1
- package/build/process-env.js +0 -1
- package/build/seo.js +0 -1
- package/build/swcrc.js +0 -1
- package/build/tsloader.config.js +0 -1
- package/build/utils.js +0 -1
- package/build/webpack.common.js +0 -1
- package/build/webpack.dev.d.ts +0 -2
- package/build/webpack.dev.js +0 -4
- package/build/webpack.prod.js +0 -1
- package/lib/normalize.css +0 -254
- package/lib/packages/library/bootstrap.js +0 -1
- package/lib/packages/library/index.d.ts +0 -4
- package/lib/packages/library/index.js +0 -1
- package/lib/refresh-rem.d.ts +0 -0
- package/lib/refresh-rem.js +0 -1
- package/lib/router/index.d.ts +0 -52
- package/lib/router/index.js +0 -1
- /package/lib/{packages/library/bootstrap.d.ts → cleanup.d.ts} +0 -0
- /package/{build → lib}/envFlags.d.ts +0 -0
- /package/{build → lib}/has-pkg.d.ts +0 -0
- /package/{build → lib}/has-pkg.js +0 -0
- /package/{build → lib}/html-add-entry-attr.d.ts +0 -0
- /package/{build → lib}/minify.d.ts +0 -0
- /package/{build → lib}/minify.js +0 -0
- /package/{build → lib}/modifyVars.d.ts +0 -0
- /package/{build → lib}/module-federation.d.ts +0 -0
- /package/{build → lib}/module.config.d.ts +0 -0
- /package/{build → lib}/resolver-sync.d.ts +0 -0
- /package/{build → lib}/resolver-sync.js +0 -0
- /package/{build → lib}/seo.d.ts +0 -0
- /package/{build/webpack.prod.d.ts → lib/webpack.dev.d.ts} +0 -0
- /package/{build → lib}/yarn-argv.d.ts +0 -0
- /package/{build → lib}/yarn-argv.js +0 -0
package/lib/cleanup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as o,readdirSync as t,rmdirSync as r,statSync as c,unlinkSync as n}from"fs";import{join as s}from"path";import{apiCacheDir as e,frameworkCacheDir as i}from"./process-env.js";function f(){try{n(s(i,"example.js"))}catch(o){}try{n(s(i,"route.js"))}catch(o){}!function e(i){o(i)&&(t(i).forEach(o=>{let t=s(i,o);c(t).isDirectory()?e(t):n(t)}),r(i))}(e)}process.on("SIGINT",function(){f()}),process.on("exit",function(){f()});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, ConfigType } from '../typings/global.
|
|
1
|
+
import type { AppType, ConfigType } from '../typings/global.js';
|
|
2
2
|
export declare const ENTRYPATH: Record<AppType, string>;
|
|
3
3
|
export declare const log: (msg: string) => void;
|
|
4
4
|
export declare const CONFIG: ConfigType<"swc">;
|
package/lib/common.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as r,FRAMEWORK as l,PROGRAMPATH as a,jsxImportSource as c,pkgName as m}from"./process-env.js";import{isFunction as p,readConf as u}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let d=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"],h={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"}}};"single-component"===n&&(h=!1);let g={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",designSize:"mobile"===n?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${a}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:h,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:d,css:d,js:d,media:d,fonts:d},mdx:{jsxImportSource:c,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"}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=g,y=null,x={},b={};try{y=t.join(a,"./config/index.ts"),e.accessSync(y,e.constants.R_OK)}catch(e){y=null}if(y)try{let e=(await u(y,"index")).default;x=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(r){let o=null;try{o=t.join(a,`./config/${r}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await u(o,r)).default;b=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(f=i(f,x,b)).compiler&&f.minifier&&(f.minifier.js||Object.assign(f.minifier,{js:{type:"terser"}}),f.minifier.css||Object.assign(f.minifier,{css:{type:"cssnano"}})),!1===f.devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&f.htmlPluginOption&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
|
|
2
|
+
(function(l) {
|
|
3
|
+
if (l.search[1] === '/' ) {
|
|
4
|
+
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
5
|
+
return s.replace(/~and~/g, '&')
|
|
6
|
+
}).join('?');
|
|
7
|
+
window.history.replaceState(null, null,
|
|
8
|
+
l.pathname.slice(0, -1) + decoded + l.hash
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}(window.location))
|
|
12
|
+
`}));export const CONFIG=f;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,log};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CoverageType, ProjectCoverageType } from '../typings/global.
|
|
1
|
+
import type { CoverageType, ProjectCoverageType } from '../typings/global.js';
|
|
2
2
|
export declare const coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 s}from"./process-env.js";export const coverage={};try{let i=o(s,"./coverage/clover.xml");e(i,r.R_OK);let m=new t({explicitArray:!1,async:!1}),p=c(i,{encoding:"utf-8"});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.$})})}})}catch(e){}
|
package/{build → lib}/done.d.ts
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Compiler } from 'webpack';
|
|
1
2
|
declare class DoneWebpackPlugin {
|
|
2
3
|
options: {
|
|
3
4
|
done?: () => void;
|
|
@@ -5,12 +6,6 @@ declare class DoneWebpackPlugin {
|
|
|
5
6
|
constructor(options: {
|
|
6
7
|
done?: () => void;
|
|
7
8
|
});
|
|
8
|
-
apply(compiler:
|
|
9
|
-
hooks: {
|
|
10
|
-
done: {
|
|
11
|
-
tap: (arg0: string, arg1: () => void) => void;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}): void;
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
15
10
|
}
|
|
16
11
|
export default DoneWebpackPlugin;
|
package/lib/done.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",()=>{this.options.done?.()})}};
|
package/lib/envFlags.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"fs";import r from"path";import{CONFIG as t}from"./common.js";import{coverage as e}from"./coverage.js";import o from"./html-plugin-option.js";import{APPTYPE as s,NODE_ENV as n,PACKAGENAME as f,PROGRAMPATH as a,hasAntd as c,programInfo as m}from"./process-env.js";import{toUpperCaseString as p}from"./utils.js";let l="library"===s?"site":"src",g=!1;try{let t=r.join(a,"./src/index.ts");i.accessSync(t,i.constants.R_OK),g=t}catch(i){g=!1}let y={projectName:JSON.stringify(p(f)),projectCoverage:JSON.stringify(e),providerConfig:JSON.stringify({prefixCls:t.prefixCls,iconPrefixCls:`${t.prefixCls}-icon`,theme:t.theme}),fallbackCompPath:JSON.stringify(t.fallbackCompPath),ReactDOMPath:JSON.stringify("react-dom/client"),favicon:JSON.stringify(o.favicon),hasLocales:JSON.stringify(i.existsSync(r.join(a,`./${l}/locales`))),hasPersist:JSON.stringify(i.existsSync(r.join(a,`./${l}/persist.ts`))),layoutSider:JSON.stringify(t.layoutSider),hasAntd:JSON.stringify(c),APPTYPE:JSON.stringify(s),APPENTRY:JSON.stringify(g),programInfo:JSON.stringify({...m,routeBaseName:t.routeBaseName,designSize:t.designSize,routerMode:t.routerMode,renderMode:t.mode}),"process.env":JSON.stringify({NODE_ENV:n,iconfont:t.iconfont,...t.env})};export default y;
|
package/lib/esm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
package/lib/esm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function t(t,...e){let r=t.raw[0];for(let a=0;a<e.length;a++)r+=e[a]+t.raw[a+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e;import{existsSync as t,mkdirSync as n,readFile as r,readFileSync as l,statSync as o,unlink as i,writeFile as c}from"fs";import{dirname as u,join as s}from"path";import{watch as a}from"chokidar";import f from"typescript";import{CONFIG as p}from"./common.js";import{APPTYPE as m,apiCacheDir as g,frameworkCacheDir as $}from"./process-env.js";import{resolveProgramPath as d}from"./utils.js";import{alias as h}from"./webpack.common.js";let{ScriptKind:b,ScriptTarget:x,SyntaxKind:y,createSourceFile:j,forEachChild:k,getLeadingCommentRanges:T,isInterfaceDeclaration:E,isQuestionToken:S,isPropertySignature:w,isFunctionTypeNode:B,isUnionTypeNode:N,isMethodSignature:v}=f,F={};function O(e){let t=T(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r){let e=r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim();return e}}return null}function _(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function z(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}${r?" 📧":" ⎋"}](${n})`}return null}function I(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let K=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function q(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(F[e]){let n=`/${[p.routeBaseName,F[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(K,e=>`\\color{#009688}{${e}}`)),n}function A(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/(\{|\}|\[|\]|\(|\)|=>|keyof|typeof|true|false)/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function C(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}function L(){}let W={},Z={};function D(o,a){t($)||n($),t(g)||n(g);let p=o.replace(RegExp(`^${h["@pkg"]}`),""),m=u(p).replace(/^\//,""),d=s(g,m),T=p.split("/").pop()?.replace(/\.tsx?/,".md");if(!T)return;W[m]||(W[m]=[]);let K=W[m].indexOf(T),D=s(d,T);if("deleted"===a)delete Z[D],i(D,L),-1!==K&&W[m].splice(K,1);else{let e=function(e){let t=l(e,"utf-8"),n=j(e,t,x.Latest,!0,b.TS),r="";return k(n,e=>{E(e)?r+=function(e){let t=e.name.text;Object.assign(F,{[e.name.text]:u(e.getSourceFile().fileName).replace(h["@pkg"],"")});let n=O(e),r=_(n),l=C(n),o=I(n)?.split("|")||[],i=o.includes("comment"),c=o.includes("initial"),s=o.includes("optional"),a=o.includes("version"),p=o.includes("author"),m=l?`\\color{|4||0.45}{${t}}`:t,g=(function(e){let t=[];if(e.heritageClauses){for(let n of e.heritageClauses)if(n.token===f.SyntaxKind.ExtendsKeyword)for(let e of n.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${q(A(e))}</n-tag>`),$=[l,m,r&&`\\color{#52c11b|1||0.9}{${r}}`,g.length>0&&`<sub>\`extends\`</sub> ${g.join(" ")}`].filter(Boolean).join(" "),d=`## ${$}`,b=e.members.filter(e=>w(e)&&e.type?.kind!==y.NeverKeyword||v(e)),x=[];if(b.length){b.forEach(e=>{let t=q(A(v(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),r=O(e),l=A(e.name.getText());!l||l.startsWith("\\color")||(v(e)||function(e){if(e.type){if(!N(e.type))return B(e.type);for(let t of e.type.types)if(B(t))return!0}return!1}(e)||t?.includes("=>")?l=`\\color{#f9a913}{${l}}`:/^("|')(.+)("|')$/.test(l)||(l=`\\color{#4c81db}{${l}}`));let o=e.questionToken&&S(e.questionToken);x.push([l,!s&&`\\color{${o?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${o?"✘":"✔"}}`,!i&&A(C(r)),t,!c&&A(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(r)),!a&&A(_(r)),!p&&(z(r)||z(n))])});let e=!1,t=!1,r=!1,l=!1;x.forEach(n=>{!i&&n[2]&&(l=!0),!c&&n[4]&&(r=!0),!a&&n[5]&&(t=!0),!p&&n[6]&&(e=!0)}),d+="\n";let o=["属性",!s&&"必要",l&&"说明","类型",r&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");d+=`|${o}|`;let u=[":-",!s&&":-",l&&":-",":-",r&&":-",t&&":-",e&&":-"].filter(Boolean);d+="\n";let f=u.join("|");d+=`|${f}|`,x.forEach(n=>{d+="\n";let o=[n[0]||"-",!s&&(n[1]||"-"),l&&(n[2]||"-"),n[3]||"-",r&&(n[4]||"-"),t&&(n[5]||"-"),e&&(n[6]||"-")].filter(Boolean).join("|");d+=`|${o}|`}),d+="\n"}return d+="\n"}(e):f.isEnumDeclaration(e)&&(r+=function(e){let t=e.name.text;Object.assign(F,{[e.name.text]:u(e.getSourceFile().fileName).replace(h["@pkg"],"")});let n=O(e),r=I(n)?.split("|")||[],l=r.includes("comment"),o=r.includes("version"),i=r.includes("author"),c=`## ${t}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=A(e.name.getText()),c=O(e),u=A(function(e){let t=e.initializer;return t&&f.isStringLiteral(t)?` '${t.text}'`:null}(e)),s=A(_(c)),a=A(C(c));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!l&&a,u,!o&&s,!i&&(z(c)||z(n))])});let r=!1,u=!1,s=!1;t.forEach(e=>{!l&&e[1]&&(s=!0),!o&&e[3]&&(u=!0),!i&&e[4]&&(r=!0)}),c+="\n";let a=["属性",s&&"说明","值",u&&"版本",r&&"作者"].filter(Boolean).join("|");c+=`|${a}|`;let p=[":-",s&&":-",":-",u&&":-",r&&":-"].filter(Boolean);c+="\n";let m=p.join("|");c+=`|${m}|`,t.forEach(e=>{c+="\n";let t=[e[0]||"-",s&&(e[1]||"-"),e[2]||"-",u&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");c+=`|${t}|`})}return c+="\n\n"}(e))}),r}(o);if(e){let l=Z[D];l?l!==e&&(t(d)||n(d),c(D,e,"utf-8",L)):r(D,{encoding:"utf-8"},(r,l)=>{(r||l!==e)&&(Z[D]=l,t(d)||n(d),c(D,e,"utf-8",L))}),-1===K&&W[m].push(T)}else delete Z[D],i(D,L),-1!==K&&W[m].splice(K,1)}let G=`export default ${JSON.stringify(W)};`;e!==G&&(e=G,c(s(g,"index.js"),G,"utf-8",L))}"library"===m&&function(){let e=[],t=a(d("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function n(e){return/\.tsx?$/.test(e)&&o(e).isFile()}t.on("add",t=>{n(t)&&(D(t,"added"),e.push(t))}),t.on("change",e=>{n(e)&&D(e,"change")}),t.on("unlink",t=>{n(t)&&(D(t,"deleted"),e.splice(e.indexOf(t),1))}),t.on("ready",()=>{e.forEach(e=>{D(e,"change")})}),process.on("SIGINT",function(){t.close()})}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"html-webpack-plugin";export default class{constructor(t){this.entryMatchCallback=t}apply(a){a.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",e=>{let r=a.options.plugins.find(a=>a instanceof t);if(r){let t=r.getHooks(e);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&"string"==typeof t.attributes?.src&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"path";import{merge as t}from"webpack-merge";import{CONFIG as i}from"./common.js";import{PACKAGENAME as o,PROGRAMPATH as a,pkgName as m,programInfo as p}from"./process-env.js";let{template:r,favicon:n,...l}=i.htmlPluginOption||{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`},s=t({title:i.env?.PROJECTNAME||o.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:p.description||""},tags:[],template:e.join(a,r),favicon:e.join(a,n)},l);export default s;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export type PartialCommomType<T = 'swc'> = Partial<CommomType<T>>;
|
|
6
|
-
/** 一些项目基本信息 */
|
|
7
|
-
export declare const projectBasicInfo: {
|
|
8
|
-
projectName: string;
|
|
9
|
-
providerConfig: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
prefixCls: string;
|
|
12
|
-
iconPrefixCls: string;
|
|
13
|
-
input: React.InputHTMLAttributes<HTMLInputElement>;
|
|
14
|
-
};
|
|
15
|
-
programInfo: {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
version: string;
|
|
19
|
-
type: "mobile" | "site" | "back-stage" | "single-spa" | "library";
|
|
20
|
-
author: {
|
|
21
|
-
name: string;
|
|
22
|
-
url?: string | undefined;
|
|
23
|
-
email?: string | undefined;
|
|
24
|
-
};
|
|
25
|
-
repository: {
|
|
26
|
-
type?: string | undefined;
|
|
27
|
-
url?: string | undefined;
|
|
28
|
-
directory?: string | undefined;
|
|
29
|
-
};
|
|
30
|
-
routerMode: "hash" | "browser" | "memory";
|
|
31
|
-
routeBaseName: string;
|
|
32
|
-
designSize: number;
|
|
33
|
-
renderMode: "ssr" | "csr";
|
|
34
|
-
};
|
|
35
|
-
coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
|
|
36
|
-
};
|
|
1
|
+
export * from './process-env.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export * from '../typings/global.js';
|
|
4
|
+
export { default as envFlags } from './envFlags.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./process-env.js";export*from"./utils.js";export*from"../typings/global.js";export{default as envFlags}from"./envFlags.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as i}from"./common.js";import o from"./html-plugin-option.js";let f=i.prefixCls||"n",n={};Object.assign(n,{"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":JSON.stringify(o.favicon)},i.modifyVars||{});export default n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as l}from"./utils.js";let a=r.NormalModuleReplacementPlugin,i={},m={},n={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?m[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(m[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:n,exposes:m})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new a(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));
|
|
@@ -0,0 +1 @@
|
|
|
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"./common.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modifyVars.js";import{APPTYPE as n,DEV as i,FRAMEWORK as c,__dirname 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="single-spa"===n?l:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};i&&(x="style-loader");let $=[...t.cssModules,`@moneko/${c}`,"neko-ui"].map(u),j=[...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(f)],b=["components","example","mock","site","src"].map(f),v=[x,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!i}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[s]))return/(.*(?<!\.global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(i)},h={rules:[{test:/\.mdx?$/,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(m,"./frontmatter-loader.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/,type:"webassembly/async"},{test:/\.txt$/,type:"asset/source"},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:b.concat(t.rulesInclude?.media?.map(u)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)}},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:b.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:v,include:b.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:b.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:b.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default h;
|
package/lib/net.d.ts
ADDED
package/lib/net.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createConnection as t}from"net";import{networkInterfaces as e}from"os";import r from"webpack-dev-server";let{internalIPSync:o}=r;export function getNetworkAdress(){let t=e();for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let r=t[e];for(let t=0;t<r.length;t++){let e=r[t];if("IPv4"===e.family&&"127.0.0.1"!==e.address&&!e.address.startsWith("169.254")&&!e.internal)return e.address}}}export function getIPv4(){return o("v4")}export function getPort(e,r,o="0.0.0.0"){return new Promise(n=>{let s=t(e,o);s.on("connect",()=>{s.destroy(),n(getPort(e+1,r,o))}),s.on("error",()=>{n(e)})})}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type { AppType } from '../typings/global.
|
|
1
|
+
import type { AppType, Framework } from '../typings/global.js';
|
|
2
2
|
export declare const __dirname: string;
|
|
3
3
|
export declare const APPTYPE: AppType;
|
|
4
|
+
export declare const FRAMEWORK: Framework;
|
|
5
|
+
export declare const isReact: boolean;
|
|
6
|
+
export declare const isSolid: boolean;
|
|
7
|
+
export declare const jsxImportSource: string;
|
|
4
8
|
export declare const PROGRAMPATH: string;
|
|
5
9
|
export declare const PACKAGENAME: string;
|
|
6
10
|
export declare const PACKAGEVERSION: string;
|
|
7
11
|
export declare const pkgName: string;
|
|
12
|
+
export declare const DEV: boolean;
|
|
13
|
+
export declare const frameworkCacheDir: ".git/" | `node_modules/.cache/${string}`;
|
|
14
|
+
export declare const apiCacheDir: string;
|
|
15
|
+
export declare const cacheDir: string;
|
|
8
16
|
export declare const NODE_ENV: string | undefined;
|
|
9
17
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
10
|
-
export declare const DEV: boolean;
|
|
11
18
|
export declare let hasEslintConfig: boolean;
|
|
12
19
|
export declare let hasStylelintConfig: boolean;
|
|
13
|
-
export declare const hasReact: boolean;
|
|
14
20
|
export declare const hasAntd: boolean;
|
|
15
21
|
export declare const programInfo: {
|
|
16
22
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as e,mkdirSync as o,readFileSync as r}from"fs";import{join as t}from"path";import s from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c 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 isReact="react"===FRAMEWORK;export const isSolid="solid-js"===FRAMEWORK;export const jsxImportSource={react:"react","solid-js":"solid-js/h"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=r(t(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(a).name;export const DEV="development"===process.env.NODE_ENV;export const frameworkCacheDir=p(DEV?".git/":`node_modules/.cache/${PACKAGENAME}`);export const apiCacheDir=t(frameworkCacheDir,"./apis");export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/@moneko/cli/");e(cacheDir)||o(cacheDir,{recursive:!0});export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||c.config;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasAntd=n("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let e=r(p("package.json"),{encoding:"utf-8"}),{description:o,author:t,repository:s,eslintConfig:n,stylelint:c}=JSON.parse(e);programInfo.author="string"==typeof t?{name:t}:t,programInfo.repository="string"==typeof t?{url:s}:s,programInfo.description=o,hasEslintConfig=!!n,hasStylelintConfig=!!c}
|
package/lib/routes.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/routes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e,t;import{existsSync as r,mkdirSync as o,readFileSync as n,readdirSync as s,statSync as i,writeFile as l}from"fs";import{join as c,relative as m}from"path";import{watch as p}from"chokidar";import{load as a}from"js-yaml";import{APPTYPE as u,DEV as f,FRAMEWORK as d,PROGRAMPATH as g,frameworkCacheDir as h}from"./process-env.js";let $=/^---\n([\s\S]+?)\n---\n/;function j(e,t){let{regex:r,alia:o,base:l=e,outputSource:p}=t,u=s(e);return u.reduce((s,u)=>{let f=c(e,u),d=i(f);if(d.isDirectory()){let e=j(f,{...t,base:l});if(e.length>0){let t={},r={path:u,key:m(l,f)};if(p)Object.assign(t,{children:e});else{let o=e.splice(0,1)[0];e.length?Object.assign(t,{children:[{...o,path:"/",key:r.key},...e]}):Object.assign(t,o)}s.push(Object.assign(t,r))}}else if(r.test(f)){let e=n(f,{encoding:"utf-8"}),t=function(e){let t=e.match($);return t&&t[1]?t[1].trim():null}(e),r=t?a(t):{},i=m(l,f);s.push(Object.assign({path:u,key:i,meta:{...r}},o&&{component:`rr(() => import(/* webpackChunkName: '${i}' */'${c(o,i)}'))rr`},p&&{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 s},[])}let x=c(g,"./components");function k(e){if(e)throw e}function y(){e&&clearTimeout(e),e=setTimeout(()=>{let e={react:"createElement","solid-js":"createComponent"}[d],t=`() => ${e}(SuspenseComp, { comp: $1 })`,n=`import { ${e} } from "${d}";import { SuspenseComp } from "@moneko/${d}";`;["react","solid-js"].includes(d)||(t="$1",n="");let s=JSON.stringify(j(x,{regex:/README\.mdx?$/,alia:"@pkg"})).replace(/"rr\((.+?)\)rr"/g,t);r(h)||o(h),l(c(h,"route.js"),`${n}export default ${s}`,"utf-8",k)},100)}function b(){t&&clearTimeout(t),r(h)||o(h),t=setTimeout(()=>{let e=Object.fromEntries(j(x,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).map(e=>[e.key,e.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)]));l(c(h,"example.js"),`export default ${JSON.stringify(e)}`,"utf-8",k)},100)}function O(e,t,r){let o=p(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}"library"===u&&(f?(O(x,/(?<!README\.mdx?)$/,y),O(x,/(?<!\/examples\/(.+)\.md)$/,b)):(y(),b()));
|
package/lib/seo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as t,mkdirSync as o,readdirSync as e,statSync as r,writeFile as s}from"fs";import{join as m}from"path";import{CONFIG as i}from"./common.js";import{APPTYPE as p,PROGRAMPATH as n}from"./process-env.js";import{resolveProgramPath as c}from"./utils.js";import{outputConfig as f}from"./webpack.common.js";export const seo=()=>{let{domain:a,nojekyll:u,path:l}=i.seo||{};if(!a)return;let h=i.routeBaseName,$=h.endsWith("/")?h:`${h}/`,j=l&&c(l)||f?.path||process.cwd(),E=t=>{if(t)throw t};t(j)||o(j),s(m(j,"CNAME"),a,"utf-8",E),s(m(j,"robots"),`Sitemap: https://${a}${$}sitemap.txt`,"utf-8",E);let d="";"library"===p&&(d=(function t(o,s,m){let i=[],p=e(o);return p.forEach(function(e){if("static"===e)return!1;let p=`${o}/${e}`,c=r(p);c&&c.isDirectory()?i=i.concat(t(p,s,m)):p.endsWith("README.mdx")&&i.push(`https://${s}${m}${p.replace(`${n}/components/`,"").replace("/README.mdx","")}`)}),i})(m(n,"./components"),a,$).join("\n")),s(m(j,"sitemap.txt"),d,"utf-8",E),u&&s(m(j,".nojekyll"),"","utf-8",E)};
|
package/{build → lib}/swcrc.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config as SwcConfig
|
|
1
|
+
import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
2
2
|
export declare const swcMinifyOption: JsMinifyOptions;
|
|
3
3
|
declare const _default: (isDev?: boolean) => SwcConfig;
|
|
4
4
|
export default _default;
|
package/lib/swcrc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import{isReact as r,isSolid as s,jsxImportSource as t}from"./process-env.js";let n={env:{targets:["last 2 version","> 0.5%","ie 11","not dead"],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((a=!1)=>{let c={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&&a,development:a,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(c,!a&&n);return o.swcrc&&(i=e(i,"function"==typeof o.swcrc?o.swcrc(a):o.swcrc)),i});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"fs";import r from"ts-import-plugin";import o from"webpack-merge";import{CONFIG as e}from"./common.js";import{isFunction as m,readConf as s,resolveProgramPath as a}from"./utils.js";let i=[];Array.isArray(e.importOnDemand)&&Object.assign(i,e.importOnDemand.map(t=>r(t)));let n=[...i],p={transpileOnly:!0,getCustomTransformers:()=>({before:n})};try{let r=a("tsloader.config.ts");t.accessSync(r,t.constants.R_OK);let e=(await s(r,"tsloader.config")).default;p=o(p,m(e)?e(process):e)}catch(t){}export default p;
|
package/{build → lib}/utils.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function tfc(filepath: string): string;
|
|
2
|
+
export declare function readConf(src: string, name: string): Promise<any>;
|
|
2
3
|
export declare function toUpperCaseString(string: string): string;
|
|
3
|
-
|
|
4
|
-
type ProgramPath<T extends string> = `~/${T extends string ? T : string}`;
|
|
4
|
+
type ProgramPath<T extends string> = `${T extends string ? T : string}`;
|
|
5
5
|
type NodeModulesPath<T> = ProgramPath<`node_modules/${T extends string ? T : string}`>;
|
|
6
6
|
/** 位于项目根目录下的位置
|
|
7
7
|
* @param {string} src 路径
|
|
@@ -12,7 +12,12 @@ export declare function resolveProgramPath<T extends string>(src: T): ProgramPat
|
|
|
12
12
|
* @param {string} src 路径
|
|
13
13
|
* @returns {string} 位于项目根目录node_modules下的位置
|
|
14
14
|
*/
|
|
15
|
-
export declare const resolveNodeModulesPath: <T extends string>(src: T) =>
|
|
15
|
+
export declare const resolveNodeModulesPath: <T extends string>(src: T) => `${`node_modules/${T extends string ? T : string}` extends infer T_1 ? T_1 extends `node_modules/${T extends string ? T : string}` ? T_1 extends string ? T_1 : string : never : never}`;
|
|
16
|
+
/** 获取模块真实入口位置
|
|
17
|
+
* @param {string} url 路径
|
|
18
|
+
* @returns {string} 模块真实入口路径
|
|
19
|
+
*/
|
|
20
|
+
export declare const resolve: (url: string) => string;
|
|
16
21
|
export declare function isObject(target: unknown): target is object;
|
|
17
22
|
export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
|
|
18
23
|
export {};
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as e}from"fs";import o from"path";import{transformFileSync as t}from"@swc/core";import{cacheDir as r}from"./process-env.js";import n from"./resolver-sync.js";let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return t(e,c).code||"{}"}export function readConf(t,n){let c=o.join(r,`${n}.mjs`);return e(c,tfc(t),"utf-8"),import(c)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(e){return o.resolve(process.cwd(),`./${e}`)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>n.resolveSync({},process.cwd(),e)||e;export function isObject(e){let o=typeof e;return null!==e&&("object"==o||"function"==o)}export function isFunction(e){if(!isObject(e))return!1;let o=Object.prototype.toString.call(e);return"[object Function]"==o||"[object AsyncFunction]"==o||"[object GeneratorFunction]"==o||"[object Proxy]"==o}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Compiler } from 'webpack';
|
|
2
|
+
interface VirtualModulePluginOption {
|
|
3
|
+
name: string;
|
|
4
|
+
contents: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
declare class VirtualModulePlugin {
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options: VirtualModulePluginOption);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
}
|
|
11
|
+
export default VirtualModulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"webpack-virtual-modules";import{resolveNodeModulesPath as o}from"./utils.js";export default class{constructor(t){this.options=t}apply(i){let s=o(`${this.options.name}.js`),r=new t({[s]:JSON.stringify(this.options.contents)});r.apply(i),i.hooks.compilation.tap("VirtualModulePlugin",function(t){try{r.writeModule(s,JSON.stringify({a:2}))}catch(o){t.errors.push(o)}})}};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import './cleanup.js';
|
|
2
|
+
import './generate-api.js';
|
|
3
|
+
import './routes.js';
|
|
1
4
|
import type { WebpackConfiguration } from 'webpack-dev-server';
|
|
5
|
+
export declare const alias: Record<string, string>;
|
|
2
6
|
export declare const outputConfig: WebpackConfiguration['output'];
|
|
3
7
|
declare const config: WebpackConfiguration;
|
|
4
8
|
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
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,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./done.js";import p from"./envFlags.js";import"./generate-api.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as g,FRAMEWORK as j,PACKAGENAME as h,PROGRAMPATH as b,frameworkCacheDir as y,hasEslintConfig as w,hasStylelintConfig as x}from"./process-env.js";import"./routes.js";import{seo as k}from"./seo.js";import{resolveNodeModulesPath as v,resolveProgramPath as O}from"./utils.js";import C from"./virtual-module-plugin.js";let P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],$=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(b),B=!1,S=!1;for(let e=0,t=A.length;e<t;e++)$.includes(A[e])&&(S=!0),P.includes(A[e])&&(B=!0);B||(B=w),S||(S=x);let T=S?(await import("stylelint-webpack-plugin")).default:null,M=B?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":O("src"),"@framework-cache-dir":y};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":O("site"),"@pkg":O("components"),[h]:O("components")});let D=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:O("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:g,clean:!0,publicPath:a};let F=v(`@moneko/${j}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:O("umd")}),F=O(g?"example/index.ts":"src/index.ts"),outputConfig.path=O(g?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let K={main:F};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.routeBaseName.split("/").filter(Boolean).length,W=`${Array(L).fill("..").join("/")+(L?"/":"")}404.html`,{pathSegmentsToKeep:N=L,path:R=W}=l.fixBrowserRouter||{},_={entry:K,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new n.AutomaticPrefetchPlugin,...u,M&&new M({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),T&&new T({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(c),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${N||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(D),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new n.DefinePlugin(p),new n.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),l.sourceMap&&new n.SourceMapDevToolPlugin(l.sourceMap),l.bar&&new o(l.bar),new r({done:()=>{!g&&l.seo&&k(),l.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C({name:"env-flags",contents:p}),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:l.externals,output:outputConfig};export default _;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import r from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as a}from"./has-pkg.js";import{getIPv4 as p,getPort as i}from"./net.js";import{CUSTOMCONFIG as l,isReact as m}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import d from"./webpack.common.js";let{yellow:v,green:h}=o,f=p(),u=s.devServer.port||3e3,w=await i(u,65535,s.devServer.host),g=s.devServer.port!==w,k=a("@moneko/mock"),y=k&&await import("@moneko/mock"),$=m&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,S=!1;s.cacheDirectory&&(S={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${l||"default"}-development`});let b=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=w;let j="/"===s.routeBaseName,x=s.devServer.https?"https:":"http:",D=j?"":s.routeBaseName;export default t(d,{devtool:b,mode:"development",cache:S,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:w,historyApiFallback:j||{index:D.endsWith("/")?D:`${D}/`,disableDotRule:!0},https:s.devServer.https,proxy:s.proxy,allowedHosts:s.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")||/\/node_modules\//.test(e)}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&n(y)&&y(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new r.HotModuleReplacementPlugin,$&&new $,new e({compilationSuccessInfo:{messages:[`You application is running here:
|
|
2
|
+
|
|
3
|
+
Local: ${o.cyan(`${x}//${s.devServer.host}:${w}${D}`)}
|
|
4
|
+
Network: ${o.cyan(`${x}//${f}:${w}${D}`)}`],notes:g?[`Port ${v(u)} is in use, trying ${h(w)} instead`]:[]},clearConsole:!0})].filter(Boolean)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{CONFIG as s}from"./common.js";import{getMinifyOption as t}from"./minify.js";import{CUSTOMCONFIG as c}from"./process-env.js";import p from"./webpack.common.js";let{cssnanoMinify:l,swcMinify:a}=e,u="swc"===s.compiler?"swc":"terser",f="swc"===s.compiler?"swc":"cssnano",d=[];s.minifier&&(s.minifier.js&&d.push(new n(t(s.minifier.js?.type||u,s.minifier.js?.options))),s.minifier.css&&d.push(new e({minify:{swc:a,cssnano:l}[s.minifier.css?.type||f],minimizerOptions:s.minifier.css?.options})));let h={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:d},k=!1;s.cacheDirectory&&(k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});export default r(p,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:k,optimization:h,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new m.optimize.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
|
package/package.json
CHANGED
|
@@ -1,77 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.80",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
10
|
-
"build-src": "swc src -d lib -C module.type=es6 -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true --copy-files",
|
|
11
|
-
"build:types": "tsc && tsc --project cli.json",
|
|
12
|
-
"postbuild": "node ./copy.js ./prefix ./lib",
|
|
13
|
-
"prebuild": "rm -rf ./build && rm -rf ./lib"
|
|
8
|
+
"build": "swc src -d lib -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
|
|
9
|
+
"prebuild": "rm -rf ./lib && tsc"
|
|
14
10
|
},
|
|
15
11
|
"keywords": [],
|
|
16
12
|
"author": "moneko",
|
|
17
13
|
"license": "MIT",
|
|
18
14
|
"dependencies": {
|
|
19
|
-
"@emotion/css": "11.11.0",
|
|
20
|
-
"@mapbox/rehype-prism": "0.8.0",
|
|
21
15
|
"@mdx-js/loader": "2.3.0",
|
|
22
|
-
"@moneko/common": "1.1.0",
|
|
23
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
24
16
|
"@soda/friendly-errors-webpack-plugin": "1.8.1",
|
|
25
|
-
"@swc/core": "1.3.
|
|
26
|
-
"@swc/css": "0.0.
|
|
17
|
+
"@swc/core": "1.3.62",
|
|
18
|
+
"@swc/css": "0.0.28",
|
|
27
19
|
"@swc/helpers": "0.5.1",
|
|
20
|
+
"@teamsupercell/typings-for-css-modules-loader": "2.5.2",
|
|
28
21
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
29
|
-
"core-js": "3.
|
|
22
|
+
"core-js": "3.31.1",
|
|
30
23
|
"cross-env": "7.0.3",
|
|
31
|
-
"css-loader": "6.
|
|
32
|
-
"css-minimizer-webpack-plugin": "5.0.
|
|
24
|
+
"css-loader": "6.8.1",
|
|
25
|
+
"css-minimizer-webpack-plugin": "5.0.1",
|
|
33
26
|
"css-unicode-loader": "1.0.3",
|
|
34
27
|
"external-remotes-plugin": "1.0.0",
|
|
35
|
-
"html-webpack-plugin": "5.5.
|
|
28
|
+
"html-webpack-plugin": "5.5.3",
|
|
36
29
|
"less": "4.1.3",
|
|
37
|
-
"less-loader": "11.1.
|
|
38
|
-
"mini-css-extract-plugin": "2.7.
|
|
30
|
+
"less-loader": "11.1.3",
|
|
31
|
+
"mini-css-extract-plugin": "2.7.6",
|
|
39
32
|
"mini-svg-data-uri": "1.4.4",
|
|
40
33
|
"path-to-regexp": "6.2.1",
|
|
41
|
-
"
|
|
42
|
-
"rehype-accessible-emojis": "0.3.2",
|
|
43
|
-
"rehype-figure": "1.0.1",
|
|
44
|
-
"style-loader": "3.3.2",
|
|
34
|
+
"style-loader": "3.3.3",
|
|
45
35
|
"style-resources-loader": "1.5.0",
|
|
46
36
|
"swc-loader": "0.2.3",
|
|
47
|
-
"swc-plugin-another-transform-imports": "0.2.
|
|
37
|
+
"swc-plugin-another-transform-imports": "0.2.4",
|
|
48
38
|
"ts-import-plugin": "3.0.0",
|
|
49
|
-
"ts-loader": "9.4.
|
|
39
|
+
"ts-loader": "9.4.4",
|
|
50
40
|
"typescript": "5.0.4",
|
|
51
|
-
"webpack": "5.
|
|
52
|
-
"webpack-bundle-analyzer": "4.
|
|
53
|
-
"webpack-cli": "5.1.
|
|
54
|
-
"webpack-dev-server": "4.15.
|
|
55
|
-
"webpack-merge": "5.
|
|
41
|
+
"webpack": "5.77.0",
|
|
42
|
+
"webpack-bundle-analyzer": "4.9.0",
|
|
43
|
+
"webpack-cli": "5.1.4",
|
|
44
|
+
"webpack-dev-server": "4.15.1",
|
|
45
|
+
"webpack-merge": "5.9.0",
|
|
46
|
+
"webpack-virtual-modules": "0.5.0",
|
|
56
47
|
"webpackbar": "5.0.2",
|
|
57
|
-
"xml2js": "0.
|
|
48
|
+
"xml2js": "0.6.1"
|
|
58
49
|
},
|
|
59
50
|
"devDependencies": {
|
|
60
|
-
"@moneko/mock": "^1.0.
|
|
61
|
-
"@
|
|
51
|
+
"@moneko/mock": "^1.0.10",
|
|
52
|
+
"@moneko/postcss": "^1.0.30",
|
|
62
53
|
"@swc/cli": "0.1.62",
|
|
54
|
+
"@types/js-yaml": "^4.0.5",
|
|
63
55
|
"@types/mini-css-extract-plugin": "^2.5.1",
|
|
64
56
|
"@types/shelljs": "^0.8.12",
|
|
65
57
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
66
|
-
"@types/webpack-env": "^1.18.
|
|
67
|
-
"eslint-config-neko": "^1.
|
|
58
|
+
"@types/webpack-env": "^1.18.1",
|
|
59
|
+
"eslint-config-neko": "^1.1.1",
|
|
68
60
|
"shelljs": "^0.8.5",
|
|
69
|
-
"
|
|
70
|
-
"stylelint-config-moneko": "^1.0.15"
|
|
61
|
+
"stylelint-config-moneko": "^1.0.17"
|
|
71
62
|
},
|
|
72
63
|
"files": [
|
|
73
64
|
"lib",
|
|
74
|
-
"build",
|
|
75
65
|
"template",
|
|
76
66
|
"typings/global.d.ts"
|
|
77
67
|
]
|