@moneko/core 3.1.5-beta.0 → 3.1.5-beta.2

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 CHANGED
@@ -1 +1 @@
1
- import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,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}=o,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=l.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:"assets/[hash][ext][query]",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")};l.entry&&("string"==typeof l.entry?J=l.entry:Object.keys(l.entry)&&Object.assign(J,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let R=l.basename.split("/").filter(Boolean).length,U=`${Array(R).fill("..").join("/")+(R?"/":"")}404.html`,{pathSegmentsToKeep:_=R,path:q=U}=l.fixBrowserRouter||{},z=!1;l.cacheDirectory&&(z={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.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:l.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/"]}),l.htmlPluginOption&&new s(p),l.fixBrowserRouter&&new s({filename:q,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${_||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(l.env)}),new S({paths:[/\.d\.ts$/]}),l.sourceMap&&new M(l.sourceMap),l.bar&&new n(l.bar),new i({done:()=>{!g&&l.seo&&x(),l.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:g&&{imports:!1,entries:!1},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx",".wasm"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:l.externals,output:outputConfig};
1
+ import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,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}=o,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=l.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:"assets/[hash][ext][query]",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")};l.entry&&("string"==typeof l.entry?J=l.entry:Object.keys(l.entry)&&Object.assign(J,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let R=l.basename.split("/").filter(Boolean).length,U=`${Array(R).fill("..").join("/")+(R?"/":"")}404.html`,{pathSegmentsToKeep:_=R,path:q=U}=l.fixBrowserRouter||{},z=!1;l.cacheDirectory&&(z={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.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:l.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/"]}),l.htmlPluginOption&&new s(p),l.fixBrowserRouter&&new s({filename:q,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${_||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(l.env)}),new S({paths:[/\.d\.ts$/]}),l.sourceMap&&new M(l.sourceMap),l.bar&&new n(l.bar),new i({done:()=>{!g&&l.seo&&x(),l.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:g&&{imports:!1,entries:!1},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx",".wasm"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:l.externals,output:outputConfig};
@@ -9,9 +9,7 @@ export default /**
9
9
  * ```
10
10
  */class{// eslint-disable-next-line no-unused-vars
11
11
  constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{// 通过最终的 webpack 配置的 plugins 属性,根据插件的 constructor.name 拿到 html-webpack-plugin 实例
12
- let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);// .find(
13
- // (plugin) => plugin instanceof HtmlWebpackPlugin,
14
- // ) as typeof HtmlWebpackPlugin;
12
+ let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);// .find((plugin) => plugin instanceof HtmlWebpackPlugin) as typeof HtmlWebpackPlugin;
15
13
  if(e){// 获取 html-webpack-plugin 所有的 hooks
16
14
  let t=e.getHooks(a);// 在插入标签之前做些什么
17
15
  t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(// 拿到所有的标签,如果是 script 标签,并且满足我们的匹配函数,则将其 attributes['entry'] 设为 true
@@ -1,3 +1,4 @@
1
- import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as o,PUBLICPATH as t}from"./config.js";import{hasPkg as l}from"./has-pkg.js";import r from"./modify-vars.js";import a from"./paths.js";import{FRAMEWORK as i,isDev as n,isMicro as c}from"./process-env.js";import m from"./swcrc.js";import p from"./tsloader.config.js";import{resolveNodeModulesPath as d,resolveProgramPath as u}from"./utils.js";let f={loader:`${a.corePath}/loader/css-unicode.cjs`},y=c?t:"../",x={loader:e.loader,options:{publicPath:"/"!==y?y:"../"}},$=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};n&&(x="style-loader");let g=[...o.cssModules,`@moneko/${i}`,"neko-ui"].map(d),j=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(u)],v=["components","example","mock","site","src","server"].map(u),w=[x,n&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!n}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
2
- auto:e=>{for(let s=0,o=g.length;s<o;s++)if(e&&e?.includes(g[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
3
- localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,f,{loader:"less-loader",options:{sourceMap:!!o.sourceMap,lessOptions:{modifyVars:r,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),b={loader:"tsc"===o.compiler?"ts-loader":"swc-loader",options:"tsc"===o.compiler?p:m(n)},h=v.concat(o.rulesInclude?.media?.map(d)||[]),I=v.concat(o.rulesInclude?.fonts?.map(d)||[]),k=v.concat(o.rulesInclude?.less?.map(d)||[]),O=v.concat(o.rulesInclude?.css?.map(d)||[]),B=v.concat(o.rulesInclude?.js?.map(d)||[]),L=v.concat(o.rulesInclude?.wasm?.map(d)||[]),M={rules:[{test:/\.mdx?$/i,include:[u("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/i,type:"webassembly/async",include:L},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:h},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)},include:h},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:h},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:w,include:k},{test:/\.css$/i,use:[x,"css-loader",$,f].filter(Boolean),include:O},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...o.prefixJsLoader,b].filter(Boolean),include:B},{test:/\.mdx?$/i,use:[...o.prefixJsLoader,b,{loader:"@mdx-js/loader",options:o.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...o.moduleRules]};export default M;
1
+ import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o}from"./config.js";import{hasPkg as l}from"./has-pkg.js";import r from"./modify-vars.js";import a from"./paths.js";import{FRAMEWORK as i,isDev as n,isMicro as c}from"./process-env.js";import m from"./swcrc.js";import p from"./tsloader.config.js";import{resolveNodeModulesPath as d,resolveProgramPath as u}from"./utils.js";let f={loader:`${a.corePath}/loader/css-unicode.cjs`},y=c?o:"../",x={loader:e.loader,options:{publicPath:"/"!==y?y:"../"}},$=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};n&&(x="style-loader");let g=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(d),j=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(u)],v=["components","example","mock","site","src","server"].map(u),w=[x,n&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!n}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
2
+ auto:e=>{for(let s=0,t=g.length;s<t;s++)if(e&&e?.includes(g[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
3
+ localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,f,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:r,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),b={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?p:m(n)},h=v.concat(t.rulesInclude?.media?.map(d)||[]),I=v.concat(t.rulesInclude?.fonts?.map(d)||[]),k=v.concat(t.rulesInclude?.less?.map(d)||[]),O=v.concat(t.rulesInclude?.css?.map(d)||[]),B=v.concat(t.rulesInclude?.js?.map(d)||[]),L=v.concat(t.rulesInclude?.wasm?.map(d)||[]),M={rules:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.mdx?$/i,include:[u("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{test:/\.wasm$/i,type:"webassembly/async",include:L},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:h},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)},include:h},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:h},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:w,include:k},{test:/\.css$/i,type:"css/auto",use:[x,// 'css-loader',
4
+ $,f].filter(Boolean),include:O},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,b].filter(Boolean),include:B},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,b,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default M;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.1.5-beta.0",
3
+ "version": "3.1.5-beta.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -12,9 +12,9 @@
12
12
  "author": "moneko",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@mdx-js/loader": "2.3.0",
15
+ "@mdx-js/loader": "3.0.0",
16
16
  "@soda/friendly-errors-webpack-plugin": "1.8.1",
17
- "@swc/core": "1.3.94",
17
+ "@swc/core": "1.3.95",
18
18
  "@swc/css": "0.0.28",
19
19
  "@swc/helpers": "0.5.3",
20
20
  "@teamsupercell/typings-for-css-modules-loader": "2.5.2",