@moneko/core 3.0.0-beta.105 → 3.0.0-beta.107
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/common.js +1 -1
- package/lib/docs.js +1 -1
- package/lib/module.config.js +1 -1
- package/lib/process-env.js +1 -1
- package/lib/routes.js +1 -1
- package/lib/webpack.common.d.ts +1 -2
- package/lib/webpack.common.js +1 -1
- package/lib/webpack.dev.d.ts +1 -1
- package/lib/webpack.dev.js +2 -2
- package/lib/webpack.prod.d.ts +1 -1
- package/lib/webpack.prod.js +1 -1
- package/package.json +2 -2
- package/typings/global.d.ts +3 -2
package/lib/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import i from"chalk";import{merge as r}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as a,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as g}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 f=[`@moneko/${a}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={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&&(x=!1);let b={library:{"@":g("site"),"@pkg":g("components"),[c]:g("components")},"single-component":{[c]:g("umd")},mobile:{},site:{},"back-stage":{},"single-spa":{}},y={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:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":g("src")},b[n]),layoutSider:{},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/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:x,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f},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};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let w=y,C=null,k={},O={};try{C=o(m,"./config/index.ts"),e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;k=d(e)?e(process):e}catch(e){process.stdout.write(i.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;O=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}}"tsc"===(w=r(w,k,O)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:`
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import i from"chalk";import{merge as r}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as a,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as g}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 f=[`@moneko/${a}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={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&&(x=!1);let b={library:{"@":g("site"),"@pkg":g("components"),[c]:g("components")},"single-component":{[c]:g("umd")},mobile:{},site:{},"back-stage":{},"single-spa":{}},y={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:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":g("src")},b[n]),layoutSider:{},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/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:x,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f},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 w=y,C=null,k={},O={};try{C=o(m,"./config/index.ts"),e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;k=d(e)?e(process):e}catch(e){process.stdout.write(i.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;O=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}}"tsc"===(w=r(w,k,O)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:`
|
|
2
2
|
(function(l) {
|
|
3
3
|
if (l.search[1] === '/' ) {
|
|
4
4
|
var decoded = l.search.slice(1).split('&').map(function(s) {
|
package/lib/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./common.js";import n from"./generate-api.js";import s from"./object-listener.js";import{APPTYPE as l,FRAMEWORK as p}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";let c="@app/comment";export const docs=s({});let m={[c]:{}},d={react:"createElement",
|
|
1
|
+
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./common.js";import n from"./generate-api.js";import s from"./object-listener.js";import{APPTYPE as l,FRAMEWORK as p}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";let c="@app/comment";export const docs=s({});let m={[c]:{}},d={react:"createElement",solid:"createComponent"}[p],f=`() => ${d}(SuspenseComp, { comp: $1 })`,u=`import { ${d} } from "${p}";import { SuspenseComp } from "@moneko/${p}";`;function $(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),l=t(s).replace(/^\//,""),p=[c,l].join("/"),a=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!a)return;m[c][l]||(m[c][l]={});let $=o(p,a);if("deleted"===r)m[c][l][a]&&delete m[c][l][a];else{let t=n(e);m[$]=t,t?m[c][l][a]=`rr(() => import(/* webpackChunkName: '${$}' */'${$}?raw').then((res) => ({default: ${d}(Dynamic, {text: res.default, component: 'n-md', css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})))rr`:m[c][l][a]&&delete m[c][l][a]}let g={};for(let e in m[c])Object.prototype.hasOwnProperty.call(m[c],e)&&(g[e]=Object.values(m[c][e]));let b={...m};delete b[c],Object.assign(docs.data,{...b,"@app/docs":`${u}export default ${JSON.stringify(g).replace(/"rr\((.+?)\)rr"/g,f)}`})}["react","solid"].includes(p)||(f="$1",u=""),"solid"===p&&(u=`import { Dynamic } from "${p}/web";${u}`),"library"===l&&function(){let t=[],o=r(a("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function i(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{i(e)&&($(e,"added"),t.push(e))}),o.on("change",e=>{i(e)&&$(e,"change")}),o.on("unlink",e=>{i(e)&&($(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{$(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/lib/module.config.js
CHANGED
|
@@ -1 +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
|
|
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"./common.js";import{hasPkg as l}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?r:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=l("@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)],v=["components","example","mock","site","src","server"].map(f),b=[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,"./loader/frontmatter.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:v.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:v.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:b,include:v.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:v.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:v.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,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/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o,readFileSync as r}from"fs";import{join as
|
|
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"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"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 cacheDir=t(PROGRAMPATH,"./node_modules/.cache/.mo/");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.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 l}from"js-yaml";import{hasCustomRouter as m}from"./common.js";import c from"./object-listener.js";import{APPTYPE as p,FRAMEWORK as u,PROGRAMPATH as d}from"./process-env.js";let f=/^---\n([\s\S]+?)\n---\n/;function g(e,t){let{regex:a,alia:m,base:c=e,outputSource:p}=t,u=o(e);return u.reduce((o,u)=>{let d=s(e,u),h=n(d);if(h.isDirectory()){let e=g(d,{...t,base:c});if(e.length>0){let t={},r={path:u,key:i(c,d)};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)}o.push(Object.assign(t,r))}}else if(a.test(d)){let e=r(d,{encoding:"utf-8"}),t=function(e){let t=e.match(f);return t&&t[1]?t[1].trim():null}(e),n=t?l(t):{},a=i(c,d);o.push(Object.assign({path:u,key:a,meta:{...n}},m&&{component:`rr(() => import(/* webpackChunkName: '${a}' */'${s(m,a)}'))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(f,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let h=s(d,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let
|
|
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 l}from"js-yaml";import{hasCustomRouter as m}from"./common.js";import c from"./object-listener.js";import{APPTYPE as p,FRAMEWORK as u,PROGRAMPATH as d}from"./process-env.js";let f=/^---\n([\s\S]+?)\n---\n/;function g(e,t){let{regex:a,alia:m,base:c=e,outputSource:p}=t,u=o(e);return u.reduce((o,u)=>{let d=s(e,u),h=n(d);if(h.isDirectory()){let e=g(d,{...t,base:c});if(e.length>0){let t={},r={path:u,key:i(c,d)};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)}o.push(Object.assign(t,r))}}else if(a.test(d)){let e=r(d,{encoding:"utf-8"}),t=function(e){let t=e.match(f);return t&&t[1]?t[1].trim():null}(e),n=t?l(t):{},a=i(c,d);o.push(Object.assign({path:u,key:a,meta:{...n}},m&&{component:`rr(() => import(/* webpackChunkName: '${a}' */'${s(m,a)}'))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(f,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let h=s(d,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let x={react:"createElement",solid:"createComponent"}[u],j=`() => ${x}(SuspenseComp, { comp: $1 })`,$=`import { ${x} } from "${u}";import { SuspenseComp } from "@moneko/${u}";`;m&&($+=`import merge from "@moneko/${u}/lib/merge.js";import customRouter from "@/router";`),["react","solid"].includes(u)||(j="$1",$="");export let routes=[];function b(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()})}"library"===p&&(b(h,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=g(h,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,j).slice(1,-1);Object.assign(route.data,{data:`${$}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
|
|
2
2
|
export default ${m?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)}),b(h,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};g(h,{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)}));
|
package/lib/webpack.common.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import './cleanup.js';
|
|
2
2
|
import type { WebpackConfiguration } from 'webpack-dev-server';
|
|
3
3
|
export declare const outputConfig: WebpackConfiguration['output'];
|
|
4
|
-
declare const
|
|
5
|
-
export default config;
|
|
4
|
+
export declare const clientConfig: WebpackConfiguration;
|
package/lib/webpack.common.js
CHANGED
|
@@ -1 +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,PUBLICPATH as i}from"./common.js";import r from"./define.js";import a from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import c from"./module.config.js";import{APPTYPE as d,DEV as f,PACKAGENAME as j,PROGRAMPATH as
|
|
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"./common.js";import r from"./define.js";import a from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import c from"./module.config.js";import{APPTYPE as d,DEV as f,PACKAGENAME as j,PROGRAMPATH as g,hasEslintConfig as h,hasStylelintConfig as y}from"./process-env.js";import{seo as b}from"./seo.js";import{resolveNodeModulesPath as w,resolveProgramPath as x}from"./utils.js";import k from"./virtual-module-plugin.js";import v from"./virtual-modules.js";let{AutomaticPrefetchPlugin:C,DefinePlugin:O,SourceMapDevToolPlugin:$,WatchIgnorePlugin:B}=n,P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],A=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],S=e.readdirSync(g),T=!1,K=!1;for(let e=0,t=S.length;e<t;e++)A.includes(S[e])&&(K=!0),P.includes(S[e])&&(T=!0);T||(T=h),K||(K=y);let L=K?(await import("stylelint-webpack-plugin")).default:null,M=T?(await import("eslint-webpack-plugin")).default:null,F=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:x("library"===d?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:j,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${j}`,pathinfo:f,clean:!0,publicPath:i};let N=w("@app/entry");"single-component"===d&&(N=x(f?"example/index.ts":"src/index.ts"),outputConfig.path=x(f?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:j,type:"umd",umdNamedDefine:!0});let R={main:N};l.entry&&("string"==typeof l.entry?R=l.entry:Object.keys(l.entry)&&Object.assign(R,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let W=l.routeBaseName.split("/").filter(Boolean).length,_=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:q=W,path:D=_}=l.fixBrowserRouter||{};export const clientConfig={entry:R,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new C,...u,M&&new M({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),L&&new L({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(m),l.fixBrowserRouter&&new s({filename:D,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${q||W};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(F),"single-spa"===d&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new O(r),new B({paths:[/\.d\.ts$/]}),l.sourceMap&&new $(l.sourceMap),l.bar&&new o(l.bar),new a({done:()=>{!f&&l.seo&&b(),l.done?.(),f||setTimeout(()=>{process.exit(0)},2e3)}}),new k(v),...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/webpack.dev.d.ts
CHANGED
package/lib/webpack.dev.js
CHANGED
|
@@ -1,4 +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 m,isReact as l}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import d
|
|
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 m,isReact as l}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import{clientConfig as d}from"./webpack.common.js";let{HotModuleReplacementPlugin:v}=r,{yellow:h,green:f}=o,w=p(),u=s.devServer.port||3e3,g=await i(u,65535,s.devServer.host),k=s.devServer.port!==g,y=a("@moneko/mock"),$=y&&await import("@moneko/mock"),S=l&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1;s.cacheDirectory&&(b={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${m||"default"}-development`});let j=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=g;let x="/"===s.routeBaseName,D=s.devServer.https?"https:":"http:",A=x?"":s.routeBaseName,B=t(d,{devtool:j,mode:"development",cache:b,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:g,historyApiFallback:x||{index:A.endsWith("/")?A:`${A}/`,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($)&&$(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new v,S&&new S,new e({compilationSuccessInfo:{messages:[`You application is running here:
|
|
2
2
|
|
|
3
3
|
Local: ${o.cyan(`${D}//${s.devServer.host}:${g}${A}`)}
|
|
4
|
-
Network: ${o.cyan(`${D}//${w}:${g}${A}`)}`],notes:k?[`Port ${h(u)} is in use, trying ${f(g)} instead`]:[]},clearConsole:!0})].filter(Boolean)});
|
|
4
|
+
Network: ${o.cyan(`${D}//${w}:${g}${A}`)}`],notes:k?[`Port ${h(u)} is in use, trying ${f(g)} instead`]:[]},clearConsole:!0})].filter(Boolean)});export default[B];
|
package/lib/webpack.prod.d.ts
CHANGED
package/lib/webpack.prod.js
CHANGED
|
@@ -1 +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 l
|
|
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{clientConfig as l}from"./webpack.common.js";let{optimize:p}=m,{cssnanoMinify:a,swcMinify:u}=e,f="swc"===s.compiler?"swc":"terser",d="swc"===s.compiler?"swc":"cssnano",h=[];s.minifier&&(s.minifier.js&&h.push(new n(t(s.minifier.js?.type||f,s.minifier.js?.options))),s.minifier.css&&h.push(new e({minify:{swc:u,cssnano:a}[s.minifier.css?.type||d],minimizerOptions:s.minifier.css?.options})));let k={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:h},w=!1;s.cacheDirectory&&(w={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});let y=r(l,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:w,optimization:k,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new p.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});export default[y];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.107",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"webpack": "5.77.0",
|
|
42
42
|
"webpack-bundle-analyzer": "4.9.0",
|
|
43
43
|
"webpack-cli": "5.1.4",
|
|
44
|
-
"webpack-dev-server": "4.15.
|
|
44
|
+
"webpack-dev-server": "4.15.1",
|
|
45
45
|
"webpack-merge": "5.9.0",
|
|
46
46
|
"webpack-virtual-modules": "0.5.0",
|
|
47
47
|
"webpackbar": "5.0.2",
|
package/typings/global.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
|
6
6
|
import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
|
|
7
7
|
import type { MinifyOptions } from 'terser';
|
|
8
8
|
import type { Options } from 'ts-import-plugin';
|
|
9
|
-
import type { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
9
|
+
import type { Configuration, ExternalsPresets, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
10
10
|
import type {
|
|
11
11
|
ProxyArray,
|
|
12
12
|
ProxyConfigArray,
|
|
@@ -23,7 +23,7 @@ export declare type AppType =
|
|
|
23
23
|
| 'back-stage'
|
|
24
24
|
| 'single-spa'
|
|
25
25
|
| 'library';
|
|
26
|
-
export declare type Framework = 'react' | 'solid
|
|
26
|
+
export declare type Framework = 'react' | 'solid';
|
|
27
27
|
export type TerserOptions = MinifyOptions;
|
|
28
28
|
export type SwcOptions = JsMinifyOptions;
|
|
29
29
|
export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
@@ -294,6 +294,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
294
294
|
* @default true
|
|
295
295
|
*/
|
|
296
296
|
normalizeCss?: boolean;
|
|
297
|
+
externalsPresets?: ExternalsPresets;
|
|
297
298
|
};
|
|
298
299
|
export declare interface ModuleFederationOption {
|
|
299
300
|
/** 模块名称,唯一性,不能重名 */
|