@moneko/core 3.1.6 → 3.2.0
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/config.d.ts +1 -2
- package/lib/config.js +1 -1
- package/lib/html-plugin-option.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +1 -1
- package/lib/minify.d.ts +1 -1
- package/lib/paths.d.ts +1 -0
- package/lib/paths.js +1 -1
- package/lib/polyfills/replace-children.d.ts +1 -0
- package/lib/polyfills/replace-children.js +3 -0
- package/lib/process-env.d.ts +14 -2
- package/lib/process-env.js +7 -1
- package/package.json +1 -1
package/lib/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
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import l from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./config.js";import i from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import m from"./module.config.js";import u from"./paths.js";import{CUSTOMCONFIG as f,PACKAGENAME as d,PACKAGEVERSION as h,hasEslintConfig as j,hasStylelintConfig as y,isDev as g,isLibrary as b,isMicro as w}from"./process-env.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import C from"./virtual-module-plugin.js";import $ from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:P,SourceMapDevToolPlugin:M,WatchIgnorePlugin:S}=l,B=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],D=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],T=e.readdirSync(u.programPath),A=!1,H=!1;for(let e=0,t=T.length;e<t;e++)D.includes(T[e])&&(H=!0),B.includes(T[e])&&(A=!0);A||(A=j),H||(H=y);let K=H?(await import("stylelint-webpack-plugin")).default:null,L=A?(await import("eslint-webpack-plugin")).default:null,F=n.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v(b?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${g?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:d,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${d}`,pathinfo:g,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let J={main:k("@app/entry")};n.polyfill&&Object.assign(J,{"dom-polyfills":[`${u.corePath}/polyfills/replace-children.js`]}),n.entry&&("string"==typeof n.entry?J={main:n.entry}:Object.keys(n.entry)&&Object.assign(J,n.entry)),n.output&&("string"==typeof n.output?outputConfig.path=n.output:Object.keys(n.output)&&Object.assign(outputConfig,n.output));let R=n.basename.split("/").filter(Boolean).length,U=`${Array(R).fill("..").join("/")+(R?"/":"")}404.html`,{pathSegmentsToKeep:W=R,path:_=U}=n.fixBrowserRouter||{},z=!1;n.cacheDirectory&&(z={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:n.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${g?"development":"production"}`,version:h});export const clientConfig={entry:J,stats:"errors-only",cache:z,infrastructureLogging:{level:"none"},target:"web",externalsPresets:n.externalsPresets,plugins:[new O,...c,L&&new L({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),K&&new K({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),n.htmlPluginOption&&new s(p),n.fixBrowserRouter&&new s({filename:_,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${W||R};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),w&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new P({"process.env":JSON.stringify(n.env)}),new S({paths:[/\.d\.ts$/]}),n.sourceMap&&new M(n.sourceMap),n.bar&&new o(n.bar),new i({done:()=>{!g&&n.seo&&x(),n.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...n.plugins].filter(Boolean),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:g&&{imports:!1,entries:!1},buildHttp:n.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx",".wasm"],alias:n.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:n.externals,output:outputConfig};
|
package/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const ENTRYPATH: Record<AppType, string>;
|
|
1
|
+
import type { ConfigType } from '.';
|
|
3
2
|
export declare const log: (msg: string) => void;
|
|
4
3
|
export declare const CONFIG: ConfigType<"swc">;
|
|
5
4
|
export declare const PUBLICPATH: string;
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as l,FRAMEWORK as n,PACKAGENAME as c,
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as l,FRAMEWORK as n,PACKAGENAME as c,coreName as m,jsxImportSource as p}from"./process-env.js";import{isFunction as u,readConf as d,resolveProgramPath as h}from"./utils.js";let f=["@moneko/core",`@moneko/${n}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],g={library:{"@":h("site"),"@pkg":h("components"),[c]:h("components")},mobile:{},site:{},backstage:{},micro:{}},x={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:"mobile"===a?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":h("src")},g[a]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,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:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f,wasm:[]},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:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let C=x,w=null,b={},y={};try{w=i.defaultConfigPath,e(w,t.R_OK)}catch(e){w=null}if(w)try{let e=(await d(w,"index")).default;b=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(l){let o=null;try{o=`${i.programPath}/config/${l}.ts`,e(o,t.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await d(o,l)).default;y=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(C=r(C,b,y)).compiler&&C.minifier&&(C.minifier.js||Object.assign(C.minifier,{js:{type:"terser"}}),C.minifier.css||Object.assign(C.minifier,{css:{type:"cssnano"}})),!1===C.devtool&&(C.sourceMap=!1),!1===C.sourceMap&&(C.devtool=!1),C.fixBrowserRouter&&C.htmlPluginOption&&(C.htmlPluginOption.tags||(C.htmlPluginOption.tags=[]),C.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=C;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(`${CONFIG.alias["@"]}/router/index.ts`,t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,
|
|
1
|
+
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,coreName as r}from"./process-env.js";let{template:p,favicon:m,...n}=Object.assign({template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`},i.htmlPluginOption||{}),l=e({title:i.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:t.description||""},tags:[],template:`${o.programPath}/${p}`,favicon:`${o.programPath}/${m}`},n);export default l;
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as paths } from './paths.js';
|
|
2
|
+
export { CUSTOMCONFIG, FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, } from './process-env.js';
|
|
3
|
+
export { realResolve, resolveNodeModulesPath, resolveProgramPath } from './utils.js';
|
|
4
|
+
export type * from '../typings/global.d.ts';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{default as paths}from"./paths.js";export{CUSTOMCONFIG,FRAMEWORKNAME,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils.js";
|
package/lib/minify.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
-
import type { MinifierType, SwcOptions, TerserOptions } from '
|
|
2
|
+
import type { MinifierType, SwcOptions, TerserOptions } from '.';
|
|
3
3
|
import type { JsMinifyOptions } from '@swc/core';
|
|
4
4
|
type MinifyObject = {
|
|
5
5
|
terser: {
|
package/lib/paths.d.ts
CHANGED
package/lib/paths.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let
|
|
1
|
+
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let t=process.cwd(),c=`${t}/node_modules/.cache/.mo`;e(c)||o(c,{recursive:!0});export default{corePath:a.fileURLToPath(new URL(".",import.meta.url)),programPath:t,webpackCachePath:`${t}/node_modules/.temp_cache`,cachePath:c,httpCachePath:`${t}/node_modules/.cache/http`,swcCachePath:`${t}/node_modules/.swc`,defaultConfigPath:`${t}/config/index.ts`,coveragePath:`${t}/coverage/clover.xml`,pagesPath:`${t}/src/pages`,componentsPath:`${t}/components`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function replaceChildrenPolyfill(...nodes: (string | Node)[]): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function e(...t){/**
|
|
2
|
+
* @ts-ignore */// eslint-disable-next-line consistent-this, no-invalid-this, @typescript-eslint/no-this-alias
|
|
3
|
+
let o=this,r=t.length,l=Array(r);for(let e=0;e<r;e++)l[e]=t[e];for(;o.firstChild;)o.removeChild(o.firstChild);l.forEach(function(e){"string"==typeof e?o.appendChild(document.createTextNode(e)):o.appendChild(e)})}Element.prototype.replaceChildren||(Element.prototype.replaceChildren=e),ShadowRoot.prototype.replaceChildren||(ShadowRoot.prototype.replaceChildren=e);
|
package/lib/process-env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, Framework } from '
|
|
1
|
+
import type { AppType, Framework } from '.';
|
|
2
2
|
export declare const APPTYPE: AppType;
|
|
3
3
|
export declare const FRAMEWORK: Framework;
|
|
4
4
|
export declare const isLibrary: boolean;
|
|
@@ -7,11 +7,23 @@ export declare const isReact: boolean;
|
|
|
7
7
|
export declare const isSolid: boolean;
|
|
8
8
|
export declare const jsxImportSource: string;
|
|
9
9
|
export declare const createElement: string;
|
|
10
|
+
/** 框架名称 */
|
|
10
11
|
export declare const FRAMEWORKNAME: string;
|
|
12
|
+
/** 应用名称 */
|
|
11
13
|
export declare const PACKAGENAME: string;
|
|
14
|
+
/** 版本号 */
|
|
12
15
|
export declare const PACKAGEVERSION: string;
|
|
13
|
-
|
|
16
|
+
/** core 包名 */
|
|
17
|
+
export declare const coreName: string;
|
|
18
|
+
/** 是否为本地开发环境 */
|
|
14
19
|
export declare const isDev: boolean;
|
|
20
|
+
/** 附加启动配置名称
|
|
21
|
+
* @example
|
|
22
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
23
|
+
* ```sh
|
|
24
|
+
* npm run start --config=test
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
15
27
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
16
28
|
export declare const hasEslintConfig: boolean;
|
|
17
29
|
export declare const hasStylelintConfig: boolean;
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK]
|
|
1
|
+
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];/** 框架名称 */export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];/** 应用名称 */export const PACKAGENAME=process.env.npm_package_name;/** 版本号 */export const PACKAGEVERSION=process.env.npm_package_version;let s=e(`${o.corePath}/../package.json`,{encoding:"utf-8"});/** core 包名 */export const coreName=JSON.parse(s).name;/** 是否为本地开发环境 */export const isDev="development"===process.env.NODE_ENV;/** 附加启动配置名称
|
|
2
|
+
* @example
|
|
3
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
4
|
+
* ```sh
|
|
5
|
+
* npm run start --config=test
|
|
6
|
+
* ```
|
|
7
|
+
*/export const CUSTOMCONFIG=process.env.npm_config_config||t.config;let n=Object.keys(process.env);export const hasEslintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|