@moneko/core 3.0.0-beta.105 → 3.0.0-beta.106

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.
@@ -1 +1,70 @@
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{CUSTOMCONFIG as c}from"./process-env.js";import l from"./webpack.common.js";let{optimize:p}=m,{cssnanoMinify:a,swcMinify:u}=e,f="swc"===s.compiler?"swc":"terser",d="swc"===s.compiler?"swc":"cssnano",h=[];s.minifier&&(s.minifier.js&&h.push(new n(t(s.minifier.js?.type||f,s.minifier.js?.options))),s.minifier.css&&h.push(new e({minify:{swc:u,cssnano:a}[s.minifier.css?.type||d],minimizerOptions:s.minifier.css?.options})));let k={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:h},w=!1;s.cacheDirectory&&(w={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});export default r(l,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:w,optimization:k,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new p.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 { CUSTOMCONFIG } from './process-env.js';
10
+ import { clientConfig } from './webpack.common.js';
11
+ const { optimize } = webpack;
12
+ const { cssnanoMinify , swcMinify } = CssMinimizerPlugin;
13
+ const defaultJsMiniify = CONFIG.compiler === 'swc' ? 'swc' : 'terser';
14
+ const defaultCssMiniify = CONFIG.compiler === 'swc' ? 'swc' : 'cssnano';
15
+ const cssMinify = {
16
+ swc: swcMinify,
17
+ cssnano: cssnanoMinify
18
+ };
19
+ const minimizer = [];
20
+ if (CONFIG.minifier) {
21
+ if (CONFIG.minifier.js) {
22
+ minimizer.push(new TerserPlugin(getMinifyOption(CONFIG.minifier.js?.type || defaultJsMiniify, CONFIG.minifier.js?.options)));
23
+ }
24
+ if (CONFIG.minifier.css) {
25
+ minimizer.push(new CssMinimizerPlugin({
26
+ minify: cssMinify[CONFIG.minifier.css?.type || defaultCssMiniify],
27
+ minimizerOptions: CONFIG.minifier.css?.options
28
+ }));
29
+ }
30
+ }
31
+ const optimization = {
32
+ splitChunks: CONFIG.splitChunk,
33
+ runtimeChunk: CONFIG.runtimeChunk,
34
+ chunkIds: 'named',
35
+ moduleIds: 'named',
36
+ removeAvailableModules: true,
37
+ removeEmptyChunks: true,
38
+ mergeDuplicateChunks: true,
39
+ minimize: true,
40
+ minimizer: minimizer
41
+ };
42
+ let cacheConfig = false;
43
+ if (CONFIG.cacheDirectory) {
44
+ cacheConfig = {
45
+ type: 'filesystem',
46
+ allowCollectingMemory: true,
47
+ cacheDirectory: CONFIG.cacheDirectory,
48
+ name: `${CUSTOMCONFIG || 'default'}-production`
49
+ };
50
+ }
51
+ const client = merge(clientConfig, {
52
+ devtool: CONFIG.devtool === false || CONFIG.devtool ? CONFIG.devtool : 'cheap-module-source-map',
53
+ mode: 'production',
54
+ cache: cacheConfig,
55
+ optimization: optimization,
56
+ plugins: [
57
+ new MiniCssExtractPlugin({
58
+ filename: 'style/[name].bundle.css',
59
+ chunkFilename: 'style/[name].chunk.css',
60
+ experimentalUseImportModule: true
61
+ }),
62
+ CONFIG.bundleAnalyzer && new BundleAnalyzerPlugin(CONFIG.bundleAnalyzer),
63
+ CONFIG.splitChunk && new optimize.MinChunkSizePlugin({
64
+ minChunkSize: 10000
65
+ })
66
+ ].filter(Boolean)
67
+ });
68
+ export default [
69
+ client
70
+ ];
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,11 +1,11 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.105",
3
+ "version": "3.0.0-beta.106",
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=false -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": [],
@@ -41,7 +41,7 @@
41
41
  "webpack": "5.77.0",
42
42
  "webpack-bundle-analyzer": "4.9.0",
43
43
  "webpack-cli": "5.1.4",
44
- "webpack-dev-server": "4.15.0",
44
+ "webpack-dev-server": "4.15.1",
45
45
  "webpack-merge": "5.9.0",
46
46
  "webpack-virtual-modules": "0.5.0",
47
47
  "webpackbar": "5.0.2",
@@ -6,7 +6,7 @@ import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
6
6
  import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
7
7
  import type { MinifyOptions } from 'terser';
8
8
  import type { Options } from 'ts-import-plugin';
9
- import type { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
9
+ import type { Configuration, ExternalsPresets, RuleSetRule, WebpackPluginInstance } from 'webpack';
10
10
  import type {
11
11
  ProxyArray,
12
12
  ProxyConfigArray,
@@ -294,6 +294,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
294
294
  * @default true
295
295
  */
296
296
  normalizeCss?: boolean;
297
+ externalsPresets?: ExternalsPresets;
297
298
  };
298
299
  export declare interface ModuleFederationOption {
299
300
  /** 模块名称,唯一性,不能重名 */