@moneko/core 3.0.0-beta.30 → 3.0.0-beta.32

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/utils.js CHANGED
@@ -1 +1,64 @@
1
- import{writeFileSync as e}from"fs";import{networkInterfaces as t}from"os";import r from"path";import{transformFileSync as o}from"@swc/core";import{cacheDir as n}from"./process-env.js";import s from"./resolver-sync.js";let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return o(e,c).code||"{}"}export function readConf(t,o){let s=r.join(n,`${o}.mjs`);return e(s,tfc(t),"utf-8"),import(s)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function getIPAdress(){let e=t();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];for(let e=0;e<r.length;e++){let t=r[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.address.startsWith("169.254")&&!t.internal)return t.address}}}export function resolveProgramPath(e){return r.resolve(process.cwd(),"./"+e)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>s.resolveSync({},process.cwd(),e)||e;export function isObject(e){let t=typeof e;return null!==e&&("object"==t||"function"==t)}export function isFunction(e){if(!isObject(e))return!1;let t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t||"[object GeneratorFunction]"==t||"[object Proxy]"==t}
1
+ import { writeFileSync } from 'fs';
2
+ import { networkInterfaces } from 'os';
3
+ import path from 'path';
4
+ import { transformFileSync } from '@swc/core';
5
+ import { cacheDir } from './process-env.js';
6
+ import resolverSync from './resolver-sync.js';
7
+ const swcOption = {
8
+ inputSourceMap: false,
9
+ sourceMaps: false,
10
+ module: {
11
+ type: 'es6'
12
+ },
13
+ jsc: {
14
+ parser: {
15
+ syntax: 'typescript'
16
+ },
17
+ loose: false
18
+ }
19
+ };
20
+ export function tfc(filepath) {
21
+ return transformFileSync(filepath, swcOption).code || '{}';
22
+ }
23
+ export function readConf(src, name) {
24
+ const cacheFile = path.join(cacheDir, `${name}.mjs`);
25
+ writeFileSync(cacheFile, tfc(src), 'utf-8');
26
+ return import(cacheFile);
27
+ }
28
+ export function toUpperCaseString(string) {
29
+ return string?.replace(/\b\w/g, (th)=>th.toUpperCase()).replace(/\./g, ' ');
30
+ }
31
+ export function getIPAdress() {
32
+ const interfaces = networkInterfaces();
33
+ for(const devName in interfaces){
34
+ if (Object.prototype.hasOwnProperty.call(interfaces, devName)) {
35
+ const iface = interfaces[devName];
36
+ for(let i = 0; i < iface.length; i++){
37
+ const alias = iface[i];
38
+ if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.address.startsWith('169.254') && !alias.internal) {
39
+ return alias.address;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ export function resolveProgramPath(src) {
46
+ return path.resolve(process.cwd(), './' + src);
47
+ }
48
+ export const resolveNodeModulesPath = (src)=>{
49
+ return resolveProgramPath(`node_modules/${src}`);
50
+ };
51
+ export const resolve = (url)=>resolverSync.resolveSync({}, process.cwd(), url) || url;
52
+ const funcTag = '[object Function]';
53
+ const asyncTag = '[object AsyncFunction]';
54
+ const genTag = '[object GeneratorFunction]';
55
+ const proxyTag = '[object Proxy]';
56
+ export function isObject(target) {
57
+ const type = typeof target;
58
+ return target !== null && (type == 'object' || type == 'function');
59
+ }
60
+ export function isFunction(target) {
61
+ if (!isObject(target)) return false;
62
+ const tagType = Object.prototype.toString.call(target);
63
+ return tagType == funcTag || tagType == asyncTag || tagType == genTag || tagType == proxyTag;
64
+ }
@@ -1,3 +1,4 @@
1
+ import './routes.js';
1
2
  import type { WebpackConfiguration } from 'webpack-dev-server';
2
3
  export declare const outputConfig: WebpackConfiguration['output'];
3
4
  declare const config: WebpackConfiguration;
@@ -1 +1,218 @@
1
- import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./done.js";import p from"./envFlags.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import f from"./module.config.js";import{APPTYPE as d,DEV as g,hasEslintConfig as j,hasStylelintConfig as h,PACKAGENAME as b,PROGRAMPATH as y,FRAMEWORK as w}from"./process-env.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";let C=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],O=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],P=e.readdirSync(y),$=!1,T=!1;for(let e=0,t=P.length;e<t;e++)O.includes(P[e])&&(T=!0),C.includes(P[e])&&($=!0);$||($=j),T||(T=h);let A=T?(await import("stylelint-webpack-plugin")).default:null,B=$?(await import("eslint-webpack-plugin")).default:null,S={"@":v("src")};Object.assign(S,l.alias),"library"===d&&Object.assign(S,{"@":v("site"),"@pkg":v("components"),[b]:v("components")});let M=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===d?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:b,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${b}`,pathinfo:!1,clean:!0,publicPath:a};let F=k(`@moneko/${w}/lib/packages/${i[d]}/index.js`);"single-component"===d&&(Object.assign(S,{[b]:v("umd")}),F=v(g?"example/index.ts":"src/index.ts"),outputConfig.path=v(g?"dist":"umd"),outputConfig.filename="index.js",outputConfig.library=b,outputConfig.libraryTarget="umd",outputConfig.libraryExport="default");let K={main:F};l.entry&&("string"==typeof l.entry?K=l.entry:Object.keys(l.entry)&&Object.assign(K,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let L=l.routeBaseName.split("/").filter(Boolean).length,W=Array(L).fill("..").join("/")+(L?"/":"")+"404.html",{pathSegmentsToKeep:D=L,path:R=W}=l.fixBrowserRouter||{},_={entry:K,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new n.AutomaticPrefetchPlugin,...u,B&&new B({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),A&&new A({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new s(c),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${D||L};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(M),"single-spa"===d&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new n.DefinePlugin(p),new n.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),l.sourceMap&&new n.SourceMapDevToolPlugin(l.sourceMap),new o({name:"编译中",color:"#6f42c1"}),new r({done:()=>{!g&&l.seo&&x(),l.done?.()}}),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:S,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:f,externals:l.externals,output:outputConfig};export default _;
1
+ import fs from 'fs';
2
+ import AddAssetHtmlPlugin from 'add-asset-html-webpack-plugin';
3
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
4
+ import webpack from 'webpack';
5
+ import WebpackBar from 'webpackbar';
6
+ import { CONFIG, ENTRYPATH, PUBLICPATH } from './common.js';
7
+ import DoneWebpackPlugin from './done.js';
8
+ import envFlags from './envFlags.js';
9
+ import AddEntryAttributeWebpackPlugin from './html-add-entry-attr.js';
10
+ import htmlPluginOption from './html-plugin-option.js';
11
+ import { moduleFederation } from './module-federation.js';
12
+ import moduleConfig from './module.config.js';
13
+ import { APPTYPE, DEV, hasEslintConfig, hasStylelintConfig, PACKAGENAME, PROGRAMPATH, FRAMEWORK } from './process-env.js';
14
+ import './routes.js';
15
+ import { seo } from './seo.js';
16
+ import { resolveNodeModulesPath, resolveProgramPath } from './utils.js';
17
+ const eslintrc = [
18
+ '.eslintrc.js',
19
+ '.eslintrc.json',
20
+ '.eslintrc.yaml',
21
+ '.eslintrc.json'
22
+ ];
23
+ const stylelintrc = [
24
+ '.stylelintrc',
25
+ '.stylelintrc.json',
26
+ '.stylelintrc.yaml',
27
+ '.stylelintrc.yml',
28
+ '.stylelintrc.js',
29
+ 'stylelint.config.js',
30
+ 'stylelint.config.cjs'
31
+ ];
32
+ const rootFiles = fs.readdirSync(PROGRAMPATH);
33
+ let hasEslint = false, hasStylelint = false;
34
+ for(let i = 0, len = rootFiles.length; i < len; i++){
35
+ if (stylelintrc.includes(rootFiles[i])) {
36
+ hasStylelint = true;
37
+ }
38
+ if (eslintrc.includes(rootFiles[i])) {
39
+ hasEslint = true;
40
+ }
41
+ }
42
+ if (!hasEslint) {
43
+ hasEslint = hasEslintConfig;
44
+ }
45
+ if (!hasStylelint) {
46
+ hasStylelint = hasStylelintConfig;
47
+ }
48
+ const StylelintPlugin = hasStylelint ? (await import('stylelint-webpack-plugin')).default : null;
49
+ const ESLintPlugin = hasEslint ? (await import('eslint-webpack-plugin')).default : null;
50
+ const alias = {
51
+ '@': resolveProgramPath('src')
52
+ };
53
+ Object.assign(alias, CONFIG.alias);
54
+ if (APPTYPE === 'library') {
55
+ Object.assign(alias, {
56
+ '@': resolveProgramPath('site'),
57
+ '@pkg': resolveProgramPath('components'),
58
+ [PACKAGENAME]: resolveProgramPath('components')
59
+ });
60
+ }
61
+ const assetHtmlOption = CONFIG.assetHtml.map((item)=>{
62
+ return {
63
+ publicPath: '',
64
+ ...item
65
+ };
66
+ });
67
+ export const outputConfig = {
68
+ path: resolveProgramPath(APPTYPE === 'library' ? 'docs' : 'dist'),
69
+ filename: 'js/[name].bundle.js',
70
+ chunkFilename: 'js/[name].chunk.js',
71
+ assetModuleFilename: `assets/[name].[hash][ext]`,
72
+ library: PACKAGENAME,
73
+ libraryTarget: 'window',
74
+ globalObject: 'window',
75
+ chunkLoadingGlobal: `webpackJsonp_${PACKAGENAME}`,
76
+ pathinfo: false,
77
+ clean: true,
78
+ publicPath: PUBLICPATH
79
+ };
80
+ let mainEntry = resolveNodeModulesPath(`@moneko/${FRAMEWORK}/lib/packages/${ENTRYPATH[APPTYPE]}/index.js`);
81
+ if (APPTYPE === 'single-component') {
82
+ Object.assign(alias, {
83
+ [PACKAGENAME]: resolveProgramPath('umd')
84
+ });
85
+ mainEntry = resolveProgramPath(DEV ? 'example/index.ts' : 'src/index.ts');
86
+ outputConfig.path = resolveProgramPath(DEV ? 'dist' : 'umd');
87
+ outputConfig.filename = 'index.js';
88
+ outputConfig.library = PACKAGENAME;
89
+ outputConfig.libraryTarget = 'umd';
90
+ outputConfig.libraryExport = 'default';
91
+ }
92
+ let entryMap = {
93
+ main: mainEntry
94
+ };
95
+ if (CONFIG.entry) {
96
+ if (typeof CONFIG.entry === 'string') {
97
+ entryMap = CONFIG.entry;
98
+ } else if (Object.keys(CONFIG.entry)) {
99
+ Object.assign(entryMap, CONFIG.entry);
100
+ }
101
+ }
102
+ if (CONFIG.output) {
103
+ if (typeof CONFIG.output === 'string') {
104
+ outputConfig.path = CONFIG.output;
105
+ } else if (Object.keys(CONFIG.output)) {
106
+ Object.assign(outputConfig, CONFIG.output);
107
+ }
108
+ }
109
+ const dirDeep = CONFIG.routeBaseName.split('/').filter(Boolean).length;
110
+ const page404 = Array(dirDeep).fill('..').join('/') + (dirDeep ? '/' : '') + '404.html';
111
+ const { pathSegmentsToKeep =dirDeep , path =page404 } = CONFIG.fixBrowserRouter || {};
112
+ const config = {
113
+ entry: entryMap,
114
+ stats: 'errors-only',
115
+ infrastructureLogging: {
116
+ level: 'none'
117
+ },
118
+ target: 'web',
119
+ plugins: [
120
+ new webpack.AutomaticPrefetchPlugin(),
121
+ ...moduleFederation,
122
+ ESLintPlugin && new ESLintPlugin({
123
+ fix: true,
124
+ threads: true,
125
+ extensions: [
126
+ 'js',
127
+ 'md',
128
+ 'mdx',
129
+ 'cjs',
130
+ 'ejs',
131
+ 'mjs',
132
+ 'jsx',
133
+ 'ts',
134
+ 'tsx',
135
+ 'json',
136
+ 'html',
137
+ 'coffee',
138
+ 'vue'
139
+ ]
140
+ }),
141
+ StylelintPlugin && new StylelintPlugin({
142
+ fix: true,
143
+ threads: true,
144
+ extensions: [
145
+ 'css',
146
+ 'scss',
147
+ 'sass',
148
+ 'less',
149
+ 'ts',
150
+ 'tsx',
151
+ 'js',
152
+ 'jsx'
153
+ ],
154
+ exclude: [
155
+ 'node_modules/',
156
+ 'es/',
157
+ 'lib/',
158
+ 'docs/',
159
+ 'coverage/',
160
+ 'dist/'
161
+ ]
162
+ }),
163
+ new HtmlWebpackPlugin(htmlPluginOption),
164
+ CONFIG.fixBrowserRouter && new HtmlWebpackPlugin({
165
+ filename: path,
166
+ inject: false,
167
+ templateContent: ()=>`<html html><head><title>${htmlPluginOption.title}</title><script>var pathSegmentsToKeep = ${pathSegmentsToKeep || dirDeep};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>`
168
+ }),
169
+ new AddAssetHtmlPlugin(assetHtmlOption),
170
+ APPTYPE === 'single-spa' && new AddEntryAttributeWebpackPlugin((src)=>{
171
+ return !!(src.match(/main\.(.*)\.bundle.js$/) || src.match('main.bundle.js'));
172
+ }),
173
+ new webpack.DefinePlugin(envFlags),
174
+ new webpack.WatchIgnorePlugin({
175
+ paths: [
176
+ /\.d\.ts$/
177
+ ]
178
+ }),
179
+ CONFIG.sourceMap && new webpack.SourceMapDevToolPlugin(CONFIG.sourceMap),
180
+ new WebpackBar({
181
+ name: '编译中',
182
+ color: '#6f42c1'
183
+ }),
184
+ new DoneWebpackPlugin({
185
+ done: ()=>{
186
+ if (!DEV && CONFIG.seo) {
187
+ seo();
188
+ }
189
+ CONFIG.done?.();
190
+ }
191
+ }),
192
+ ...CONFIG.plugins
193
+ ].filter(Boolean),
194
+ experiments: {
195
+ topLevelAwait: true,
196
+ syncWebAssembly: true,
197
+ asyncWebAssembly: true
198
+ },
199
+ resolve: {
200
+ extensions: [
201
+ '.tsx',
202
+ '.ts',
203
+ '.js',
204
+ '.jsx'
205
+ ],
206
+ alias: alias,
207
+ fallback: {
208
+ path: false,
209
+ fs: false,
210
+ crypto: false,
211
+ assert: false
212
+ }
213
+ },
214
+ module: moduleConfig,
215
+ externals: CONFIG.externals,
216
+ output: outputConfig
217
+ };
218
+ export default config;
@@ -1,4 +1,98 @@
1
- import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import{getPort as r}from"portfinder";import t from"webpack";import{merge as s}from"webpack-merge";import{CONFIG as p}from"./common.js";import{hasPkg as i}from"./has-pkg.js";import{FRAMEWORK as a}from"./process-env.js";import{getIPAdress as l,isFunction as m,resolveProgramPath as c}from"./utils.js";import n from"./webpack.common.js";let d=i("@moneko/mock"),v=d&&await import("@moneko/mock"),h="react"===a&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,w=!1;p.cacheDirectory&&(w={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:p.cacheDirectory});let f=!1===p.devtool||p.devtool?p.devtool:"eval-cheap-module-source-map",u=new Promise(i=>{r({port:p.devServer.port,stopPort:9999},(r,a)=>{let d=[];p.devServer.port!==a&&d.push(`Port ${o.yellow(p.devServer.port)} is in use, trying ${o.green(a)} instead`),p.devServer.port=a;let u="/"===p.routeBaseName,g=p.devServer.https?"https:":"http:",k=u?"":p.routeBaseName,y=s(n,{devtool:f,mode:"development",cache:w,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:p.devServer.compress,host:"0.0.0.0",port:a,historyApiFallback:u||{index:k,disableDotRule:!0},https:p.devServer.https,proxy:p.proxy,allowedHosts:p.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&m(v)&&v(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new t.HotModuleReplacementPlugin,h&&new h,new e({compilationSuccessInfo:{messages:[`You application is running here:
1
+ import FriendlyErrorsWebpackPlugin from '@soda/friendly-errors-webpack-plugin';
2
+ import chalk from 'chalk';
3
+ import { getPort } from 'portfinder';
4
+ import webpack from 'webpack';
5
+ import { merge } from 'webpack-merge';
6
+ import { CONFIG } from './common.js';
7
+ import { hasPkg } from './has-pkg.js';
8
+ import { FRAMEWORK } from './process-env.js';
9
+ import { getIPAdress, isFunction, resolveProgramPath } from './utils.js';
10
+ import common from './webpack.common.js';
11
+ const hasMockMiddlewares = hasPkg('@moneko/mock');
12
+ const mockMiddlewares = hasMockMiddlewares && await import('@moneko/mock');
13
+ const ReactRefresh = FRAMEWORK === 'react' && (await import('@pmmmwh/react-refresh-webpack-plugin')).default;
14
+ let cacheConfig = false;
15
+ if (CONFIG.cacheDirectory) {
16
+ cacheConfig = {
17
+ type: 'filesystem',
18
+ allowCollectingMemory: true,
19
+ cacheDirectory: CONFIG.cacheDirectory
20
+ };
21
+ }
22
+ const devtool = CONFIG.devtool === false || CONFIG.devtool ? CONFIG.devtool : 'eval-cheap-module-source-map';
23
+ const webpackConfig = new Promise((resolve)=>{
24
+ getPort({
25
+ port: CONFIG.devServer.port,
26
+ stopPort: 9999
27
+ }, (_err, port)=>{
28
+ const notes = [];
29
+ if (CONFIG.devServer.port !== port) {
30
+ notes.push(`Port ${chalk.yellow(CONFIG.devServer.port)} is in use, trying ${chalk.green(port)} instead`);
31
+ }
32
+ CONFIG.devServer.port = port;
33
+ const initRouteBase = CONFIG.routeBaseName === '/';
34
+ const protocol = CONFIG.devServer.https ? 'https:' : 'http:';
35
+ const routeBase = initRouteBase ? '' : CONFIG.routeBaseName;
36
+ const conf = merge(common, {
37
+ devtool: devtool,
38
+ mode: 'development',
39
+ cache: cacheConfig,
40
+ devServer: {
41
+ headers: {
42
+ 'Access-Control-Allow-Origin': '*'
43
+ },
44
+ compress: CONFIG.devServer.compress,
45
+ host: '0.0.0.0',
46
+ port: port,
47
+ historyApiFallback: initRouteBase || {
48
+ index: routeBase,
49
+ disableDotRule: true
50
+ },
51
+ https: CONFIG.devServer.https,
52
+ proxy: CONFIG.proxy,
53
+ allowedHosts: CONFIG.devServer.allowedHosts,
54
+ client: {
55
+ progress: false,
56
+ logging: 'info',
57
+ overlay: false
58
+ },
59
+ static: {
60
+ watch: {
61
+ ignored: (f)=>{
62
+ return f.endsWith('.d.ts') || /\/node_modules\//.test(f);
63
+ }
64
+ }
65
+ },
66
+ setupMiddlewares: (middlewares, devServer)=>{
67
+ if (!devServer) {
68
+ throw new Error('webpack-dev-server is not defined');
69
+ }
70
+ if (devServer.app && isFunction(mockMiddlewares)) {
71
+ mockMiddlewares(devServer.app, resolveProgramPath('mock/'));
72
+ }
73
+ return middlewares;
74
+ },
75
+ open: false,
76
+ hot: true
77
+ },
78
+ plugins: [
79
+ new webpack.HotModuleReplacementPlugin(),
80
+ ReactRefresh && new ReactRefresh(),
81
+ new FriendlyErrorsWebpackPlugin({
82
+ compilationSuccessInfo: {
83
+ messages: [
84
+ `You application is running here:
2
85
 
3
- local: ${o.cyan(`${g}//${p.devServer.host}:${a}${k}`)}
4
- network: ${o.cyan(`${g}//${l()}:${a}${k}`)}`],notes:d},clearConsole:!0})].filter(Boolean)});i(y)})});export default u;
86
+ local: ${chalk.cyan(`${protocol}//${CONFIG.devServer.host}:${port}${routeBase}`)}
87
+ network: ${chalk.cyan(`${protocol}//${getIPAdress()}:${port}${routeBase}`)}`
88
+ ],
89
+ notes: notes
90
+ },
91
+ clearConsole: true
92
+ })
93
+ ].filter(Boolean)
94
+ });
95
+ resolve(conf);
96
+ });
97
+ });
98
+ export default webpackConfig;
@@ -1 +1,64 @@
1
- import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{CONFIG as s}from"./common.js";import{getMinifyOption as t}from"./minify.js";import c from"./webpack.common.js";let{cssnanoMinify:l,swcMinify:p}=e,a="swc"===s.compiler?"swc":"terser",u="swc"===s.compiler?"swc":"cssnano",f=[];s.minifier&&(s.minifier.js&&f.push(new n(t(s.minifier.js?.type||a,s.minifier.js?.options))),s.minifier.css&&f.push(new e({minify:{swc:p,cssnano:l}[s.minifier.css?.type||u],minimizerOptions:s.minifier.css?.options})));let d={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:f},h=!1;s.cacheDirectory&&(h={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory});export default r(c,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:h,optimization:d,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new m.optimize.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
1
+ import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
2
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
3
+ import TerserPlugin from 'terser-webpack-plugin';
4
+ import webpack from 'webpack';
5
+ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
6
+ import { merge } from 'webpack-merge';
7
+ import { CONFIG } from './common.js';
8
+ import { getMinifyOption } from './minify.js';
9
+ import common from './webpack.common.js';
10
+ const { cssnanoMinify , swcMinify } = CssMinimizerPlugin;
11
+ const defaultJsMiniify = CONFIG.compiler === 'swc' ? 'swc' : 'terser';
12
+ const defaultCssMiniify = CONFIG.compiler === 'swc' ? 'swc' : 'cssnano';
13
+ const cssMinify = {
14
+ swc: swcMinify,
15
+ cssnano: cssnanoMinify
16
+ };
17
+ const minimizer = [];
18
+ if (CONFIG.minifier) {
19
+ if (CONFIG.minifier.js) {
20
+ minimizer.push(new TerserPlugin(getMinifyOption(CONFIG.minifier.js?.type || defaultJsMiniify, CONFIG.minifier.js?.options)));
21
+ }
22
+ if (CONFIG.minifier.css) {
23
+ minimizer.push(new CssMinimizerPlugin({
24
+ minify: cssMinify[CONFIG.minifier.css?.type || defaultCssMiniify],
25
+ minimizerOptions: CONFIG.minifier.css?.options
26
+ }));
27
+ }
28
+ }
29
+ const optimization = {
30
+ splitChunks: CONFIG.splitChunk,
31
+ runtimeChunk: CONFIG.runtimeChunk,
32
+ chunkIds: 'named',
33
+ moduleIds: 'named',
34
+ removeAvailableModules: true,
35
+ removeEmptyChunks: true,
36
+ mergeDuplicateChunks: true,
37
+ minimize: true,
38
+ minimizer: minimizer
39
+ };
40
+ let cacheConfig = false;
41
+ if (CONFIG.cacheDirectory) {
42
+ cacheConfig = {
43
+ type: 'filesystem',
44
+ allowCollectingMemory: true,
45
+ cacheDirectory: CONFIG.cacheDirectory
46
+ };
47
+ }
48
+ export default merge(common, {
49
+ devtool: CONFIG.devtool === false || CONFIG.devtool ? CONFIG.devtool : 'cheap-module-source-map',
50
+ mode: 'production',
51
+ cache: cacheConfig,
52
+ optimization: optimization,
53
+ plugins: [
54
+ new MiniCssExtractPlugin({
55
+ filename: 'style/[name].bundle.css',
56
+ chunkFilename: 'style/[name].chunk.css',
57
+ experimentalUseImportModule: true
58
+ }),
59
+ CONFIG.bundleAnalyzer && new BundleAnalyzerPlugin(CONFIG.bundleAnalyzer),
60
+ CONFIG.splitChunk && new webpack.optimize.MinChunkSizePlugin({
61
+ minChunkSize: 10000
62
+ })
63
+ ].filter(Boolean)
64
+ });
package/lib/yarn-argv.js CHANGED
@@ -1 +1,9 @@
1
- let e=JSON.parse(process.env.npm_config_argv||"{}")?.original,a={};e?.forEach(e=>{let r=e.split("=");Object.assign(a,{[r[0]]:r[1]||!0})});export default a;
1
+ const original = JSON.parse(process.env.npm_config_argv || '{}')?.original;
2
+ const yarnArgv = {};
3
+ original?.forEach((o)=>{
4
+ const m = o.split('=');
5
+ Object.assign(yarnArgv, {
6
+ [m[0]]: m[1] || true
7
+ });
8
+ });
9
+ export default yarnArgv;
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.30",
3
+ "version": "3.0.0-beta.32",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "build": "swc src -d lib -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
8
+ "build": "swc src -d lib -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=false -C jsc.minify.compress=false -C minify=false -D",
9
9
  "prebuild": "rm -rf ./lib && tsc"
10
10
  },
11
11
  "keywords": [],
12
12
  "author": "moneko",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@emotion/css": "11.11.0",
16
15
  "@mdx-js/loader": "2.3.0",
17
16
  "@soda/friendly-errors-webpack-plugin": "1.8.1",
18
17
  "@swc/core": "1.3.56",
@@ -51,6 +50,7 @@
51
50
  "@moneko/mock": "^1.0.9",
52
51
  "@moneko/postcss": "^1.0.30",
53
52
  "@swc/cli": "0.1.62",
53
+ "@types/js-yaml": "^4.0.5",
54
54
  "@types/mini-css-extract-plugin": "^2.5.1",
55
55
  "@types/shelljs": "^0.8.12",
56
56
  "@types/webpack-bundle-analyzer": "^4.6.0",