@moneko/core 3.8.3-beta.3 → 3.8.3-beta.4
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/dev.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/loader/mdx.cjs +1 -1
- package/lib/loader/mdx.d.cts +2 -2
- package/lib/vm/routes.js +1 -1
- package/package.json +2 -2
- package/typings/global.d.ts +3 -2
- package/lib/loader/frontmatter.cjs +0 -1
- package/lib/loader/frontmatter.d.cts +0 -1
package/lib/dev.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readdirSync as e}from"fs";import t from"chalk";import o from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import{clientConfig as l}from"./common.js";import{CONFIG as i}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as a,getPort as c}from"./net.js";import p from"./paths.js";import{hasEslintConfig as m,hasStylelintConfig as d,isLibrary as
|
|
2
|
-
`);function
|
|
3
|
-
${S(" Network ")} ${C(
|
|
1
|
+
import{readdirSync as e}from"fs";import t from"chalk";import o from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import{clientConfig as l}from"./common.js";import{CONFIG as i}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as a,getPort as c}from"./net.js";import p from"./paths.js";import{hasEslintConfig as m,hasStylelintConfig as d,isLibrary as u,isReact as f}from"./process-env.js";import{cleanDir as h,isFunction as v,log as w,resolveProgramPath as g}from"./utils.js";let{HotModuleReplacementPlugin:j}=o,{yellow:k,green:y,grey:$,gray:x,bgBlue:b,bgGreenBright:S,blueBright:T,greenBright:C}=t,A=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],B=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],D=e(p.programPath),E=!1,H=!1;for(let e=0,t=D.length;e<t;e++)B.includes(D[e])&&(H=!0),A.includes(D[e])&&(E=!0);E||(E=m),H||(H=d);let M=H?(await import("stylelint-webpack-plugin")).default:null,O=E?(await import("eslint-webpack-plugin")).default:null,P=i.devServer.port||3e3,_=await c(P,65535,i.devServer.host),I=n("@moneko/mock")&&(await import("@moneko/mock")).default,J=f&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,N=!1===i.devtool||i.devtool?i.devtool:"eval-cheap-module-source-map";i.devServer.port=_;let W="/"===i.basename,F=i.devServer.https?"https:":"http:",G=W?"":i.basename,L=i.devServer.port!==_&&x(`Port ${k(P)} is in use, trying ${y(_)} instead.
|
|
2
|
+
`);function R(e){return`${F}//${"local"===e?i.devServer.host:a()}:${_}${G}`}let Y=x("You application is running here:"),q=`${b(" Local ")} ${T(R("local"))}
|
|
3
|
+
${S(" Network ")} ${C(R("net"))}`,z=["js","md","mdx","jsx","ts","tsx","json","html","vue"],K=z.join(","),Q=["css","scss","sass","less","ts","tsx","js","jsx"],U=Q.join(","),V=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],X=[O&&new O({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${K}}`,u&&`${i.alias["@pkg"]}/**/*.{${K}}`].filter(Boolean),extensions:z,exclude:V,cache:!1,lintDirtyModulesOnly:!0}),M&&new M({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${U}}`,u&&`${i.alias["@pkg"]}/**/*.{${U}}`].filter(Boolean),extensions:Q,exclude:V,cache:!1,lintDirtyModulesOnly:!0}),new j,J&&new J].filter(Boolean),Z={headers:{"Access-Control-Allow-Origin":"*"},compress:i.devServer.compress,host:"0.0.0.0",port:_,historyApiFallback:W||{index:G.endsWith("/")?G:`${G}/`,disableDotRule:!0},https:i.devServer.https,proxy:i.proxy,allowedHosts:i.devServer.allowedHosts,client:{reconnect:!0,progress:!1,logging:"info",overlay:!1,webSocketTransport:"ws"},webSocketServer:"ws",static:{watch:{ignored:e=>e.endsWith(".d.ts")||e.includes("/node_modules/")}},setupMiddlewares:(e,t)=>{if(!t)throw Error("devServer is not defined");return t.app&&v(I)&&I(t.app,g("mock/")),e},open:!1,hot:!0},ee=o(r(l,{devtool:N,mode:"development",plugins:X}));ee.watch({aggregateTimeout:600,ignored:/node_modules/,stdin:!0},(e,t)=>{!e&&t&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),w([Y,"",q,"",$(`Compiled successfully in ${y(`${t.endTime-t.startTime}ms`)}`)]),t.compilation.warnings.forEach(e=>w(e.message)),t.compilation.errors.forEach(e=>w(e.message)),L&&w(L))});let et=new s(Z,ee);et.startCallback(e=>{e||w([Y,"",q])}),et.stopCallback(e=>{e||h(p.cachePath)}),process.on("exit",function(){ee.close(()=>{}),et.invalidate(),et.stop()}),process.on("SIGINT",()=>{process.exit()});
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary,
|
|
|
3
3
|
export { realResolve, resolveNodeModulesPath, resolveProgramPath, log } from './utils.js';
|
|
4
4
|
export { getIPv4, getPort } from './net.js';
|
|
5
5
|
export { default as osTmpDir } from './os-tmp-dir.js';
|
|
6
|
-
export type {
|
|
6
|
+
export type { MdxOptions } from '@moneko/mdx';
|
|
7
7
|
export type { OverrideResolverOption } from './plugin/override-resolve.js';
|
|
8
8
|
export type * from '../typings/global.d.ts';
|
package/lib/loader/mdx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=require("@moneko/mdx");function t(t){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=require("@moneko/mdx");function t(t){let n=this.async();(0,e.mdx)({value:t,filepath:this.resourcePath,...this.getOptions()}).then(e=>{n(null,e.code)}).catch(n)}
|
package/lib/loader/mdx.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MdxOptions } from '@moneko/mdx';
|
|
2
2
|
import type { LoaderContext } from 'webpack';
|
|
3
|
-
export default function (this: LoaderContext<Omit<
|
|
3
|
+
export default function (this: LoaderContext<Omit<MdxOptions, 'value'>>, value: string): void;
|
package/lib/vm/routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e,t,r;import{accessSync as o,constants as s,readFileSync as a,readdirSync as n,statSync as p}from"fs";import{join as i,relative as l}from"path";import{
|
|
1
|
+
let e,t,r;import{accessSync as o,constants as s,readFileSync as a,readdirSync as n,statSync as p}from"fs";import{join as i,relative as l}from"path";import{frontmatterSync as m}from"@moneko/mdx";import{watch as c}from"chokidar";import{CONFIG as u}from"../config.js";import f from"../paths.js";import{FRAMEWORK as d,FRAMEWORKNAME as x,createElement as h,isDev as g,isLibrary as $,isReact as j,isSolid as y}from"../process-env.js";import D,{vmWriteing as N}from"../reactive-object.js";try{o(`${u.alias["@"]}/router/index.ts`,s.R_OK),e=!0}catch(t){e=!1}let O=y?"component":"element";function k(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function T(e,t){let{regex:r,alia:o,base:s=e,outputSource:c}=t;return n(e).reduce((n,u)=>{let f=i(e,u);if(p(f).isDirectory()){let e=T(f,{...t,base:s});if(e.length>0){let t={},r={path:k(u),key:k(l(s,f))};if(c)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,!y&&s,{children:[y&&{...s,path:r.path===s.path?"/":s.path},...e].filter(Boolean)}):Object.assign(t,s)}n.push(Object.assign(t,r))}}else if(r.test(f)){let{frontmatter:e,code:t}=m(a(f,{encoding:"utf-8"})),r=l(s,f),p=k(r);n.push(Object.assign({path:p.split("/").slice(-2,-1)?.join("")||"/",key:p.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:JSON.parse(e)},o&&{[O]:`rr(() => import(/* webpackChunkName: '${r}' */'${i(o,r)}'))rr`},c&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t;r[e.split(" ").pop()||"jsx"]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(t.replace(/^\n+|\n+$/g,""))}))}return n},[])}export const routesModuleName="@app/routes";export const route=new D({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new D;let E=`${y?"() => ":""}${h}(SuspenseComp, { comp: $1 })`,M=`import { ${h} } from "${x}";import SuspenseComp from "@app/suspense";${j?'import prefix from "@app/prefix-router";':""}`;e&&(M+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(d)||(E="$1",M="");export let routes=[];function S(t){return`${M}const routes = [{ path: "/", children: [${y?'{ path: "/" },':""} ${t}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${j?"prefix(_routes)":"_routes"};`}function b(e,t,r,o){N.setData(o,!0);let s=c(e,{ignored:(e,r)=>{if(r)return!r.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});function a(){s.unwatch(e),s.close(),N.setData(o,!1)}s.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),s.once("ready",()=>{g||a()}),process.on("SIGINT",a)}$?(b(f.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=T(f.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,S(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,E).slice(1,-1)))},100)},"vm-router"),b(f.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),T(f.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(e=>{let t=["@app/example",e.key].filter(Boolean).join("/"),r=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)||[];examples.setData(t,`export default ${JSON.stringify(r)};`)})},100)},"vm-examples")):b(f.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=T(f.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,S(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,E).slice(1,-1)))},100)},"vm-router");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.8.3-beta.
|
|
3
|
+
"version": "3.8.3-beta.4",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "moneko",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@moneko/mdx": "0.1.
|
|
15
|
+
"@moneko/mdx": "0.1.9",
|
|
16
16
|
"@swc/core": "1.3.99",
|
|
17
17
|
"@swc/css": "0.0.28",
|
|
18
18
|
"@swc/helpers": "0.5.3",
|
package/typings/global.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
|
3
3
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
4
4
|
import WebpackBar from 'webpackbar';
|
|
5
5
|
import DoneWebpackPlugin from '../lib/plugin/done';
|
|
6
|
-
import type {
|
|
6
|
+
import type { OverrideResolverOption } from '../lib/index';
|
|
7
|
+
import type { MdxOptions } from '@moneko/mdx';
|
|
7
8
|
import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
8
9
|
import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
|
|
9
10
|
import type { MinifyOptions } from 'terser';
|
|
@@ -299,7 +300,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
299
300
|
| false;
|
|
300
301
|
/** 📦 打包完成 */
|
|
301
302
|
done?: ConstructorParameters<typeof DoneWebpackPlugin>[0]['done'];
|
|
302
|
-
mdx?:
|
|
303
|
+
mdx?: Omit<MdxOptions, 'value' | 'filepath'>;
|
|
303
304
|
jsxDomExpressions?: {
|
|
304
305
|
moduleName?: string;
|
|
305
306
|
builtIns?: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=/^---\n([\s\S]+?)\n---\n/,n=/^\n+|\n+$/g;function t(t){return t.replace(e,"").replace(n,"")}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (content: string): string;
|