@moneko/core 3.9.3-beta.2 → 3.9.5
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/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileExists as e}from"@moneko/mdx";import{merge as t}from"webpack-merge";import
|
|
1
|
+
import{fileExists as e}from"@moneko/mdx";import{merge as t}from"webpack-merge";import o,{CUSTOMCONFIG as s}from"./paths.js";import{FRAMEWORK as i,PACKAGENAME as n,coreName as r,isDev as a,isLibrary as l,isMobile as m,isSolid as p,jsxImportSource as c,mainDirectory as u}from"./process-env.js";import{isFunction as d,log as h,readConf as f,resolveProgramPath as g}from"./utils.js";let C=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],x={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:m?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(u)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:o.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{CHANGELOG:{test:/CHANGELOG\.md/,priority:-10,name:"CHANGELOG",reuseExistingChunk:!0},prismjs:{test:/(prism\.js|prism\/css\.ts)/,priority:-10,name:"vendors-prismjs",reuseExistingChunk:!0},site:{test:/site/,priority:-10,reuseExistingChunk:!0},marked:{test:/marked/,priority:-10,reuseExistingChunk:!0},"@moneko":{test:/@moneko/,priority:-10,reuseExistingChunk:!0}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:a,jsxImportSource:c,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:{},bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${o.httpCachePath}/http.lock`,cacheLocation:`${o.httpCachePath}/data`,upgrade:!0}};p&&Object.assign(x,{jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}}),l&&(x.alias=Object.assign(x.alias,{"@pkg":o.componentsPath,[n]:o.componentsPath}));let k=x,P={},w={};if(e(o.configPath)){let e=(await f(o.configPath,"index")).default;P=d(e)?e(process):e}if(s&&e(o.customConfigPath)){let e=(await f(o.customConfigPath,s)).default;w=d(e)?e(process):e}"tsc"===(k=t(k,P,w)).compiler&&k.minifier&&void 0===k.minifier.type&&(k.minifier.type="terser"),(!1===k.devtool||!1===k.sourceMap)&&(k.sourceMap=!1,k.devtool=!1),k.fixBrowserRouter&&k.htmlPluginOption&&(k.htmlPluginOption.tags||(k.htmlPluginOption.tags=[]),k.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=k;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:s,log:h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return n}});const e=require("buffer"),t=require("lightningcss"),r={Declaration:{custom:e=>{if("content"===e.name&&1===e.value.length){let t=e.value[0];if("token"===t.type&&"string"===t.value.type)return[{property:e.name,raw:JSON.stringify(t.value.value.replace(/[\u4e00-\u9faF]/g,e=>`\\${e.charCodeAt(0).toString(16)}`))}]}}}};async function n(n,i){let a=this.async(),{implementation:o,targets:s,visitor:u,rem:c,...f}=this.getOptions();if(o&&"function"!=typeof o.transform){this.cacheable(!1),a(TypeError(`[lightningcss]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof o.transform}`));return}let l=o?.transform??t.transform;try{c&&!r.Length&&(r.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let{code:t,map:o}=l({filename:this.resourcePath,code:e.Buffer.from(n),targets:s,visitor:{...r,...u},sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&i?JSON.stringify(i):void 0,...f});this.cacheable(!0),a(null,t.toString(),o&&JSON.parse(o.toString()))}catch(e){this.cacheable(!1),a(e)}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return n}});const e=require("buffer"),t=require("lightningcss"),r={Declaration:{custom:e=>{if("content"===e.name&&1===e.value.length){let t=e.value[0];if("token"===t.type&&"string"===t.value.type)return[{property:e.name,raw:JSON.stringify(t.value.value.replace(/[\u4e00-\u9faF]/g,e=>`\\${e.charCodeAt(0).toString(16)}`))}]}}}};async function n(n,i){let a=this.async(),{implementation:o,targets:s,visitor:u,rem:c,...f}=this.getOptions();if(o&&"function"!=typeof o.transform){this.cacheable(!1),a(TypeError(`[lightningcss]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof o.transform}`));return}let l=o?.transform??t.transform;try{c&&!r.Length&&(r.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let{code:t,map:o}=l({filename:this.resourcePath,code:e.Buffer.from(n),targets:s,minify:!0,visitor:{...r,...u},sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&i?JSON.stringify(i):void 0,...f});this.cacheable(!0),a(null,t.toString(),o&&JSON.parse(o.toString()))}catch(e){this.cacheable(!1),a(e)}}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Targets } from 'lightningcss';
|
|
2
|
+
import { type Compiler } from 'webpack';
|
|
3
|
+
type Filter = string | RegExp;
|
|
4
|
+
type Implementation = typeof import('lightningcss');
|
|
5
|
+
interface MinifyPluginOpts {
|
|
6
|
+
implementation?: Implementation;
|
|
7
|
+
sourceMap?: boolean;
|
|
8
|
+
test?: RegExp;
|
|
9
|
+
include?: Filter | Filter[];
|
|
10
|
+
exclude?: Filter | Filter[];
|
|
11
|
+
targets?: Targets;
|
|
12
|
+
}
|
|
13
|
+
declare class LightningCssMinifyPlugin {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private readonly transform;
|
|
16
|
+
constructor(opts?: MinifyPluginOpts);
|
|
17
|
+
apply(compiler: Compiler): void;
|
|
18
|
+
private transformAssets;
|
|
19
|
+
}
|
|
20
|
+
export default LightningCssMinifyPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Buffer as s}from"buffer";import{loadFileSync as t}from"@moneko/mdx";import{transform as o}from"lightningcss";import i from"webpack";let{sources:{RawSource:n,SourceMapSource:e},ModuleFilenameHelpers:{matchObject:r}}=i,a="lightning-css-minify",m=/\.css(?:\?.*)?$/i,{name:p,version:f}=JSON.parse(t(`${process.cwd()}/package.json`)||"{}");export default class{constructor(s={}){let{implementation:t,...i}=s;if(t&&"function"!=typeof t.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof t.transform}`);this.transform=t?.transform??o,this.options=i}apply(s){let t=JSON.stringify({name:p,version:f,options:this.options});s.hooks.compilation.tap(a,s=>{s.hooks.chunkHash.tap(a,(s,o)=>o.update(t)),s.hooks.processAssets.tapPromise({name:a,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(a,s=>{s.hooks.print.for("asset.info.minimized").tap(a,(s,{green:t,formatFlag:o})=>s&&t&&o?t(o("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:o}}=t.compiler,{include:i,exclude:a,test:p,sourceMap:f=!!(o&&o.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(p||m).test(s.name)&&r({include:i,exclude:a},s.name));await Promise.all(l.map(async o=>{let i;let{source:r,map:a}=o.source.sourceAndMap(),m=r.toString(),p="string"==typeof r?s.from(r):r,l=this.transform({filename:o.name,code:p,minify:!0,sourceMap:f,...c}),h=l.code.toString();i=f?new e(h,o.name,JSON.parse(l.map.toString()),m,a,!0):new n(h),t.updateAsset(o.name,i,{...o.info,minimized:!0})}))}}
|
package/lib/prod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{removeDirAll as e}from"@moneko/mdx";import
|
|
1
|
+
import{removeDirAll as e}from"@moneko/mdx";import o from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import i from"webpack";import{BundleAnalyzerPlugin as n}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as s}from"./config.js";import{getMinifyOption as l}from"./minify.js";import u from"./paths.js";import a from"./plugin/done.js";import c from"./plugin/lightningcss-plugin.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=i,h=[];s.minifier&&(h.push(new m(l(s.minifier?.type||"swc",s.minifier?.options))),h.push(new c));let k={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:h};i(r(p,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",optimization:k,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.splitChunk&&new d({minChunkSize:1e4}),s.bundleAnalyzer&&new n(s.bundleAnalyzer),s.bar&&new t(s.bar),new a({done:e=>{s.done?.(e),s.seo&&f()}})].filter(Boolean)})).run(e=>{if(e)throw e}),process.on("exit",function(){e(u.cachePath)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.5",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"core-js-compat": "3.34.0",
|
|
22
22
|
"cross-env": "7.0.3",
|
|
23
23
|
"css-loader": "6.8.1",
|
|
24
|
-
"css-minimizer-webpack-plugin": "5.0.1",
|
|
25
24
|
"html-webpack-plugin": "5.5.4",
|
|
26
25
|
"less": "4.2.0",
|
|
27
26
|
"less-loader": "11.1.3",
|
package/typings/global.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { DonePluginOption } from '../lib/plugin/done';
|
|
|
6
6
|
import type { MdxOptions } from '@moneko/mdx';
|
|
7
7
|
import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions } from '@swc/core';
|
|
8
8
|
import type { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
|
|
9
|
-
import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
|
|
10
9
|
import type { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
11
10
|
import type { MinifyOptions as TerserMinifyOptions } from 'terser';
|
|
12
11
|
import type { Options } from 'ts-import-plugin';
|
|
@@ -110,24 +109,11 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
110
109
|
/** 压缩配置 */
|
|
111
110
|
minifier:
|
|
112
111
|
| {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
type?: MinifierType;
|
|
119
|
-
options?: SwcMinifyOptions | TerserMinifyOptions;
|
|
120
|
-
}
|
|
121
|
-
| false;
|
|
122
|
-
css?:
|
|
123
|
-
| {
|
|
124
|
-
/**
|
|
125
|
-
* @default 'swc'
|
|
126
|
-
*/
|
|
127
|
-
type?: CssMinify;
|
|
128
|
-
options?: CssNanoOptionsExtended;
|
|
129
|
-
}
|
|
130
|
-
| false;
|
|
112
|
+
/**
|
|
113
|
+
* @default 'swc'
|
|
114
|
+
*/
|
|
115
|
+
type?: MinifierType;
|
|
116
|
+
options?: SwcMinifyOptions | TerserMinifyOptions;
|
|
131
117
|
}
|
|
132
118
|
| false;
|
|
133
119
|
/** 环境变量, 可通过 process.env 获取 */
|