@moneko/core 3.0.0-beta.45 → 3.0.0-beta.47

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