@moneko/core 3.14.0 → 3.15.1
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.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileExists as e}from"@moneko/mdx";import{merge as o}from"webpack-merge";import t from"./options/jsx-dom-expressions.mjs";import s from"./options/split-chunk.mjs";import
|
|
1
|
+
import{fileExists as e}from"@moneko/mdx";import{merge as o}from"webpack-merge";import t from"./options/jsx-dom-expressions.mjs";import s from"./options/split-chunk.mjs";import i,{CUSTOMCONFIG as a}from"./paths.mjs";import{APPTYPE as r,FRAMEWORK as l,NODE_ENV as n,PACKAGENAME as m,isDev as p,isLibrary as c,isMobile as u,jsxImportSource as d,mainDirectory as h}from"./process-env.mjs";import{isFunction as f,resolveProgram as g}from"./utils/index.mjs";import x from"./utils/log.mjs";import P from"./utils/read-conf.mjs";import v from"./utils/setup-env.mjs";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"],j={devtool:p?"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:v(n,r,l),basename:"/",publicPath:"/",rem:{designSize:u?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(h)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},cacheDirectory:i.webpackCachePath,devServer:{host:"localhost",port:3e3},htmlPluginOption:{},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:s,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:p,jsxImportSource:d,providerImportSource:`@moneko/${l}/mdx`},jsxDomExpressions:t,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0},virtualModule:{},cssExtract:{}};c&&(j.alias=Object.assign(j.alias,{"@pkg":i.componentsPath,[m]:i.componentsPath}));let k=j,w={},b={};if(e(i.configPath)){let e=(await P(i.configPath,"index")).default;w=f(e)?e(process):e}if(a&&e(i.customConfigPath)){let e=(await P(i.customConfigPath,a)).default;b=f(e)?e(process):e}(!1===(k=o(k,w,b)).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:a,log:x};
|
package/lib/module.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as
|
|
1
|
+
let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as n}from"./paths.mjs";import{getLightningCssTargets as a}from"./polyfills/targets.mjs";import{FRAMEWORK as i,isDev as l,isLibrary as m}from"./process-env.mjs";import d from"./rule.mjs";import c from"./utils/has-pkg.mjs";import{node_modules as p,resolveProgram as u}from"./utils/index.mjs";import f from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import j from"./vm/generate-doc.mjs";import v from"./options/css-extract.mjs";import{saveFile as x}from"@moneko/mdx";import h from"./utils/reactive-object.mjs";let _={loader:`${r.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!s.sourceMap,analyzeDependencies:!1,targets:a(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!s.rem}},w={loader:"less-loader",options:{sourceMap:!!s.sourceMap,lessOptions:{modifyVars:o,javascriptEnabled:!0}}},k=[...s.cssModules,`@moneko/${i}`,"neko-ui"].map(p),M=["components","example","mock","site","src","server"].map(u);function $(e){return[...M,...s.rulesInclude?.[e]?.map(p)||[]]}n&&M.push(u(n)),s.overrideResolve&&s.overrideResolve.override&&M.push(s.overrideResolve.override);let O=$("css"),b=$("js"),P=$("media"),R=$("wasm"),L=$("font");c("sass")&&(e={loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}});let B=m&&l&&{test:d.tsdoc,include:s.alias["@pkg"],exclude:[d.node_modules,d.__tests__],enforce:"pre",loader:`${r.corePath}/loader/ts-doc.cjs`,options:{comment:y,generateDoc:j,getCommentPath:g}},D=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:d.wasm,type:"webassembly/async",include:R},{test:d.txt,type:"asset/source"},{test:d.ico,type:"asset/inline",include:P},{test:d.svg,type:"asset/inline",generator:{dataUrl:e=>f(e.toString())},include:P},{test:d.image,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:P},{test:d.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:P},{test:d.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:L}],S=s.prefixJsLoader.filter(Boolean)||[],I=new h({});function J(e){I.setData(`${e.resourcePath}.d.ts`,e.exports.map(({name:e,value:s})=>`export const ${e}: '${s}';`).join("\n")+"\n")}I.on("change",(e,s)=>{x(e,s)});export default(o=>{let n={loader:"swc-loader",options:t(o)},a={loader:"css-loader",options:{modules:{auto:e=>{if(e){for(let s=0,o=k.length;s<o;s++)if(e.includes(k[s]))return d.css_module.test(e)}return d.node_modules_css_module.test(e)},localIdentName:"[path][name]_[local]",exportLocalsConvention:"dashesOnly",exportOnlyLocals:o,getJSON:s.cssModuleDefinition?J:void 0},importLoaders:2}};return{noParse:d.no_parse,rules:[B,{oneOf:[...D,{test:d.js,use:[...S,n],include:b},{test:d.css,use:[v,"css-loader",_],include:O},e&&{test:d.scss,use:[v,a,_,e],include:O},{test:d.less,use:[v,a,_,w],include:O},{test:d.markdown,use:[...S,{loader:`${r.corePath}/loader/mdx.cjs`,options:s.mdx}],exclude:[d.node_modules]}].filter(Boolean)},...s.moduleRules].filter(Boolean)}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{loadFile as t,scanFolder as i}from"@moneko/mdx";import{basename as o,resolve as p}from"path";import e from"../utils/log.mjs";export class CopyPlugin{constructor(t){this.option=t}async writeFile(i,l){let r=l.compiler.outputFileSystem;if(r){let s=o(i),a=await t(p(i));r.writeFile(p(l.outputOptions.path,s),a,t=>{t&&e(`Error copying file ${s} to output directory: ${t}`)})}}apply(t){t.hooks.emit.tapPromise({name:"CopyPlugin",stage:t.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT},async t=>{if(this.option&&t.compiler.outputFileSystem){let o=[...this.option.files||[],...this.option.dirs?.flatMap(t=>i(t))||[]];await Promise.all(o.map(i=>this.writeFile(i,t)))}})}}
|
package/lib/plugins.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"html-webpack-plugin";import t from"webpack";import{CONFIG as o}from"./config.mjs";import l from"./options/html-plugin-option.mjs";import{AddEntryAttributePlugin as i}from"./plugin/add-entry-attribute.mjs";import r from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as n}from"./plugin/virtual-module.mjs";import{isMicro as p}from"./process-env.mjs";import{CopyPlugin as m}from"./plugin/copy
|
|
1
|
+
import e from"html-webpack-plugin";import t from"webpack";import{CONFIG as o}from"./config.mjs";import l from"./options/html-plugin-option.mjs";import{AddEntryAttributePlugin as i}from"./plugin/add-entry-attribute.mjs";import r from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as n}from"./plugin/virtual-module.mjs";import{isMicro as p}from"./process-env.mjs";import{CopyPlugin as m}from"./plugin/copy.mjs";let{DefinePlugin:s,SourceMapDevToolPlugin:a,IgnorePlugin:c}=t,u=o.basename.split("/").filter(Boolean).length,f=`${Array(u).fill("..").join("/")+(u?"/":"")}404.html`,{pathSegmentsToKeep:h=u,path:d=f}=o.fixBrowserRouter||{},g=[...r,new n(o.virtualModule),o.htmlPluginOption&&new e(l),o.fixBrowserRouter&&new e({filename:d,inject:!1,templateContent:()=>`<html lang="en"><head><title>${l.title}</title><script>const pathKeep = ${h||u};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>`}),new m(o.copy),p&&new i({test:/main\.bundle\.js$/}),new s({"process.env":JSON.stringify(o.env)}),new c({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new a(o.sourceMap),...o.plugins].filter(e=>!!e);export default g;
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
WebpackPluginInstance,
|
|
21
21
|
} from 'webpack';
|
|
22
22
|
import type { PluginOptions as MiniCssExtractPluginOptions } from 'mini-css-extract-plugin';
|
|
23
|
-
import type { CopyPluginOption } from '../lib/plugin/copy
|
|
23
|
+
import type { CopyPluginOption } from '../lib/plugin/copy.mjs';
|
|
24
24
|
|
|
25
25
|
export type { TerserMinifyOptions, SwcMinifyOptions, MiniCssExtractPluginOptions };
|
|
26
26
|
export type MinifierType = 'swc' | 'terser';
|
|
@@ -73,7 +73,6 @@ export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
|
73
73
|
[key: string]: string | null | boolean | number;
|
|
74
74
|
}[];
|
|
75
75
|
};
|
|
76
|
-
export type CssMinify = 'swc' | 'cssnano' | 'lightningcss';
|
|
77
76
|
export type DevtoolOption =
|
|
78
77
|
| 'eval'
|
|
79
78
|
| 'eval-cheap-source-map'
|
|
@@ -206,6 +205,10 @@ export declare type ConfigType = {
|
|
|
206
205
|
prefixJsLoader: RuleSetRule['use'][];
|
|
207
206
|
/** node_modules中, 需要开启 cssModules 的模块 */
|
|
208
207
|
cssModules: string[];
|
|
208
|
+
/** 为 cssModule 生成准确的声明文件
|
|
209
|
+
* @default true
|
|
210
|
+
*/
|
|
211
|
+
cssModuleDefinition: boolean;
|
|
209
212
|
/** 按需引入 */
|
|
210
213
|
importOnDemand?: SwcImportOnDemandTransform;
|
|
211
214
|
/** 开发服务器代理 */
|
|
@@ -221,7 +224,7 @@ export declare type ConfigType = {
|
|
|
221
224
|
/** HtmlWebpackPlugin Option */
|
|
222
225
|
htmlPluginOption: HtmlWebpackOption | false;
|
|
223
226
|
|
|
224
|
-
copy: CopyPluginOption
|
|
227
|
+
copy: CopyPluginOption;
|
|
225
228
|
/** 路由模式
|
|
226
229
|
* @description
|
|
227
230
|
* 当在不支持 browserRouter 的环境(GitHub pages)使用 browserRouter,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{loadFile as t,scanFolder as i}from"@moneko/mdx";import{basename as o,resolve as p}from"path";import e from"../utils/log.mjs";export class CopyPlugin{constructor(t){this.option=t}async writeFile(i,r){let l=r.compiler.outputFileSystem;if(l){let s=o(i),a=await t(p(i));l.writeFile(p(r.outputOptions.path,s),a,t=>{t&&e(`Error copying file ${s} to output directory: ${t}`)})}}apply(t){t.hooks.afterEmit.tapPromise({name:"CopyPlugin",stage:t.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT},async t=>{if(this.option&&t.compiler.outputFileSystem){let o=[...this.option.files||[],...this.option.dirs?.flatMap(t=>i(t))||[]];await Promise.all(o.map(i=>this.writeFile(i,t)))}})}}
|
|
File without changes
|