@moneko/core 3.11.1-beta.0 → 3.11.1-beta.10
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/build.mjs +1 -1
- package/lib/cjs/index.cjs +1 -0
- package/lib/cjs/index.d.cts +6 -0
- package/lib/cjs/load-module-meta.cjs +1 -0
- package/lib/cjs/load-module-meta.d.cts +2 -0
- package/lib/dev/mock.d.mts +1 -1
- package/lib/index.d.mts +2 -0
- package/lib/index.mjs +1 -1
- package/lib/options/js-minify.d.mts +1 -1
- package/lib/options/swcrc.mjs +1 -1
- package/lib/paths.mjs +1 -1
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/virtual-module.d.mts +3 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/polyfills/polyfills.d.mts +0 -1
- package/lib/polyfills/polyfills.mjs +1 -1
- package/lib/utils/has-pkg.mjs +1 -1
- package/lib/utils/index.d.mts +1 -1
- package/lib/vm/info.mjs +1 -1
- package/lib/vm/modules.mjs +1 -1
- package/package.json +14 -15
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{removeDirAll as o}from"@moneko/mdx";import
|
|
1
|
+
import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as m}from"webpack-merge";import e from"./build/common.mjs";import i from"./build/server.mjs";import{CONFIG as t}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import g from"chalk";let{ProgressPlugin:h}=r,u=[m(e,{module:s(!1),plugins:[t.done&&new l({done:t.done}),t.bar&&new h({handler(o,r,...m){let e=t.bar;c(o,e.name||"Build",m.length?`[${r}] ${m.join(" ")}`:"",e.color)}})].filter(Boolean)})];a&&u.push(m(e,i));let d=r(u);async function j(){await new Promise(o=>{d.run((r,m)=>{if(r)throw r;if(m&&(m.hasErrors()||m.hasWarnings()))for(let o=0,r=m.stats.length;o<r;o++){let r=m.stats[o];for(let o=0,m=r.compilation.warnings.length;o<m;o++)p(g.yellowBright(r.compilation.warnings[o].message));for(let o=0,m=r.compilation.errors.length;o<m;o++)p(g.redBright(r.compilation.errors[o].message))}o(r)})}),t.seo&&f()}await j(),process.on("exit",function(){o(n.cachePath)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return o}});const t=(e=require("./load-module-meta.cjs"))&&e.__esModule?e:{default:e},r=(0,t.default)("core-js/package.json").version,o={coreJsVersion:r.substring(0,r.indexOf(".",2)),loadModuleMeta:t.default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});const e=function(e){return require(e)};
|
package/lib/dev/mock.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ type Any = any;
|
|
|
20
20
|
* @param {T} data data
|
|
21
21
|
* @returns {Promise} mockData
|
|
22
22
|
*/
|
|
23
|
-
export declare const yApiSchemaMock: <T extends unknown>(option: YApiOptionBySchema, data?: T
|
|
23
|
+
export declare const yApiSchemaMock: <T extends unknown>(option: YApiOptionBySchema, data?: T) => Promise<T>;
|
|
24
24
|
export type YApiOption = {
|
|
25
25
|
/** YApi host */
|
|
26
26
|
host: string;
|
package/lib/index.d.mts
CHANGED
|
@@ -13,4 +13,6 @@ export { default as jsxDomExpressions, type JsxDomExpressions, } from './options
|
|
|
13
13
|
export { default as splitChunk, type OptimizationSplitChunksOptions, } from './options/split-chunk.mjs';
|
|
14
14
|
export { default as Rule } from './rule.mjs';
|
|
15
15
|
export type { VirtualModulePluginOption } from './plugin/virtual-module.mjs';
|
|
16
|
+
export declare const coreJsVersion: any;
|
|
17
|
+
export declare const loadModuleMeta: any;
|
|
16
18
|
export type * from '../typings/global.js';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils/index.mjs";export{default as log}from"./utils/log.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{getIPv4,getPort}from"./dev/net.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{default as Rule}from"./rule.mjs";
|
|
1
|
+
export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils/index.mjs";export{default as log}from"./utils/log.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{getIPv4,getPort}from"./dev/net.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{default as Rule}from"./rule.mjs";import o from"./cjs/index.cjs";let e=o.default;export const coreJsVersion=e.coreJsVersion;export const loadModuleMeta=e.loadModuleMeta;
|
|
@@ -20,6 +20,6 @@ export declare const getMinifyOption: (type?: MinifierType, options?: SwcMinifyO
|
|
|
20
20
|
minify: typeof TerserPlugin.swcMinify;
|
|
21
21
|
terserOptions?: SwcMinifyOptions | undefined;
|
|
22
22
|
}) & {
|
|
23
|
-
terserOptions:
|
|
23
|
+
terserOptions: any;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
package/lib/options/swcrc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as r}from"../config.mjs";import o from"../paths.mjs";import
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as r}from"../config.mjs";import o from"../paths.mjs";import{coreJsVersion as t}from"../index.mjs";import s from"../polyfills/polyfills.mjs";import{isDev as m,isReact as a,isSolid as p,jsxImportSource as i}from"../process-env.mjs";let l=function(e){for(let r=0,o=Object.keys(e),t=o.length;r<t;r++)e[o[r]].transform=`${o[r]}/${e[o[r]].transform}`,e[o[r]].style&&(e[o[r]].style=`${o[r]}/${e[o[r]].style}`);return e}(r.importOnDemand||{}),n={include:s(),mode:"entry",coreJs:t};export default(t=>e({module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:r.polyfill?void 0:"es2017",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:a&&m,development:m,importSource:i},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:o.swcCachePath,plugins:[["@moneko/transform-imports",l],p&&["@moneko/jsx-dom-expressions",{...r.jsxDomExpressions,generate:t?"ssr":"dom",hydratable:t}]].filter(Boolean)}},env:r.polyfill?n:void 0,sourceMaps:!0,parseMap:!0},"function"==typeof r.swcrc?r.swcrc(m):r.swcrc||{}));
|
package/lib/paths.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"url";let
|
|
1
|
+
import e from"url";import{resolve as o}from"path";let t=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const yarnArgv={};for(let e=0,o=t.length;e<o;e++){let o=t[e].split("=");Object.assign(yarnArgv,{[o[0]]:o[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let a=process.cwd(),c=o(a,"./node_modules"),r={nodeModules:c,corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:a,webpackCachePath:`${c}/.temp_cache`,cachePath:`${c}/.cache/.mo`,httpCachePath:`${c}/.cache/http`,swcCachePath:`${c}/.swc`,configPath:`${a}/config/index.ts`,customConfigPath:`${a}/config/${CUSTOMCONFIG}.ts`,coveragePath:`${a}/coverage/clover.xml`,pagesPath:`${a}/src/pages`,componentsPath:`${a}/components`,mockPath:`${a}/mock`,lineCachePath:`${c}/.cache`};export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as s}from"buffer";import{
|
|
1
|
+
import{Buffer as s}from"buffer";import{transform as t}from"lightningcss";import i from"webpack";import{loadModuleMeta as n,paths as o}from"../index.mjs";let{sources:{RawSource:e,SourceMapSource:r},ModuleFilenameHelpers:{matchObject:a}}=i,m="lightning-css-minify",p=/\.css(?:\?.*)?$/i,{name:f,version:c}=n(`${o.programPath}/package.json`);export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...n}=s;if(i&&"function"!=typeof i.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof i.transform}`);this.transform=i?.transform??t,this.options=n}apply(s){let t=JSON.stringify({name:f,version:c,options:this.options});s.hooks.compilation.tap(m,s=>{s.hooks.chunkHash.tap(m,(s,i)=>i.update(t)),s.hooks.processAssets.tapPromise({name:m,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(m,s=>{s.hooks.print.for("asset.info.minimized").tap(m,(s,{green:t,formatFlag:i})=>s&&t&&i?t(i("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:i}}=t.compiler,{include:n,exclude:o,test:m,sourceMap:f=!!(i&&i.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(m||p).test(s.name)&&a({include:n,exclude:o},s.name));await Promise.all(l.map(async i=>{let n;let{source:o,map:a}=i.source.sourceAndMap(),m=o.toString(),p="string"==typeof o?s.from(o):o,l=this.transform({filename:i.name,code:p,minify:!0,sourceMap:f,...c}),g=l.code.toString();n=f?new r(g,i.name,JSON.parse(l.map.toString()),m,a,!0):new e(g),t.updateAsset(i.name,n,{...i.info,minimized:!0})}))}}
|
|
@@ -3,8 +3,10 @@ export interface VirtualModulePluginOption {
|
|
|
3
3
|
[key: string]: string | object;
|
|
4
4
|
}
|
|
5
5
|
export declare class VirtualModuleWebpackPlugin {
|
|
6
|
-
private readonly options?;
|
|
7
6
|
private hasTapped;
|
|
7
|
+
private virtualModules;
|
|
8
|
+
private options;
|
|
8
9
|
constructor(options?: VirtualModulePluginOption);
|
|
10
|
+
private modify;
|
|
9
11
|
apply(compiler: Compiler): void;
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"webpack-virtual-modules";import{isLibrary as o}from"../process-env.mjs";import{node_modules as e}from"../utils/index.mjs";import{comment as i,docs as s}from"../vm/docs.mjs";import{examples as r}from"../vm/example.mjs";import{locales as l}from"../vm/locales.mjs";import p from"../vm/modules.mjs";import{route as m}from"../vm/routes.mjs";import a from"../paths.mjs";export class VirtualModuleWebpackPlugin{constructor(o={}){this.virtualModules=new t,this.options={};let e={};for(let t in o)if(Object.prototype.hasOwnProperty.call(o,t)){let i=o[t];Object.assign(e,{[t]:"string"==typeof i?i:`export default ${JSON.stringify(i)}`})}this.options=e,this.hasTapped=!1}modify(t,o,i){let s=i||"",r=o.startsWith(a.nodeModules)?o:e(o),l=t?.inputFileSystem;for(;l&&l._inputFileSystem;)l=l._inputFileSystem;let p=l._virtualFiles[r];p&&p.contents===s||this.virtualModules.writeModule(r,s)}apply(t){this.virtualModules.apply(t);let e=(o,e)=>{this.modify(t,o,e)};m.on("change",e),l.on("change",e),o&&(r.on("change",e),s.on("change",e),i.on("change",e)),t.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let t in this.hasTapped=!0,p)Object.prototype.hasOwnProperty.call(p,t)&&e(t,p[t]);for(let t in this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&e(t,this.options[t]);for(let t of r)e(t[0],t[1]);for(let t of s)e(t[0],t[1]);for(let t of i)e(t[0],t[1])}})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"core-js-compat";import{getBrowsersTargets as t}from"./targets.mjs";import{coreJsVersion as o}from"../index.mjs";export default function(){return r({targets:t(),version:o}).list}
|
package/lib/utils/has-pkg.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{loadModuleMeta as r}from"../index.mjs";export default function(t){try{return r(`${t}/package.json`),!0}catch(r){return!1}}
|
package/lib/utils/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ export declare function resolveProgramPath<T extends string>(src: T): ProgramPat
|
|
|
10
10
|
* @param {string} src 路径
|
|
11
11
|
* @returns {string} 位于项目根目录node_modules下的位置
|
|
12
12
|
*/
|
|
13
|
-
export declare const resolveNodeModulesPath: <T extends string>(src: T) =>
|
|
13
|
+
export declare const resolveNodeModulesPath: <T extends string>(src: T) => NodeModulesPath<T>;
|
|
14
14
|
export declare function node_modules<T extends string>(name: T): `node_modules/${T}`;
|
|
15
15
|
/** 获取模块真实入口位置
|
|
16
16
|
* @param {string} url 路径
|
package/lib/vm/info.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CONFIG as r}from"../config.mjs";import{APPTYPE as e,PACKAGENAME as o,PACKAGEVERSION as t,SSR as s}from"../process-env.mjs";import{toUpperCaseString as i}from"../utils/index.mjs";import{loadModuleMeta as p,paths as m}from"../index.mjs";let{description:n,author:a,repository:c,keywords:d}=p(`${m.programPath}/package.json`),f="string"==typeof a,l={name:o,projectName:i(o).replace(/-/g," "),ssr:s,version:t,base:r.basename,type:e,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:n,author:f?{name:a}:a,repository:f?{url:c}:c};export const description=n;export const keywords=Array.isArray(d)?d.toString():"";export default l;
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"path";import{getAppEntry as
|
|
1
|
+
import{join as o}from"path";import{getAppEntry as m,getAppFallback as r,getAppMdxScope as e,getAppMergeRouter as p,getAppNormalizeCss as t,getAppPrefixRouter as a,getAppRem as s,getAppSuspense as i}from"@moneko/mdx";import f from"./coverage.mjs";import{docs as n,docsModuleName as l}from"./docs.mjs";import c from"./info.mjs";import{locales as d,localesModuleName as x}from"./locales.mjs";import{route as g,routesModuleName as j}from"./routes.mjs";import{CONFIG as u}from"../config.mjs";import h from"../paths.mjs";import{APPTYPE as v,FRAMEWORK as k}from"../process-env.mjs";import{node_modules as z,resolveProgramPath as D}from"../utils/index.mjs";let b={[z("@app/info")]:`export default ${JSON.stringify(c)}`,[z("@app/entry")]:m(o(u.alias["@"],"./index.ts"),!!u.rem,!!u.normalizeCss,v,k),[z("@app/rem")]:s(u.rem?.designSize||1680),[z("@app/fallback")]:r(u.fallbackCompPath),[z("@app/coverage")]:f(h.coveragePath),[z("@app/merge-router")]:p(),[z("@app/prefix-router")]:a(),[z("@app/normalize/index.css")]:t(),[z("@app/suspense/index.tsx")]:i(v,k),[z("@app/mdx-scope")]:e(D("site/mdx-scope.ts")),[z(j)]:g.getData(j),[z(x)]:d.getData(x),[z(l)]:n.getData(l)};export default b;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.11.1-beta.
|
|
3
|
+
"version": "3.11.1-beta.10",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "rm -rf ./lib && tsc && swc src -d lib --strip-leading-paths -D"
|
|
9
|
-
"postbuild": "npm run cjs && npm run mjs",
|
|
10
|
-
"cjs": "find ./lib/loader/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\;",
|
|
11
|
-
"mjs": "find ./lib/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.mjs\"' _ {} \\;"
|
|
8
|
+
"build": "rm -rf ./lib && tsc && swc src -d lib --strip-leading-paths -D && node convert"
|
|
12
9
|
},
|
|
13
10
|
"keywords": [],
|
|
14
11
|
"author": "moneko",
|
|
@@ -16,14 +13,15 @@
|
|
|
16
13
|
"dependencies": {
|
|
17
14
|
"@moneko/mdx": "0.1.26",
|
|
18
15
|
"@moneko/transform-imports": "0.4.0",
|
|
19
|
-
"@swc/core": "1.4.
|
|
16
|
+
"@swc/core": "1.4.14",
|
|
20
17
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
18
|
+
"browserslist": "4.23.0",
|
|
21
19
|
"chalk": "5.3.0",
|
|
22
20
|
"chokidar": "3.6.0",
|
|
23
21
|
"core-js": "3.36.1",
|
|
24
22
|
"core-js-compat": "3.36.1",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
23
|
+
"css-loader": "7.1.1",
|
|
24
|
+
"enhanced-resolve": "5.16.0",
|
|
27
25
|
"express": "4.19.2",
|
|
28
26
|
"html-webpack-plugin": "5.6.0",
|
|
29
27
|
"http-proxy-middleware": "3.0.0",
|
|
@@ -33,12 +31,13 @@
|
|
|
33
31
|
"mini-css-extract-plugin": "2.8.1",
|
|
34
32
|
"mock-json-schema": "1.1.1",
|
|
35
33
|
"multer": "1.4.5-lts.1",
|
|
36
|
-
"style-loader": "
|
|
34
|
+
"style-loader": "4.0.0",
|
|
37
35
|
"swc-loader": "0.2.6",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"webpack
|
|
41
|
-
"webpack-
|
|
36
|
+
"terser-webpack-plugin": "5.3.10",
|
|
37
|
+
"typescript": "5.4.5",
|
|
38
|
+
"webpack": "5.91.0",
|
|
39
|
+
"webpack-bundle-analyzer": "4.10.2",
|
|
40
|
+
"webpack-dev-middleware": "7.2.1",
|
|
42
41
|
"webpack-hot-middleware": "2.26.1",
|
|
43
42
|
"webpack-merge": "5.10.0",
|
|
44
43
|
"webpack-node-externals": "3.0.0",
|
|
@@ -49,8 +48,8 @@
|
|
|
49
48
|
"@swc/cli": "0.3.12",
|
|
50
49
|
"@types/express": "4.17.21",
|
|
51
50
|
"@types/multer": "1.4.11",
|
|
52
|
-
"sass": "1.
|
|
53
|
-
"sass-loader": "14.
|
|
51
|
+
"sass": "1.75.0",
|
|
52
|
+
"sass-loader": "14.2.0"
|
|
54
53
|
},
|
|
55
54
|
"files": [
|
|
56
55
|
"lib",
|