@moneko/core 3.26.12 → 3.26.13
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/common.d.mts +1 -3
- package/lib/build/common.mjs +1 -1
- package/lib/build.d.mts +3 -9
- package/lib/build.mjs +1 -1
- package/lib/common.d.mts +2 -6
- package/lib/common.mjs +1 -1
- package/lib/config.d.mts +2 -1
- package/lib/config.mjs +1 -1
- package/lib/dev/mock.d.mts +18 -7
- package/lib/dev/mock.mjs +1 -1
- package/lib/dev/proxy.d.mts +15 -8
- package/lib/dev/proxy.mjs +1 -1
- package/lib/dev.d.mts +17 -14
- package/lib/dev.mjs +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/options/modify-vars.d.mts +0 -1
- package/lib/options/modify-vars.mjs +1 -1
- package/lib/plugin/html-plugin.d.mts +48 -0
- package/lib/plugin/html-plugin.mjs +1 -0
- package/lib/plugin/swc-minify-plugin.d.mts +9 -0
- package/lib/plugin/swc-minify-plugin.mjs +1 -0
- package/lib/plugins.config.d.mts +2 -15
- package/lib/plugins.config.mjs +1 -1
- package/lib/utils/create-types.d.mts +11 -4
- package/lib/utils/create-types.mjs +1 -1
- package/lib/utils/dts.d.mts +2 -9
- package/lib/utils/dts.mjs +1 -1
- package/package.json +8 -13
- package/typings/global.d.ts +5 -63
- package/lib/commom/os-tmp-dir.d.mts +0 -2
- package/lib/commom/os-tmp-dir.mjs +0 -1
- package/lib/options/html-plugin-option.d.mts +0 -12
- package/lib/options/html-plugin-option.mjs +0 -11
- package/lib/options/js-minify.d.mts +0 -26
- package/lib/options/js-minify.mjs +0 -1
- package/lib/plugin/add-entry-attribute.d.mts +0 -10
- package/lib/plugin/add-entry-attribute.mjs +0 -1
package/lib/build/common.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
3
2
|
import webpack, { type Configuration } from 'webpack';
|
|
4
|
-
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
5
3
|
import { merge } from 'webpack-merge';
|
|
6
4
|
import { commonConfig } from '../common.mjs';
|
|
7
5
|
import { CONFIG } from '../config.mjs';
|
|
8
|
-
import { getMinifyOption } from '../options/js-minify.mjs';
|
|
9
6
|
import { LightningCssMinifyPlugin } from '../plugin/lightningcss-plugin.mjs';
|
|
7
|
+
import SwcMinifyPlugin from '../plugin/swc-minify-plugin.mjs';
|
|
10
8
|
import { getLightningCssTargets } from '../polyfills/targets.mjs';
|
|
11
9
|
declare const minimizer: readonly [];
|
|
12
10
|
declare const defaultPerformance: Configuration['performance'];
|
package/lib/build/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import i from"
|
|
1
|
+
import e from"mini-css-extract-plugin";import i from"webpack";import{merge as n}from"webpack-merge";import{commonConfig as m}from"../common.mjs";import{CONFIG as r}from"../config.mjs";import{LightningCssMinifyPlugin as t}from"../plugin/lightningcss-plugin.mjs";import l from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as s}from"../polyfills/targets.mjs";let o=[];r.minifier&&(o.push(new l(r.minifier)),o.push(new t({targets:s()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...r.performance},u=n(m,{performance:r.performance&&p,plugins:[new e({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",ignoreOrder:!0})],optimization:{splitChunks:r.splitChunk,runtimeChunk:r.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o}});if(r.splitChunk&&u.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:51200})),r.bundleAnalyzer){let e=(await import("webpack-bundle-analyzer")).BundleAnalyzerPlugin;u.plugins?.push(new e({analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1,defaultSizes:"gzip",logLevel:"silent",...r.bundleAnalyzer}))}export default u;
|
package/lib/build.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
2
|
import { analyzeBundleSize, completedInfo, ink, println, progressBar } from '@moneko/utils';
|
|
3
|
-
import webpack, { type
|
|
3
|
+
import webpack, { type Compiler, type Configuration, type Stats } from 'webpack';
|
|
4
4
|
import { merge } from 'webpack-merge';
|
|
5
5
|
import buildCommon from './build/common.mjs';
|
|
6
6
|
import paths from './commom/paths.mjs';
|
|
@@ -9,13 +9,7 @@ import { empty } from './utils/index.mjs';
|
|
|
9
9
|
import seo from './utils/seo.mjs';
|
|
10
10
|
import { CONFIG } from './config.mjs';
|
|
11
11
|
import moduleConfig from './module.config.mjs';
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
color: string;
|
|
15
|
-
};
|
|
16
|
-
declare const bar_name: string;
|
|
17
|
-
declare const ProgressPlugin: typeof webpack.ProgressPlugin;
|
|
18
|
-
declare const clientOption: webpack.Configuration;
|
|
19
|
-
declare const instance: webpack.Compiler;
|
|
12
|
+
declare const clientOption: Configuration;
|
|
13
|
+
declare const instance: Compiler;
|
|
20
14
|
declare function printCompilationMessages(stats: Stats);
|
|
21
15
|
declare async function build();
|
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import{analyzeBundleSize as
|
|
1
|
+
import{relative as o}from"node:path";import{analyzeBundleSize as m,completedInfo as r,ink as i,println as t,progressBar as e}from"@moneko/utils";import n from"webpack";import{merge as s}from"webpack-merge";import p from"./build/common.mjs";import a from"./commom/paths.mjs";import l from"./plugin/done.mjs";import{empty as u}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import d from"./module.config.mjs";let g=s(p,{module:d(!1),plugins:[]});if(f.done&&g.plugins.push(new l({done:f.done})),f.bar){let o=f.bar.name||"Build";g.plugins.push(new n.ProgressPlugin({handler(m,r,...i){e(m||0,1,o,i.length?`[${r}] ${i.join(" ")}`:""),1===m&&process.stdout.write("\r\x1b[2K")}}))}let h=n(g);async function w(){let e=await new Promise((o,m)=>{h.run((r,i)=>{r&&m(r),i?o(i):m(Error("编译过程中没有生成统计信息"))})});(e.hasErrors()||e.hasWarnings())&&function(o){let{warnings:m,errors:r}=o.compilation;m.forEach(o=>{t(i(o.message,"178"))}),r.forEach(o=>{t(i(o.message,"red"))})}(e),await new Promise(n=>{e.compilation.compiler.cache.shutdown(s=>{s&&t(i(s.toString(),"red")),m(e.compilation.outputOptions.path,["\\.js$"]),r(~~((e.endTime-e.startTime)/10)/100,o(a.programPath,e.compilation.outputOptions.path)),n()})}),f.seo&&c()}process.on("exit",u),await w();
|
package/lib/common.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname, join, resolve } from 'node:path';
|
|
2
|
-
import type { Configuration, FileCacheOptions
|
|
2
|
+
import type { Configuration, FileCacheOptions } from 'webpack';
|
|
3
3
|
import paths, { config_files, CUSTOMCONFIG } from './commom/paths.mjs';
|
|
4
|
-
import OverrideResolverPlugin
|
|
4
|
+
import OverrideResolverPlugin from './plugin/override-resolve.mjs';
|
|
5
5
|
import { isObject, node_modules, resolveProgram } from './utils/index.mjs';
|
|
6
6
|
import { exampleModuleName } from './vm/example.mjs';
|
|
7
7
|
import app from './vm/info.mjs';
|
|
@@ -11,8 +11,4 @@ import { isDev, isLibrary, NODE_ENV, PACKAGENAME, PACKAGEVERSION } from './proce
|
|
|
11
11
|
export declare const outputConfig: Configuration['output'];
|
|
12
12
|
declare let entryMap: Configuration['entry'];
|
|
13
13
|
declare let cacheConfig: FileCacheOptions | false;
|
|
14
|
-
declare const overrideResolve: {
|
|
15
|
-
original: string;
|
|
16
|
-
override: string;
|
|
17
|
-
};
|
|
18
14
|
export declare const commonConfig: Configuration;
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extname as e,join as t,resolve as o}from"node:path";import
|
|
1
|
+
import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as r,resolveProgram as m}from"./utils/index.mjs";import{exampleModuleName as p}from"./vm/example.mjs";import c from"./vm/info.mjs";import{CONFIG as u,PUBLICPATH as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isDev as f,isLibrary as g,NODE_ENV as b,PACKAGENAME as y,PACKAGEVERSION as j}from"./process-env.mjs";export const outputConfig={path:m(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${f?"name":"contenthash"}].js`,assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[name][hash][ext]`},library:{name:`${c.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:f,clean:!0,publicPath:d,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[u.polyfill&&t(s.corePath,"./polyfills/replace-children.mjs"),r("@app/entry")].filter(Boolean)};u.entry&&("string"==typeof u.entry?v={main:[u.entry]}:Object.keys(u.entry)&&(v=Object.assign(v,u.entry))),"string"==typeof v.main&&(v.main=[v.main]),u.output&&("string"==typeof u.output?outputConfig.path=u.output:Object.keys(u.output)&&Object.assign(outputConfig,u.output));let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,b].filter(Boolean).join("-")}`,version:`${j}`,buildDependencies:{config:n}};!1===u.cache?C=!1:l(u.cache)&&(C=Object.assign(C,u.cache));export const commonConfig={name:"client",target:"web",devtool:u.devtool,entry:v,mode:f?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:u.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:u.lazyCompilation&&f&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(r(p))||t.startsWith(r("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(u.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...u.buildHttp}:u.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:u.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:u.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:u.externals,output:outputConfig};u.overrideResolve&&commonConfig.resolve.plugins.push(new i(Object.assign({original:u.alias["@"],override:a&&m(a)},u.overrideResolve)));
|
package/lib/config.d.mts
CHANGED
|
@@ -7,13 +7,14 @@ import jsxDomExpressions from './options/jsx-dom-expressions.mjs';
|
|
|
7
7
|
import splitChunk from './options/split-chunk.mjs';
|
|
8
8
|
import { isFunction, resolveProgram } from './utils/index.mjs';
|
|
9
9
|
import type { ConfigType } from './index.mjs';
|
|
10
|
-
import { APPTYPE, FRAMEWORK, isDev, isLibrary, isMobile, jsxImportSource, mainDirectory, NODE_ENV, PACKAGENAME } from './process-env.mjs';
|
|
10
|
+
import { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMobile, jsxImportSource, mainDirectory, NODE_ENV, PACKAGENAME } from './process-env.mjs';
|
|
11
11
|
declare const includeModule: readonly [string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string];
|
|
12
12
|
export declare function getConfig(path: string): Promise<ConfigType>;
|
|
13
13
|
type EnvType = {
|
|
14
14
|
NODE_ENV: string;
|
|
15
15
|
APPTYPE: string;
|
|
16
16
|
FRAMEWORK: string;
|
|
17
|
+
PROJECTNAME?: string;
|
|
17
18
|
};
|
|
18
19
|
declare const resp: [EnvType, ConfigType, ConfigType];
|
|
19
20
|
declare const env: EnvType;
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileExists as e}from"@moneko/utils";import{merge as o}from"webpack-merge";import t from"./commom/paths.mjs";import n from"./commom/require.mjs";import
|
|
1
|
+
import{fileExists as e}from"@moneko/utils";import{merge as o}from"webpack-merge";import t from"./commom/paths.mjs";import n from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import s from"./options/jsx-dom-expressions.mjs";import r from"./options/split-chunk.mjs";import{isFunction as l,resolveProgram as a}from"./utils/index.mjs";import{APPTYPE as m,coreName as p,FRAMEWORK as c,isDev as u,isLibrary as d,isMobile as f,jsxImportSource as h,mainDirectory as g,NODE_ENV as v,PACKAGENAME as x}from"./process-env.mjs";let P=["@app","@moneko","neko-ui",".cache/http/data","@ant-design","@antv","@antv/x6","@antv/x6-react-components","@element-plus","ant-design-vue","antd","antd-mini","antd-mobile","antd-mobile-icons","element-plus","element-ui","ng-zorro-antd","@antv","@mui","@du","ahooks","rc-queue-anim","umi","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design"];export function getConfig(o){return delete n.cache[o],new Promise(t=>{if(e(o)){let e=n(o).default;return t(l(e)?e(process):e)}return t({})})}let b=await Promise.all([i(v,m,c,[]),getConfig(t.configPath),getConfig(t.customConfigPath)]),C=b[0],w=b[1],j=b[2],k={devtool:u?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:C,basename:"/",publicPath:"/",rem:{designSize:f?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":a(g)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{title:x.toLocaleUpperCase(),favicon:`node_modules/${p}/lib/options/favicon.ico`},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:r,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:P,js:P,media:P,font:P,wasm:[]},mdx:{jsx:!1,development:u,jsxImportSource:h,providerImportSource:`@moneko/${c}/mdx`},jsxDomExpressions:s,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==c,bundleId:"com.moneko.bid",bundles:[]};d&&(k.alias=Object.assign(k.alias,{"@pkg":t.componentsPath,[x]:t.componentsPath}));let O=k;(!1===(O=o(O,w,j)).devtool||!1===O.sourceMap)&&(O.sourceMap=!1,O.devtool=!1),O.fixBrowserRouter&&O.htmlPluginOption&&(O.htmlPluginOption.tags||(O.htmlPluginOption.tags=[]),O.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=O;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/dev/mock.d.mts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
-
import { print } from '@moneko/utils';
|
|
2
|
+
import { directoryExists, print } from '@moneko/utils';
|
|
3
3
|
import { watch } from 'chokidar';
|
|
4
|
-
import
|
|
4
|
+
import type { FastifyPluginAsync, FastifyReply, FastifyRequest } from 'fastify';
|
|
5
5
|
import { merge } from 'webpack-merge';
|
|
6
6
|
import log from '../commom/log.mjs';
|
|
7
7
|
import matchPath from '../commom/match-path.mjs';
|
|
8
8
|
import require from '../commom/require.mjs';
|
|
9
9
|
import { jsonSchema } from './json-schema.mjs';
|
|
10
|
-
export interface RequestFormData extends
|
|
11
|
-
files
|
|
10
|
+
export interface RequestFormData extends FastifyRequest {
|
|
11
|
+
files?: {
|
|
12
|
+
fieldname: string;
|
|
13
|
+
originalname: string;
|
|
14
|
+
encoding: string;
|
|
15
|
+
mimetype: string;
|
|
16
|
+
buffer: Buffer;
|
|
17
|
+
size: number;
|
|
18
|
+
}[];
|
|
19
|
+
params: Record<string, string>;
|
|
12
20
|
}
|
|
13
|
-
export type ProxyFuncType = (req:
|
|
21
|
+
export type ProxyFuncType = (req: FastifyRequest, reply: FastifyReply, done: () => void) => void | Promise<void>;
|
|
14
22
|
export type MockConfiguration = Record<string, ProxyFuncType | Record<string, any> | null>;
|
|
15
23
|
declare function clearProxy(iproxy: MockConfiguration, path: string, old: MockConfiguration);
|
|
16
24
|
export type YApiOptionBySchema = {
|
|
@@ -26,5 +34,8 @@ export type YApiOption = {
|
|
|
26
34
|
pathRewrite: string;
|
|
27
35
|
};
|
|
28
36
|
export declare const yApiMock: (req: RequestFormData, yapi: YApiOption) => Promise<Any>;
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
export interface MockPluginOptions {
|
|
38
|
+
directory: string;
|
|
39
|
+
}
|
|
40
|
+
declare const setupMock: FastifyPluginAsync<MockPluginOptions>;
|
|
41
|
+
export default setupMock;
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:http";import{print as
|
|
1
|
+
import e from"node:http";import{directoryExists as t,print as o}from"@moneko/utils";import{watch as r}from"chokidar";import{merge as a}from"webpack-merge";import n from"../commom/log.mjs";import s from"../commom/match-path.mjs";import c from"../commom/require.mjs";import{jsonSchema as m}from"./json-schema.mjs";function i(e,t,o){if(delete c.cache[t],o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&(e[r]=null,delete e[r]);o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise(r=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),n=m(t);void 0!==o?r(a(n,o)):r(n)}}catch(e){n(e)}})})});export const yApiMock=(t,o)=>new Promise((r,a)=>{let s=new URL(o.host),c={hostname:s.hostname,port:s.port,path:t.url.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:t.method,headers:t.headers,query:t.query},m=e.request(c,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{r(JSON.parse(t))}catch(e){n(e)}})});m.on("error",e=>{a(e.message)}),m.write(JSON.stringify(t.body)),m.end()});let p=async(e,a)=>{if(!t(a.directory))return;let m={},p={};r(a.directory).on("all",async function(e,t){if("string"==typeof t){switch(o("Updating mock...",!0),e){case"add":case"change":try{i(p,t,m);let e=c(t).default;m[t]=e,p=Object.assign(p,e)}catch(e){n(e)}break;case"unlink":i(p,t,m)}o("Mock update successful",!0)}}),e.addHook("preHandler",(e,t,o)=>{let r=`${e.method} ${e.url}`,a=Object.keys(p).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(r)});if(p[r]||a&&a.length>0){let n=p[r]||p[a[0]];if("function"==typeof n){let r=s(a[0].split(" ")[1],e.url);r&&e.params&&"object"==typeof e.params&&Object.assign(e.params,r.params),n(e,t,o);return}t.send(n);return}o()})};export default p;
|
package/lib/dev/proxy.d.mts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import httpProxy from '@fastify/http-proxy';
|
|
3
|
+
import type { FastifyInstance } from 'fastify';
|
|
4
|
+
import { empty } from '../utils/index.mjs';
|
|
5
|
+
type ProxyItem = {
|
|
6
|
+
target: string;
|
|
7
|
+
changeOrigin?: boolean;
|
|
8
|
+
secure?: boolean;
|
|
9
|
+
ws?: boolean;
|
|
10
|
+
pathRewrite?: Record<string, string>;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export type ProxyConfig = Record<string, string | ProxyItem>;
|
|
14
|
+
declare const registeredProxies: Set<string>;
|
|
15
|
+
export declare async function setupProxy(app: FastifyInstance, proxyConfig?: ProxyConfig);
|
package/lib/dev/proxy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"@fastify/http-proxy";import{empty as t}from"../utils/index.mjs";let r=new Set;export async function setupProxy(s,i){for(let e of r)s.all(`${e}*`,t);if(r.clear(),i)for(let[t,o]of Object.entries(i)){let i="string"==typeof o?{upstream:o}:{upstream:o.target,websocket:o.ws,rewritePrefix:Object.entries(o.pathRewrite||{}).reduce((e,[t,r])=>e.replace(new RegExp(t),r),t),replyOptions:{rewriteRequestHeaders:(e,t)=>({...t,...o.headers,host:new URL(o.target).host})}};s.register(e,{prefix:t,...i}),r.add(t)}}
|
package/lib/dev.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { exec, spawn } from 'node:child_process';
|
|
2
2
|
import { watchFile } from 'node:fs';
|
|
3
|
-
import type { IncomingMessage
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import multer, { type Multer } from 'multer';
|
|
3
|
+
import type { IncomingMessage } from 'node:http';
|
|
4
|
+
import compress from '@fastify/compress';
|
|
5
|
+
import { fastifyMiddie } from '@fastify/middie';
|
|
6
|
+
import { ink, loadFile, print, println, progressBar } from '@moneko/utils';
|
|
7
|
+
import fastify, { FastifyInstance } from 'fastify';
|
|
9
8
|
import webpack, { type WebpackPluginInstance } from 'webpack';
|
|
10
9
|
import middleware from 'webpack-dev-middleware';
|
|
11
10
|
import webpackHotMiddleware, { type ClientOptions } from 'webpack-hot-middleware';
|
|
@@ -13,10 +12,11 @@ import { merge } from 'webpack-merge';
|
|
|
13
12
|
import { diffObject } from './commom/diff-object.mjs';
|
|
14
13
|
import hasPkg from './commom/has-pkg.mjs';
|
|
15
14
|
import paths, { config_files } from './commom/paths.mjs';
|
|
15
|
+
import Rule from './commom/rule.mjs';
|
|
16
16
|
import sigintExit from './commom/sigint-exit.mjs';
|
|
17
17
|
import { devLog, PORT } from './dev/config.mjs';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
18
|
+
import setupMock from './dev/mock.mjs';
|
|
19
|
+
import { type ProxyConfig, setupProxy } from './dev/proxy.mjs';
|
|
20
20
|
import reslove from './options/reslove.mjs';
|
|
21
21
|
import { empty, resolveProgram } from './utils/index.mjs';
|
|
22
22
|
import { commonConfig } from './common.mjs';
|
|
@@ -39,15 +39,18 @@ declare const bar: ConfigType['bar'];
|
|
|
39
39
|
declare const bar_name: string;
|
|
40
40
|
declare const clientOption: webpack.Configuration;
|
|
41
41
|
declare const compilers: webpack.Compiler;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
interface FastifyOptions {
|
|
43
|
+
http2?: boolean;
|
|
44
|
+
https?: {
|
|
45
|
+
key: string;
|
|
46
|
+
cert: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
declare const fastifyOptions: FastifyOptions;
|
|
45
50
|
declare const devMiddleware: middleware.API<IncomingMessage, middleware.ServerResponse>;
|
|
46
51
|
declare const hotMiddleware: ReturnType<typeof webpackHotMiddleware>;
|
|
52
|
+
declare const app: FastifyInstance;
|
|
47
53
|
declare const baseHtml: string;
|
|
48
|
-
declare let httpsServer: HttpsServer | undefined;
|
|
49
|
-
type Listen = HttpsServer<typeof IncomingMessage, typeof ServerResponse> | HttpServer<typeof IncomingMessage, typeof ServerResponse>;
|
|
50
|
-
declare const listen: Listen;
|
|
51
54
|
declare function exit();
|
|
52
55
|
declare const _prev: ConfigType[];
|
|
53
56
|
declare let prev: ConfigType;
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import r from"@fastify/compress";import{fastifyMiddie as i}from"@fastify/middie";import{ink as s,loadFile as l,print as n,println as a,progressBar as m}from"@moneko/utils";import c from"fastify";import p from"webpack";import d from"webpack-dev-middleware";import u from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as h}from"./commom/diff-object.mjs";import g from"./commom/has-pkg.mjs";import w,{config_files as y}from"./commom/paths.mjs";import x from"./commom/rule.mjs";import v from"./commom/sigint-exit.mjs";import{devLog as k,PORT as $}from"./dev/config.mjs";import j from"./dev/mock.mjs";import{setupProxy as b}from"./dev/proxy.mjs";import C from"./options/reslove.mjs";import{empty as P,resolveProgram as S}from"./utils/index.mjs";import{commonConfig as A}from"./common.mjs";import{CONFIG as E,getConfig as T,PUBLICPATH as M}from"./config.mjs";import I from"./module.config.mjs";import{isLibrary as _,isReact as O,refresh as R}from"./process-env.mjs";let H=!1!==E.stylelint&&g("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,q=!1!==E.eslint&&g("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,z=O&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,B=["js","jsx","ts","tsx","json","html","vue"],D=B.join(","),U=["css","scss","sass","less","ts","tsx","js","jsx"],G=U.join(","),L=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],W=`${M.endsWith("/")?"":"/"}__hmr__`,F=new URLSearchParams({name:"client",path:W,dynamicPublicPath:!0,timeout:2e3,reload:!R,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),N=A.output.path,K=E.bar.name||"Build",X=f(A,{entry:{main:[`${C.hotMiddlewareClient}?${F}`]},output:{path:N},module:I(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:x.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new p.HotModuleReplacementPlugin,new p.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),z&&new z,q&&new q({fix:!0,threads:!0,files:[`${E.alias["@"]}/**/*.{${D}}`,_&&`${E.alias["@pkg"]}/**/*.{${D}}`].filter(Boolean),extensions:B,exclude:L,cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:S("eslint.config.mjs"),configType:"flat"}),H&&new H({fix:!0,threads:!0,files:[`${E.alias["@"]}/**/*.{${G}}`,_&&`${E.alias["@pkg"]}/**/*.{${G}}`].filter(Boolean),extensions:U,exclude:L,cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!E.bar&&new p.ProgressPlugin({handler(e,t,...o){m(e||0,1,K,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),J=p(X);J.hooks.done.tap("client-log",e=>{k(null,e)});let Q={};if(E.devServer.https){let[e,t]=await Promise.all([l(E.devServer.https.key),l(E.devServer.https.cert)]);e||(a(s(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${E.devServer.https.key}`,"red")),process.exit(1)),t||(a(s(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${E.devServer.https.cert}`,"red")),process.exit(1)),Q.http2=!0,Q.https={key:e,cert:t}}let V=d(J,{writeToDisk:!1,index:"index.html",headers:e=>({"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...E.devServer.headers,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:X.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),Y=u(J,{log:!1,path:W,heartbeat:2e3}),Z=c({logger:!1,...Q});await Z.register(i),Z.use(V),Z.use(W,Y),j(Z,{directory:w.mockPath}),b(Z,E.proxy);let ee=`${X.output.path}/index.html`;function et(){process.exit(0)}Z.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=V.context.outputFileSystem,o=e?.readFileSync?.(ee);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(W)&&"text/event-stream"===e.headers.accept){e.raw.url=W,Y(e.raw,t.raw,P);return}}),Z.addHook("onClose",()=>{V.close(P),Z.server.close(P)}),await Z.register(r,{global:!0}),Z.listen({port:$});let eo=await Promise.all(y.map(T)),er=f(eo[0]||{},eo[1]||{});y.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(y.map(T)),i=f(o||{},r||{}),l=h(er,i);1===Object.keys(l).length&&"proxy"in l?(n(s(`代理更新中...`,"yellow"),!0),await b(Z,i.proxy),n(s(`代理更新完成...`,"green"),!0),E.proxy=i.proxy,er.proxy=i.proxy,er=i):(er=i,a(s(`检测到工程配置${s(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${$}`:`lsof -i :${$} -t`,(e,t)=>{if(e){a(s(`查找端口 ${$} 时发生错误: ${e.message}`,"red")),a(s("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=ei?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){a(s(`未找到占用端口 ${$} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){a(s(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ei="win32"===process.platform;process.on("SIGHUP",function(){Z.close(P),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",et)}()}),process.on("exit",function(){Z.close(P)}),v(et);
|
package/lib/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type * from '../typings/global.js';
|
|
2
2
|
export { default as hasPkg } from './commom/has-pkg.mjs';
|
|
3
3
|
export { getIPv4, getPort } from './commom/net.mjs';
|
|
4
|
-
export { default as osTmpDir } from './commom/os-tmp-dir.mjs';
|
|
5
4
|
export { CUSTOMCONFIG, default as paths, routeDir, yarnArgv } from './commom/paths.mjs';
|
|
6
5
|
export { default as require } from './commom/require.mjs';
|
|
7
6
|
export { default as Rule } from './commom/rule.mjs';
|
|
@@ -9,6 +8,7 @@ export { type MockConfiguration, type ProxyFuncType, type RequestFormData, yApiM
|
|
|
9
8
|
export type { ProxyConfig } from './dev/proxy.mjs';
|
|
10
9
|
export { type JsxDomExpressions, default as jsxDomExpressions } from './options/jsx-dom-expressions.mjs';
|
|
11
10
|
export { type OptimizationSplitChunksOptions, default as splitChunk } from './options/split-chunk.mjs';
|
|
11
|
+
export type { HtmlMeta, HtmlPluginOption } from './plugin/html-plugin.mjs';
|
|
12
12
|
export type { OverrideResolverOption } from './plugin/override-resolve.mjs';
|
|
13
13
|
export type { VirtualModulePluginOption } from './plugin/virtual-module.mjs';
|
|
14
14
|
export { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMicro, mainDirectory, PACKAGENAME, PACKAGEVERSION } from './process-env.mjs';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{
|
|
1
|
+
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as require}from"./commom/require.mjs";export{default as Rule}from"./commom/rule.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{APPTYPE,coreName,FRAMEWORK,isDev,isLibrary,isMicro,mainDirectory,PACKAGENAME,PACKAGEVERSION}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as i}from"../config.mjs";
|
|
1
|
+
import{CONFIG as i}from"../config.mjs";let f=i.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":i.htmlPluginOption?.favicon};Object.assign(n,i.modifyVars);export default n;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
import webpack, { type Compilation, type Compiler } from 'webpack';
|
|
4
|
+
export interface HtmlMeta {
|
|
5
|
+
[key: string]: string | undefined | HtmlMeta;
|
|
6
|
+
}
|
|
7
|
+
export interface HtmlPluginOption {
|
|
8
|
+
favicon?: string | false;
|
|
9
|
+
title?: string;
|
|
10
|
+
template?: string;
|
|
11
|
+
filename?: string | ((entryName: string) => string);
|
|
12
|
+
inject?: boolean | 'head' | 'body';
|
|
13
|
+
templateContent?: (options: HtmlPluginOption) => string;
|
|
14
|
+
tags?: {
|
|
15
|
+
textContent?: string;
|
|
16
|
+
tag?: string;
|
|
17
|
+
inject?: 'body' | 'head';
|
|
18
|
+
[key: string]: string | null | boolean | number | undefined;
|
|
19
|
+
}[];
|
|
20
|
+
meta?: HtmlMeta;
|
|
21
|
+
}
|
|
22
|
+
export declare class HtmlPlugin {
|
|
23
|
+
private options: HtmlPluginOption;
|
|
24
|
+
private AddEntry: RegExp;
|
|
25
|
+
private faviconPath: string;
|
|
26
|
+
private name: string;
|
|
27
|
+
private cachedMetaTags: string | null;
|
|
28
|
+
private cachedCustomTags: {
|
|
29
|
+
head: string;
|
|
30
|
+
body: string;
|
|
31
|
+
} | null;
|
|
32
|
+
constructor(options: HtmlPluginOption = {});
|
|
33
|
+
apply(compiler: Compiler);
|
|
34
|
+
private generateDefaultTemplate(): string;
|
|
35
|
+
private generateMetaTags(): string;
|
|
36
|
+
private generateCustomTags(): {
|
|
37
|
+
head: string;
|
|
38
|
+
body: string;
|
|
39
|
+
};
|
|
40
|
+
private getAssets(compilation: Compilation): {
|
|
41
|
+
js: string[];
|
|
42
|
+
css: string[];
|
|
43
|
+
};
|
|
44
|
+
private injectAssets(templateHtml: string, assets: {
|
|
45
|
+
js: string[];
|
|
46
|
+
css: string[];
|
|
47
|
+
}, inject: boolean | 'head' | 'body'): string;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import n from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/main\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"body",...t}}apply(o){o.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(o.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon);a.emitAsset(t,new n.sources.RawSource(e(h))),this.faviconPath=(a.outputOptions.publicPath||"")+t}else a.warnings.push(new n.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(o.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let r="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(r,new n.sources.RawSource(h))})})}generateDefaultTemplate(){let t=this.generateMetaTags(),e=this.generateCustomTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}">${e.head}</head><body><div id="root"></div>${e.body}</body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!==t&&!1!==t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),r=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(r):s.push(r)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=t.outputOptions.publicPath||"";for(let i of t.entrypoints.values())i.getFiles().forEach(t=>{t.endsWith(".js")?e.js.push(s+t):t.endsWith(".css")&&e.css.push(s+t)});return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet">`).join(""):"",n=e.js.length?e.js.map(t=>`<script ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type JsMinifyOptions, minify } from '@swc/core';
|
|
2
|
+
import webpack, { type Compiler } from 'webpack';
|
|
3
|
+
declare class SwcMinifyPlugin {
|
|
4
|
+
private name: string;
|
|
5
|
+
private options: JsMinifyOptions;
|
|
6
|
+
constructor(options: JsMinifyOptions);
|
|
7
|
+
apply(compiler: Compiler);
|
|
8
|
+
}
|
|
9
|
+
export default SwcMinifyPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{minify as e}from"@swc/core";import o from"webpack";export default class{constructor(e){this.name="SwcMinifyPlugin",this.options={format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0,...e}}apply(s){s.hooks.compilation.tap(this.name,s=>{s.hooks.processAssets.tapAsync({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async(t,a)=>{let n=Object.keys(t).filter(e=>e.endsWith(".js")&&!e.endsWith(".min.js"));try{await Promise.all(n.map(async t=>{let a=s.getAsset(t);if(a){let n=a.source.source().toString().replace(/\r\n/g,"\n"),{code:i}=await e(n,this.options);s.updateAsset(t,new o.sources.RawSource(i))}})),a()}catch(e){a(e)}})})}}
|
package/lib/plugins.config.d.mts
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import webpack, { type WebpackPluginInstance } from 'webpack';
|
|
3
|
-
import htmlPluginOption from './options/html-plugin-option.mjs';
|
|
4
|
-
import { AddEntryAttributePlugin } from './plugin/add-entry-attribute.mjs';
|
|
5
2
|
import { CopyPlugin } from './plugin/copy.mjs';
|
|
3
|
+
import { HtmlMeta, HtmlPlugin } from './plugin/html-plugin.mjs';
|
|
6
4
|
import moduleFederation from './plugin/module-federation.mjs';
|
|
7
5
|
import { VirtualModuleWebpackPlugin } from './plugin/virtual-module.mjs';
|
|
8
6
|
import { CONFIG } from './config.mjs';
|
|
9
|
-
import {
|
|
10
|
-
declare const DefinePlugin: typeof webpack.DefinePlugin;
|
|
11
|
-
declare const SourceMapDevToolPlugin: typeof webpack.SourceMapDevToolPlugin;
|
|
12
|
-
declare const IgnorePlugin: typeof webpack.IgnorePlugin;
|
|
13
|
-
declare const dirDeep: number;
|
|
14
|
-
declare const page404: string;
|
|
15
|
-
declare const fixBrowserRouter: {
|
|
16
|
-
pathSegmentsToKeep?: number;
|
|
17
|
-
path?: string;
|
|
18
|
-
};
|
|
19
|
-
declare const pathSegmentsToKeep: number;
|
|
20
|
-
declare const path: string;
|
|
7
|
+
import { description, keywords } from './process-env.mjs';
|
|
21
8
|
declare const plugins: WebpackPluginInstance[];
|
|
22
9
|
export default plugins;
|
package/lib/plugins.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
1
|
+
import e from"webpack";import{CopyPlugin as t}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import o from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as l}from"./plugin/virtual-module.mjs";import{CONFIG as n}from"./config.mjs";import{description as r,keywords as p}from"./process-env.mjs";let a=[...o,new l(n.virtualModule),new t(n.copy),new e.DefinePlugin({"process.env":JSON.stringify(n.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...n.plugins].filter(Boolean);if(n.htmlPluginOption){let e={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","mobile-web-app-capable":"yes",renderer:"webkit",description:r,keywords:Array.isArray(p)?p.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};n.seo&&(e.relCanonical={rel:"canonical",href:`https://${n.seo.domain}${n.basename}`}),n.htmlPluginOption.meta&&Object.assign(e,n.htmlPluginOption.meta),a.push(new i({...n.htmlPluginOption,meta:e}))}if(n.fixBrowserRouter){let e=n.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=n.fixBrowserRouter.pathSegmentsToKeep??e;a.push(new i({filename:n.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>${n.htmlPluginOption?.title}</title><script>const pathKeep = ${o};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}))}n.sourceMap&&a.push(new e.SourceMapDevToolPlugin(n.sourceMap));export default a;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare
|
|
1
|
+
import ts, { type DeclarationStatement, type ModifierLike, type ModifierToken, type ModuleDeclaration, type Node, type NodeArray, type Printer, type SourceFile, type Statement, type SyntaxKind as SyntaxKinds, type TransformationContext, type TransformationResult } from 'typescript';
|
|
2
|
+
declare const SyntaxKind: typeof SyntaxKinds;
|
|
3
|
+
declare const declareModifier: ModifierToken<SyntaxKinds.DeclareKeyword>;
|
|
4
|
+
declare const exportModifier: ModifierToken<SyntaxKinds.ExportKeyword>;
|
|
5
|
+
declare const printer: Printer;
|
|
6
|
+
declare function transformer(context: TransformationContext);
|
|
7
|
+
declare function isTargetDeclaration(node: Node): node is DeclarationStatement & {
|
|
8
|
+
modifiers?: readonly ModifierLike[];
|
|
9
|
+
};
|
|
10
|
+
declare function updateDeclaration(node: Node, newModifiers: readonly ModifierLike[]): Node;
|
|
11
|
+
declare function createTypes(moduleName: string, dts: string): string;
|
|
5
12
|
export default createTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"typescript";let t=e.SyntaxKind,r=e.factory.createModifier(t.DeclareKeyword),i=e.factory.createModifier(t.ExportKeyword),a=e.createPrinter({newLine:e.NewLineKind.LineFeed});function n(r){let a=n=>{if((e.isInterfaceDeclaration(n)||e.isTypeAliasDeclaration(n)||e.isClassDeclaration(n)||e.isFunctionDeclaration(n)||e.isEnumDeclaration(n))&&n.modifiers?.some(e=>e.kind===t.DeclareKeyword)){let r=n.modifiers.map(e=>e.kind===t.DeclareKeyword?i:e);return e.isInterfaceDeclaration(n)?e.factory.updateInterfaceDeclaration(n,r,n.name,n.typeParameters,n.heritageClauses,n.members):n}return e.visitEachChild(n,a,r)};return t=>e.visitNode(t,a)}export default function(t,i){let o=e.createSourceFile(`@types/${t}.d.ts`,i,e.ScriptTarget.Latest,!0,e.ScriptKind.TS),c=e.transform(o,[n]),s=c.transformed[0],d=e.factory.createModuleDeclaration([r],e.factory.createStringLiteral(t),e.factory.createModuleBlock(s.statements),e.NodeFlags.None),l=[`// remote module: ${t}`,a.printNode(e.EmitHint.Unspecified,d,o)];return c.dispose(),l.join("\n")}
|
package/lib/utils/dts.d.mts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import ts from 'typescript';
|
|
1
|
+
import ts, { type CompilerOptions, type ModifierLike } from 'typescript';
|
|
3
2
|
import Rule from '../commom/rule.mjs';
|
|
4
|
-
declare const compilerOptions:
|
|
5
|
-
declare const fsMap: Map<string, string>;
|
|
6
|
-
declare const system: ts.System;
|
|
7
|
-
declare const env: VirtualTypeScriptEnvironment;
|
|
3
|
+
declare const compilerOptions: CompilerOptions;
|
|
8
4
|
export declare function generateDeclaration(source: string, filename: string): string;
|
|
9
|
-
interface SymbolObject {
|
|
10
|
-
exports?: Map<string, unknown>;
|
|
11
|
-
}
|
|
12
5
|
export declare function getExportKeys(source: string, filename: string): string[];
|
package/lib/utils/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"typescript";import t from"../commom/rule.mjs";let i={declaration:!0,emitDeclarationOnly:!0,target:e.ScriptTarget.ESNext,skipLibCheck:!0,checkJs:!1,skipDefaultLibCheck:!0,noResolve:!0,types:[],noEmitOnError:!1,noImplicitAny:!1,noImplicitThis:!1,noImplicitReturns:!1,noUnusedLocals:!1,noUnusedParameters:!1,noFallthroughCasesInSwitch:!1,strictNullChecks:!1,strictFunctionTypes:!1,strictBindCallApply:!1,strictPropertyInitialization:!1,strict:!1};export function generateDeclaration(r,a){let s=t.js.test(a)?a:`${a}.ts`,n="";return e.createProgram([s],i,{getSourceFile:t=>{if(t===s)return e.createSourceFile(t,r,i.target)},writeFile:(e,t)=>{e.endsWith(".d.ts")&&(n=t)},getDefaultLibFileName:()=>"lib.d.ts",getCurrentDirectory:()=>"",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>"\n",fileExists:()=>!0,readFile:()=>"",directoryExists:()=>!0,getDirectories:()=>[]}).emit(),n}export function getExportKeys(t,i){let r=new Set;for(let a of e.createSourceFile(i,t,e.ScriptTarget.Latest,!0).statements)if(e.isExportDeclaration(a)){if(a.exportClause&&e.isNamedExports(a.exportClause))for(let e of a.exportClause.elements)r.add(e.name.text)}else if(e.isExportAssignment(a))r.add("default");else if((e.isVariableStatement(a)||e.isFunctionDeclaration(a)||e.isClassDeclaration(a))&&a.modifiers?.some(t=>t.kind===e.SyntaxKind.ExportKeyword)){if(e.isFunctionDeclaration(a)||e.isClassDeclaration(a))a.name&&r.add(a.name.text);else if(e.isVariableStatement(a))for(let t of a.declarationList.declarations)e.isIdentifier(t.name)&&r.add(t.name.text)}return Array.from(r)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.26.
|
|
3
|
+
"version": "3.26.13",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -16,32 +16,28 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/core": "7.26.0",
|
|
19
|
+
"@fastify/compress": "7.0.3",
|
|
20
|
+
"@fastify/http-proxy": "9.5.0",
|
|
21
|
+
"@fastify/middie": "8.3.3",
|
|
19
22
|
"@moneko/mdx": "0.1.42",
|
|
20
23
|
"@moneko/transform-imports": "0.6.1",
|
|
21
24
|
"@moneko/utils": "0.1.19",
|
|
22
25
|
"@swc/cli": "0.5.2",
|
|
23
26
|
"@swc/core": "1.6.13",
|
|
24
|
-
"@typescript/vfs": "1.6.0",
|
|
25
27
|
"browserslist": "4.24.3",
|
|
26
|
-
"chokidar": "4.0.
|
|
28
|
+
"chokidar": "4.0.2",
|
|
27
29
|
"core-js": "3.39.0",
|
|
28
30
|
"core-js-compat": "3.39.0",
|
|
29
|
-
"
|
|
30
|
-
"html-webpack-plugin": "5.6.3",
|
|
31
|
-
"http-proxy-middleware": "3.0.3",
|
|
31
|
+
"fastify": "4.29.0",
|
|
32
32
|
"less": "4.2.1",
|
|
33
33
|
"less-loader": "12.2.0",
|
|
34
34
|
"lightningcss": "1.28.2",
|
|
35
35
|
"marked-completed": "1.2.14",
|
|
36
36
|
"mini-css-extract-plugin": "2.9.2",
|
|
37
|
-
"multer": "1.4.5-lts.1",
|
|
38
37
|
"style-loader": "4.0.0",
|
|
39
38
|
"swc-loader": "0.2.6",
|
|
40
|
-
"terser-webpack-plugin": "5.3.11",
|
|
41
|
-
"ts-morph": "24.0.0",
|
|
42
39
|
"typescript": "5.5.4",
|
|
43
40
|
"webpack": "5.97.1",
|
|
44
|
-
"webpack-bundle-analyzer": "4.10.2",
|
|
45
41
|
"webpack-dev-middleware": "7.4.2",
|
|
46
42
|
"webpack-hot-middleware": "2.26.1",
|
|
47
43
|
"webpack-merge": "6.0.1",
|
|
@@ -50,15 +46,14 @@
|
|
|
50
46
|
"devDependencies": {
|
|
51
47
|
"@moneko/css": "1.1.5",
|
|
52
48
|
"@types/babel__core": "7.20.5",
|
|
53
|
-
"@types/express": "5.0.0",
|
|
54
|
-
"@types/multer": "1.4.12",
|
|
55
49
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
56
50
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
57
51
|
"eslint-config-neko": "3.0.2",
|
|
58
52
|
"sass": "1.83.0",
|
|
59
53
|
"sass-loader": "16.0.4",
|
|
60
54
|
"solid-refresh": "0.7.5",
|
|
61
|
-
"stylelint": "
|
|
55
|
+
"stylelint": "16.11.0",
|
|
56
|
+
"webpack-bundle-analyzer": "4.10.2"
|
|
62
57
|
},
|
|
63
58
|
"files": [
|
|
64
59
|
"lib",
|
package/typings/global.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { MdxOptions } from '@moneko/mdx';
|
|
2
2
|
import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions } from '@swc/core';
|
|
3
|
-
import type { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
4
|
-
import type { Options } from 'http-proxy-middleware';
|
|
5
3
|
import type { PluginOptions as MiniCssExtractPluginOptions } from 'mini-css-extract-plugin';
|
|
6
4
|
import type { MinifyOptions as TerserMinifyOptions } from 'terser';
|
|
7
5
|
import type {
|
|
@@ -16,9 +14,11 @@ import type {
|
|
|
16
14
|
} from 'webpack';
|
|
17
15
|
|
|
18
16
|
import type {
|
|
17
|
+
HtmlPluginOption,
|
|
19
18
|
JsxDomExpressions,
|
|
20
19
|
OptimizationSplitChunksOptions,
|
|
21
20
|
OverrideResolverOption,
|
|
21
|
+
ProxyConfig,
|
|
22
22
|
VirtualModulePluginOption,
|
|
23
23
|
} from '../lib/index';
|
|
24
24
|
import type { CopyPluginOption } from '../lib/plugin/copy.mjs';
|
|
@@ -30,57 +30,7 @@ export type { MiniCssExtractPluginOptions, SwcMinifyOptions, TerserMinifyOptions
|
|
|
30
30
|
export type MinifierType = 'swc' | 'terser';
|
|
31
31
|
export declare type AppType = 'mobile' | 'site' | 'backstage' | 'micro' | 'library';
|
|
32
32
|
export declare type Framework = 'react' | 'solid';
|
|
33
|
-
export interface ProxyConfig {
|
|
34
|
-
[key: string]: Options;
|
|
35
|
-
}
|
|
36
33
|
|
|
37
|
-
export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
38
|
-
/**
|
|
39
|
-
* 自定义额外的 tags, 当需要添加远程cdn时很有用
|
|
40
|
-
* @description
|
|
41
|
-
* 如果你配置了自定义的 template, 那么默认情况下 tags 将不生效, 请在你的 template 中按照下方案例进行修改
|
|
42
|
-
* @example
|
|
43
|
-
* ```html
|
|
44
|
-
* <!DOCTYPE html>
|
|
45
|
-
<html lang="en">
|
|
46
|
-
<head>
|
|
47
|
-
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
48
|
-
<%
|
|
49
|
-
var customTag="";
|
|
50
|
-
if (htmlWebpackPlugin.options.tags) {
|
|
51
|
-
htmlWebpackPlugin.options.tags.forEach(function(item){
|
|
52
|
-
var { tag = "script", textContent = "", ...attrs } = item;
|
|
53
|
-
var _attrs = "";
|
|
54
|
-
for (const key in attrs) {
|
|
55
|
-
if (attrs.hasOwnProperty(key)) {
|
|
56
|
-
_attrs += `${key}="${attrs[key]}" `;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
customTag += `<${tag} ${_attrs}>${textContent}</${tag}>`;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
%>
|
|
63
|
-
<%= customTag %>
|
|
64
|
-
</head>
|
|
65
|
-
<body>
|
|
66
|
-
<div id="root"></div>
|
|
67
|
-
</body>
|
|
68
|
-
</html>
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
tags?: {
|
|
72
|
-
/**
|
|
73
|
-
* 标签内容
|
|
74
|
-
*/
|
|
75
|
-
textContent?: string;
|
|
76
|
-
/** 标签
|
|
77
|
-
* @default script
|
|
78
|
-
*/
|
|
79
|
-
tag?: string;
|
|
80
|
-
inject?: 'body' | 'head';
|
|
81
|
-
[key: string]: string | null | boolean | number;
|
|
82
|
-
}[];
|
|
83
|
-
};
|
|
84
34
|
export type DevtoolOption =
|
|
85
35
|
| 'eval'
|
|
86
36
|
| 'eval-cheap-source-map'
|
|
@@ -158,15 +108,7 @@ export declare type ConfigType = {
|
|
|
158
108
|
**/
|
|
159
109
|
entry?: Record<string, string> | string;
|
|
160
110
|
/** 压缩配置 */
|
|
161
|
-
minifier:
|
|
162
|
-
| {
|
|
163
|
-
/**
|
|
164
|
-
* @default 'swc'
|
|
165
|
-
*/
|
|
166
|
-
type?: MinifierType;
|
|
167
|
-
options?: SwcMinifyOptions | TerserMinifyOptions;
|
|
168
|
-
}
|
|
169
|
-
| false;
|
|
111
|
+
minifier: SwcMinifyOptions | false;
|
|
170
112
|
/** 环境变量, 可通过 process.env 获取 */
|
|
171
113
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
114
|
env: Record<string, any>;
|
|
@@ -303,8 +245,8 @@ export declare type ConfigType = {
|
|
|
303
245
|
cert: string;
|
|
304
246
|
};
|
|
305
247
|
};
|
|
306
|
-
/**
|
|
307
|
-
htmlPluginOption:
|
|
248
|
+
/** HtmlPlugin Option */
|
|
249
|
+
htmlPluginOption: HtmlPluginOption | false;
|
|
308
250
|
/** 需要拷贝的文件列表
|
|
309
251
|
* @example
|
|
310
252
|
* ```ts
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function(){let e;let s="win32"===process.platform;return e=s?process.env.TEMP||process.env.TMP||`${process.env.SystemRoot||process.env.windir}\\temp`:process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",(s?/[^:]\\$/:/.\/$/).test(e)&&(e=e.slice(0,-1)),e}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { merge } from 'webpack-merge';
|
|
2
|
-
import type { HtmlWebpackOption } from '../../typings/global.js';
|
|
3
|
-
import { CONFIG } from '../config.mjs';
|
|
4
|
-
import { coreName, description, keywords, PACKAGENAME } from '../process-env.mjs';
|
|
5
|
-
import { resolveProgram } from '../utils/index.mjs';
|
|
6
|
-
declare const option: HtmlWebpackOption;
|
|
7
|
-
declare const favicon: string | false;
|
|
8
|
-
declare function templateContent({ htmlWebpackPlugin: { options } }: any);
|
|
9
|
-
declare const relCanonical: string | false;
|
|
10
|
-
declare const meta: HtmlWebpackOption['meta'];
|
|
11
|
-
declare const htmlPluginOption: HtmlWebpackOption;
|
|
12
|
-
export default htmlPluginOption;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as t}from"../config.mjs";import{coreName as i,description as o,keywords as r,PACKAGENAME as a}from"../process-env.mjs";import{resolveProgram as n}from"../utils/index.mjs";let l=t.htmlPluginOption||{},p=l.favicon??`node_modules/${i}/lib/options/favicon.ico`,m=t.seo&&`https://${t.seo.domain}${t.basename}`,s={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","mobile-web-app-capable":"yes",renderer:"webkit",description:o,keywords:Array.isArray(r)?r.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};m&&Object.assign(s,{relCanonical:{rel:"canonical",href:m}});let c=e({title:t.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{minifyJS:!0,minifyCSS:!0,collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:s,tags:[]},l,{favicon:p?n(p):p},l.template?{template:n(l.template)}:{templateContent:function({htmlWebpackPlugin:{options:e}}){let t=e.tags,i="",o="";return t&&t.map(function(e){let{tag:t="script",textContent:r="",inject:a="head",...n}=e,l="";for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&(l+=`${e}="${n[e]}" `);let p=`<${t} ${l}>${r}</${t}>`;"body"===a?o+=p:i+=p}),`<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<title>${e.title}</title>
|
|
5
|
-
${i}
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<div id="root"></div>
|
|
9
|
-
${o}
|
|
10
|
-
</body>
|
|
11
|
-
</html>`}});export default c;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
-
import { merge } from 'webpack-merge';
|
|
3
|
-
import type { MinifierType, SwcMinifyOptions, TerserMinifyOptions } from '../index.mjs';
|
|
4
|
-
type MinifyObject = {
|
|
5
|
-
terser: {
|
|
6
|
-
minify: typeof TerserPlugin.terserMinify;
|
|
7
|
-
terserOptions: TerserMinifyOptions;
|
|
8
|
-
extractComments?: boolean;
|
|
9
|
-
};
|
|
10
|
-
swc: {
|
|
11
|
-
minify: typeof TerserPlugin.swcMinify;
|
|
12
|
-
terserOptions?: SwcMinifyOptions;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
declare const commonCompress: {
|
|
16
|
-
readonly drop_console: boolean;
|
|
17
|
-
readonly drop_debugger: boolean;
|
|
18
|
-
readonly global_defs: {
|
|
19
|
-
readonly '@alert': string;
|
|
20
|
-
};
|
|
21
|
-
readonly pure_funcs: readonly [string, string, string, string];
|
|
22
|
-
};
|
|
23
|
-
declare const commonMinifyConf: TerserMinifyOptions & SwcMinifyOptions;
|
|
24
|
-
export declare const minify: MinifyObject;
|
|
25
|
-
export declare const getMinifyOption: (type: string, options: {
|
|
26
|
-
}) => any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";let r={drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"]},s={ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1};export const minify={terser:{minify:e.terserMinify,terserOptions:{compress:r,...s,mangle:!0,format:{comments:!1},safari10:!1,parse:{}},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:{format:{comments:!1},compress:{...r,...s,top_retain:[],keep_infinity:!0},mangle:!0}}};export const getMinifyOption=(e="swc",r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
|
-
import type { Compiler } from 'webpack';
|
|
3
|
-
declare const name: string;
|
|
4
|
-
export declare class AddEntryAttributePlugin {
|
|
5
|
-
private readonly test;
|
|
6
|
-
constructor(opt: {
|
|
7
|
-
test: RegExp;
|
|
8
|
-
});
|
|
9
|
-
apply(compiler: Compiler);
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import t from"html-webpack-plugin";let s="AddEntryAttributePlugin";export class AddEntryAttributePlugin{constructor(t){this.test=t.test}apply(e){e.hooks.compilation.tap(s,e=>{t.getHooks(e).alterAssetTagGroups.tapAsync(s,(t,s)=>{for(let s=0,e=t.headTags.length;s<e;s++){let e=t.headTags[s];"script"===e.tagName&&e.attributes.src&&this.test.test(e.attributes.src)&&(e.attributes.entry=!0)}s(null,t)})})}}
|