@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.
package/lib/common.js CHANGED
@@ -1,206 +1,4 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import readline from 'readline';
4
- import chalk from 'chalk';
5
- import { merge } from 'webpack-merge';
6
- import { APPTYPE, CUSTOMCONFIG, FRAMEWORK, jsxImportSource, pkgName, PROGRAMPATH } from './process-env.js';
7
- import { isFunction, readConf } from './utils.js';
8
- export const ENTRYPATH = {
9
- mobile: 'mobile',
10
- site: 'site',
11
- 'back-stage': 'back-stage',
12
- 'single-spa': 'single-spa',
13
- library: 'library',
14
- 'single-component': 'single-component'
15
- };
16
- const includeModule = [
17
- `@moneko/${FRAMEWORK}`,
18
- 'neko-ui',
19
- 'antd',
20
- '@antv',
21
- 'katex',
22
- 'font-pingfang-sc',
23
- 'font-pingfang-tc',
24
- 'react-photo-view',
25
- 'react-markdown-editor-lite',
26
- 'schema-design'
27
- ];
28
- let defaultSplitChunk = {
29
- chunks: 'all',
30
- minSize: 1024,
31
- minChunks: 1,
32
- cacheGroups: {
33
- route: {
34
- test: /[\\/].git[\\/]router/,
35
- priority: -10,
36
- reuseExistingChunk: true,
37
- name: 'route'
38
- },
39
- example: {
40
- test: /[\\/].git[\\/]example/,
41
- priority: -10,
42
- reuseExistingChunk: true,
43
- name: 'example'
44
- }
45
- }
46
- };
47
- if (APPTYPE === 'single-component') {
48
- defaultSplitChunk = false;
49
- }
50
- const defaultConfig = {
51
- seo: false,
52
- mode: 'csr',
53
- compiler: 'swc',
54
- bundleAnalyzer: {
55
- analyzerMode: 'static',
56
- reportFilename: 'report.html',
57
- openAnalyzer: false
58
- },
59
- entry: {},
60
- minifier: {
61
- js: {},
62
- css: {}
63
- },
64
- sourceMap: {
65
- filename: '[file].map',
66
- publicPath: ''
67
- },
68
- env: {},
69
- routeBaseName: '/',
70
- publicPath: '/',
71
- designSize: APPTYPE === 'mobile' ? 375 : 1680,
72
- fallbackCompPath: null,
73
- modifyVars: {},
74
- prefixCls: 'n',
75
- alias: {},
76
- layoutSider: {},
77
- moduleRules: [],
78
- prefixJsLoader: [],
79
- cssModules: [],
80
- importOnDemand: {},
81
- proxy: [],
82
- cacheDirectory: PROGRAMPATH + '/node_modules/.temp_cache',
83
- devServer: {
84
- allowedHosts: [
85
- '.baidu.com'
86
- ],
87
- host: 'localhost',
88
- port: 3000,
89
- https: false,
90
- compress: false
91
- },
92
- htmlPluginOption: {
93
- template: `./node_modules/${pkgName}/template/index.html`,
94
- favicon: `./node_modules/${pkgName}/template/favicon.ico`,
95
- tags: []
96
- },
97
- assetHtml: [],
98
- routerMode: 'browser',
99
- fixBrowserRouter: false,
100
- plugins: [],
101
- splitChunk: defaultSplitChunk,
102
- runtimeChunk: APPTYPE === 'single-component' ? false : 'single',
103
- moduleFederation: [],
104
- rulesInclude: {
105
- less: includeModule,
106
- css: includeModule,
107
- js: includeModule,
108
- media: includeModule,
109
- fonts: includeModule
110
- },
111
- mdx: {
112
- jsxImportSource: jsxImportSource,
113
- remarkPlugins: [],
114
- rehypePlugins: []
115
- },
116
- jsxDomExpressions: {
117
- moduleName: 'solid-js/web',
118
- builtIns: [
119
- 'For',
120
- 'Show',
121
- 'Switch',
122
- 'Match',
123
- 'Suspense',
124
- 'SuspenseList',
125
- 'Portal',
126
- 'Index',
127
- 'Dynamic',
128
- 'ErrorBoundary'
129
- ],
130
- contextToCustomElements: true,
131
- wrapConditionals: true,
132
- generate: 'dom',
133
- hydratable: false
134
- },
135
- bar: {
136
- name: '编译中',
137
- color: '#6f42c1'
138
- }
139
- };
140
- export const log = (msg)=>{
141
- readline.cursorTo(process.stdout, 0);
142
- process.stdout.write(msg);
143
- };
144
- let customConf = defaultConfig;
145
- let configPath = null;
146
- let normalConf = {};
147
- let envConf = {};
148
- try {
149
- configPath = path.join(PROGRAMPATH, './config/index.ts');
150
- fs.accessSync(configPath, fs.constants.R_OK);
151
- } catch (error) {
152
- configPath = null;
153
- }
154
- if (configPath) {
155
- try {
156
- const conf = (await readConf(configPath, 'index')).default;
157
- normalConf = isFunction(conf) ? conf(process) : conf;
158
- } catch (error) {
159
- process.stdout.write(chalk.red(error));
160
- }
161
- }
162
- if (CUSTOMCONFIG) {
163
- let customConfigPath = null;
164
- try {
165
- customConfigPath = path.join(PROGRAMPATH, `./config/${CUSTOMCONFIG}.ts`);
166
- fs.accessSync(customConfigPath, fs.constants.R_OK);
167
- } catch (error) {
168
- customConfigPath = null;
169
- }
170
- if (customConfigPath !== null) {
171
- try {
172
- const conf = (await readConf(customConfigPath, CUSTOMCONFIG)).default;
173
- envConf = isFunction(conf) ? conf(process) : conf;
174
- } catch (error) {
175
- process.stdout.write(chalk.red(error));
176
- }
177
- }
178
- }
179
- customConf = merge(customConf, normalConf, envConf);
180
- if (customConf.compiler === 'tsc' && customConf.minifier) {
181
- if (!customConf.minifier.js) {
182
- Object.assign(customConf.minifier, {
183
- js: {
184
- type: 'terser'
185
- }
186
- });
187
- }
188
- if (!customConf.minifier.css) {
189
- Object.assign(customConf.minifier, {
190
- css: {
191
- type: 'cssnano'
192
- }
193
- });
194
- }
195
- }
196
- if (customConf.devtool === false) customConf.sourceMap = false;
197
- if (customConf.sourceMap === false) customConf.devtool = false;
198
- if (customConf.fixBrowserRouter && customConf.htmlPluginOption) {
199
- if (!customConf.htmlPluginOption.tags) {
200
- customConf.htmlPluginOption.tags = [];
201
- }
202
- customConf.htmlPluginOption.tags.push({
203
- textContent: `
1
+ import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as r,FRAMEWORK as l,jsxImportSource as a,pkgName as c,PROGRAMPATH as m}from"./process-env.js";import{isFunction as p,readConf as u}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let d=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"],h={chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}};"single-component"===n&&(h=!1);let g={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",designSize:"mobile"===n?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:m+"/node_modules/.temp_cache",devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${c}/template/index.html`,favicon:`./node_modules/${c}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:h,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:d,css:d,js:d,media:d,fonts:d},mdx:{jsxImportSource:a,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=g,x=null,y={},b={};try{x=t.join(m,"./config/index.ts"),e.accessSync(x,e.constants.R_OK)}catch(e){x=null}if(x)try{let e=(await u(x,"index")).default;y=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(r){let o=null;try{o=t.join(m,`./config/${r}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await u(o,r)).default;b=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(f=i(f,y,b)).compiler&&f.minifier&&(f.minifier.js||Object.assign(f.minifier,{js:{type:"terser"}}),f.minifier.css||Object.assign(f.minifier,{css:{type:"cssnano"}})),!1===f.devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&f.htmlPluginOption&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
204
2
  (function(l) {
205
3
  if (l.search[1] === '/' ) {
206
4
  var decoded = l.search.slice(1).split('&').map(function(s) {
@@ -211,12 +9,4 @@ if (customConf.fixBrowserRouter && customConf.htmlPluginOption) {
211
9
  );
212
10
  }
213
11
  }(window.location))
214
- `
215
- });
216
- }
217
- export const CONFIG = customConf;
218
- export const PUBLICPATH = CONFIG.publicPath || '/';
219
- global.NEKOCLICONFIG = {
220
- CONFIG,
221
- log
222
- };
12
+ `}));export const CONFIG=f;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,log};
package/lib/coverage.js CHANGED
@@ -1,30 +1 @@
1
- import { readFileSync, accessSync, constants } from 'fs';
2
- import { join } from 'path';
3
- import { Parser } from 'xml2js';
4
- import { PACKAGENAME, PROGRAMPATH } from './process-env.js';
5
- export const coverage = {};
6
- try {
7
- const coveragePath = join(PROGRAMPATH, './coverage/clover.xml');
8
- accessSync(coveragePath, constants.R_OK);
9
- const parser = new Parser({
10
- explicitArray: false,
11
- async: false
12
- });
13
- const cover = readFileSync(coveragePath, {
14
- encoding: 'utf-8'
15
- });
16
- parser.parseString(cover, (error, result)=>{
17
- if (!error) {
18
- const projectMetrics = result.coverage.project.metrics.$;
19
- const components = result.coverage.project.package;
20
- Object.assign(coverage, {
21
- [PACKAGENAME]: projectMetrics
22
- });
23
- components.forEach((pkg)=>{
24
- Object.assign(coverage, {
25
- [pkg.$.name]: pkg.metrics.$
26
- });
27
- });
28
- }
29
- });
30
- } catch (error) {}
1
+ import{readFileSync as e,accessSync as r,constants as c}from"fs";import{join as o}from"path";import{Parser as t}from"xml2js";import{PACKAGENAME as a,PROGRAMPATH as s}from"./process-env.js";export const coverage={};try{let i=o(s,"./coverage/clover.xml");r(i,c.R_OK);let m=new t({explicitArray:!1,async:!1}),p=e(i,{encoding:"utf-8"});m.parseString(p,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){}
package/lib/done.js CHANGED
@@ -1,13 +1 @@
1
- class DoneWebpackPlugin {
2
- options;
3
- constructor(options){
4
- this.options = Object.assign({}, options);
5
- }
6
- apply(compiler) {
7
- const that = this;
8
- compiler.hooks.done.tap('DoneWebpackPlugin', function() {
9
- that.options.done?.();
10
- });
11
- }
12
- }
13
- export default DoneWebpackPlugin;
1
+ export default class{constructor(o){this.options=Object.assign({},o)}apply(o){let t=this;o.hooks.done.tap("DoneWebpackPlugin",function(){t.options.done?.()})}};
package/lib/envFlags.js CHANGED
@@ -1,48 +1 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { CONFIG } from './common.js';
4
- import { coverage } from './coverage.js';
5
- import htmlPluginOption from './html-plugin-option.js';
6
- import { APPTYPE, NODE_ENV, PACKAGENAME, programInfo, PROGRAMPATH, hasAntd } from './process-env.js';
7
- import { toUpperCaseString } from './utils.js';
8
- const ReactDOMPath = 'react-dom/client';
9
- const entryName = APPTYPE === 'library' ? 'site' : 'src';
10
- let APPENTRY = false;
11
- try {
12
- const appEntryPath = path.join(PROGRAMPATH, './src/index.ts');
13
- fs.accessSync(appEntryPath, fs.constants.R_OK);
14
- APPENTRY = appEntryPath;
15
- } catch (error) {
16
- APPENTRY = false;
17
- }
18
- const envFlags = {
19
- projectName: JSON.stringify(toUpperCaseString(PACKAGENAME)),
20
- projectCoverage: JSON.stringify(coverage),
21
- providerConfig: JSON.stringify({
22
- prefixCls: CONFIG.prefixCls,
23
- iconPrefixCls: CONFIG.prefixCls + '-icon',
24
- theme: CONFIG.theme
25
- }),
26
- fallbackCompPath: JSON.stringify(CONFIG.fallbackCompPath),
27
- ReactDOMPath: JSON.stringify(ReactDOMPath),
28
- favicon: JSON.stringify(htmlPluginOption.favicon),
29
- hasLocales: JSON.stringify(fs.existsSync(path.join(PROGRAMPATH, `./${entryName}/locales`))),
30
- hasPersist: JSON.stringify(fs.existsSync(path.join(PROGRAMPATH, `./${entryName}/persist.ts`))),
31
- layoutSider: JSON.stringify(CONFIG.layoutSider),
32
- hasAntd: JSON.stringify(hasAntd),
33
- APPTYPE: JSON.stringify(APPTYPE),
34
- APPENTRY: JSON.stringify(APPENTRY),
35
- programInfo: JSON.stringify({
36
- ...programInfo,
37
- routeBaseName: CONFIG.routeBaseName,
38
- designSize: CONFIG.designSize,
39
- routerMode: CONFIG.routerMode,
40
- renderMode: CONFIG.mode
41
- }),
42
- 'process.env': JSON.stringify({
43
- NODE_ENV: NODE_ENV,
44
- iconfont: CONFIG.iconfont,
45
- ...CONFIG.env
46
- })
47
- };
48
- export default envFlags;
1
+ import i from"fs";import r from"path";import{CONFIG as t}from"./common.js";import{coverage as e}from"./coverage.js";import o from"./html-plugin-option.js";import{APPTYPE as s,NODE_ENV as n,PACKAGENAME as f,programInfo as a,PROGRAMPATH as c,hasAntd as m}from"./process-env.js";import{toUpperCaseString as p}from"./utils.js";let l="library"===s?"site":"src",g=!1;try{let t=r.join(c,"./src/index.ts");i.accessSync(t,i.constants.R_OK),g=t}catch(i){g=!1}let y={projectName:JSON.stringify(p(f)),projectCoverage:JSON.stringify(e),providerConfig:JSON.stringify({prefixCls:t.prefixCls,iconPrefixCls:t.prefixCls+"-icon",theme:t.theme}),fallbackCompPath:JSON.stringify(t.fallbackCompPath),ReactDOMPath:JSON.stringify("react-dom/client"),favicon:JSON.stringify(o.favicon),hasLocales:JSON.stringify(i.existsSync(r.join(c,`./${l}/locales`))),hasPersist:JSON.stringify(i.existsSync(r.join(c,`./${l}/persist.ts`))),layoutSider:JSON.stringify(t.layoutSider),hasAntd:JSON.stringify(m),APPTYPE:JSON.stringify(s),APPENTRY:JSON.stringify(g),programInfo:JSON.stringify({...a,routeBaseName:t.routeBaseName,designSize:t.designSize,routerMode:t.routerMode,renderMode:t.mode}),"process.env":JSON.stringify({NODE_ENV:n,iconfont:t.iconfont,...t.env})};export default y;
package/lib/esm.js CHANGED
@@ -1,7 +1 @@
1
- export default function esm(templateStrings, ...substitutions) {
2
- let js = templateStrings.raw[0];
3
- for(let i = 0; i < substitutions.length; i++){
4
- js += substitutions[i] + templateStrings.raw[i + 1];
5
- }
6
- return `data:text/javascript;base64,${Buffer.from(js).toString('base64')}`;
7
- }
1
+ export default function t(t,...e){let r=t.raw[0];for(let a=0;a<e.length;a++)r+=e[a]+t.raw[a+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}
package/lib/has-pkg.js CHANGED
@@ -1,14 +1 @@
1
- import { accessSync, constants } from 'fs';
2
- import path from 'path';
3
- import { PROGRAMPATH } from './process-env.js';
4
- export function hasPkg(name) {
5
- let flag = false;
6
- try {
7
- const antdPath = path.join(PROGRAMPATH, `./node_modules/${name}/package.json`);
8
- accessSync(antdPath, constants.R_OK);
9
- flag = true;
10
- } catch (error) {
11
- flag = false;
12
- }
13
- return flag;
14
- }
1
+ import{accessSync as o,constants as r}from"fs";import t from"path";import{PROGRAMPATH as e}from"./process-env.js";export function hasPkg(m){let n=!1;try{let p=t.join(e,`./node_modules/${m}/package.json`);o(p,r.R_OK),n=!0}catch(o){n=!1}return n}
@@ -1,23 +1 @@
1
- class AddEntryAttributeWebpackPlugin {
2
- entryMatchCallback;
3
- constructor(matchCallback){
4
- this.entryMatchCallback = matchCallback;
5
- }
6
- apply(compiler) {
7
- compiler.hooks.compilation.tap('AddEntryAttributeWebpackPlugin', (compilation)=>{
8
- const HtmlWebpackPluginInstance = compiler.options.plugins.map(({ constructor })=>constructor).find((constructor)=>constructor && constructor.name === 'HtmlWebpackPlugin');
9
- if (HtmlWebpackPluginInstance) {
10
- const hooks = HtmlWebpackPluginInstance.getHooks(compilation);
11
- hooks.alterAssetTagGroups.tap('AddEntryAttributeWebpackPlugin', (data)=>{
12
- data.headTags.forEach((tag)=>{
13
- if (tag.tagName === 'script' && typeof tag.attributes?.src === 'string' && this.entryMatchCallback(tag.attributes.src)) {
14
- tag.attributes.entry = true;
15
- }
16
- });
17
- return data;
18
- });
19
- }
20
- });
21
- }
22
- }
23
- export default AddEntryAttributeWebpackPlugin;
1
+ export default class{constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);if(e){let t=e.getHooks(a);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&"string"==typeof t.attributes?.src&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}};
@@ -1,44 +1 @@
1
- import path from 'path';
2
- import { merge } from 'webpack-merge';
3
- import { CONFIG } from './common.js';
4
- import { PROGRAMPATH, PACKAGENAME, programInfo, pkgName } from './process-env.js';
5
- const { template , favicon , ...option } = CONFIG.htmlPluginOption || {
6
- template: `./node_modules/${pkgName}/template/index.html`,
7
- favicon: `./node_modules/${pkgName}/template/favicon.ico`
8
- };
9
- const htmlPluginOption = merge({
10
- title: CONFIG.env?.PROJECTNAME || PACKAGENAME.toLocaleUpperCase() || 'Title',
11
- filename: 'index.html',
12
- hash: false,
13
- minify: {
14
- collapseWhitespace: true,
15
- removeComments: true,
16
- removeRedundantAttributes: false,
17
- removeScriptTypeAttributes: false,
18
- removeStyleLinkTypeAttributes: false,
19
- removeAttributeQuotes: true,
20
- useShortDoctype: true
21
- },
22
- meta: {
23
- charset: 'UTF-8',
24
- 'X-UA-Compatible': {
25
- 'http-equiv': 'X-UA-Compatible',
26
- content: 'IE=edge,Chrome=1'
27
- },
28
- HandheldFriendly: 'true',
29
- MobileOptimized: '320',
30
- 'screen-orientation': 'portrait',
31
- 'x5-orientation': 'portrait',
32
- browsermode: 'application',
33
- 'x5-page-mode': 'app',
34
- 'msapplication-tap-highlight': 'no',
35
- viewport: 'width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no',
36
- 'apple-mobile-web-app-capable': 'yes',
37
- renderer: 'webkit',
38
- description: programInfo.description || ''
39
- },
40
- tags: [],
41
- template: path.join(PROGRAMPATH, template),
42
- favicon: path.join(PROGRAMPATH, favicon)
43
- }, option);
44
- export default htmlPluginOption;
1
+ import e from"path";import{merge as t}from"webpack-merge";import{CONFIG as i}from"./common.js";import{PROGRAMPATH as o,PACKAGENAME as a,programInfo as m,pkgName as p}from"./process-env.js";let{template:r,favicon:n,...l}=i.htmlPluginOption||{template:`./node_modules/${p}/template/index.html`,favicon:`./node_modules/${p}/template/favicon.ico`},s=t({title:i.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:m.description||""},tags:[],template:e.join(o,r),favicon:e.join(o,n)},l);export default s;
package/lib/index.js CHANGED
@@ -1,4 +1 @@
1
- export * from './process-env.js';
2
- export * from './utils.js';
3
- export * from '../typings/global.js';
4
- export { default as envFlags } from './envFlags.js';
1
+ export*from"./process-env.js";export*from"./utils.js";export*from"../typings/global.js";export{default as envFlags}from"./envFlags.js";
package/lib/minify.js CHANGED
@@ -1,46 +1 @@
1
- import TerserPlugin from 'terser-webpack-plugin';
2
- import { merge } from 'webpack-merge';
3
- import { swcMinifyOption } from './swcrc.js';
4
- export const minify = {
5
- terser: {
6
- minify: TerserPlugin.terserMinify,
7
- terserOptions: {
8
- ecma: 2015,
9
- parse: {},
10
- compress: {
11
- global_defs: {
12
- '@alert': 'console.log'
13
- },
14
- drop_console: true,
15
- drop_debugger: true,
16
- pure_funcs: [
17
- 'console.log',
18
- 'console.warn',
19
- 'console.error',
20
- 'console.info'
21
- ]
22
- },
23
- toplevel: false,
24
- mangle: true,
25
- module: false,
26
- format: {
27
- comments: false
28
- },
29
- ie8: false,
30
- keep_classnames: undefined,
31
- keep_fnames: false,
32
- safari10: false
33
- },
34
- extractComments: false
35
- },
36
- swc: {
37
- minify: TerserPlugin.swcMinify,
38
- terserOptions: swcMinifyOption
39
- }
40
- };
41
- export const getMinifyOption = (type, options = {})=>{
42
- const min = minify[type];
43
- return Object.assign(min, {
44
- terserOptions: merge(min.terserOptions, options)
45
- });
46
- };
1
+ import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.js";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e,r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
package/lib/modifyVars.js CHANGED
@@ -1,11 +1 @@
1
- import { CONFIG } from './common.js';
2
- import htmlPluginOption from './html-plugin-option.js';
3
- const prefixCls = CONFIG.prefixCls || 'n';
4
- const modifyVars = {};
5
- Object.assign(modifyVars, {
6
- '@prefix-cls': prefixCls,
7
- '@ant-prefix': prefixCls,
8
- '@iconfont-css-prefix': prefixCls + '-icon',
9
- '@favicon': JSON.stringify(htmlPluginOption.favicon)
10
- }, CONFIG.modifyVars || {});
11
- export default modifyVars;
1
+ import{CONFIG as i}from"./common.js";import o from"./html-plugin-option.js";let f=i.prefixCls||"n",n={};Object.assign(n,{"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":f+"-icon","@favicon":JSON.stringify(o.favicon)},i.modifyVars||{});export default n;
@@ -1,46 +1 @@
1
- import ExternalTemplateRemotesPlugin from 'external-remotes-plugin';
2
- import webpack from 'webpack';
3
- import ModuleFederationPlugin from 'webpack/lib/container/ModuleFederationPlugin.js';
4
- import { CONFIG } from './common.js';
5
- import { resolve } from './utils.js';
6
- const NormalModuleReplacementPlugin = webpack.NormalModuleReplacementPlugin;
7
- const aliasLibrary = {};
8
- const exposesMap = {};
9
- const remoteMap = {};
10
- export const moduleFederation = CONFIG.moduleFederation?.map((opt)=>{
11
- if (Array.isArray(opt.remotes)) {
12
- for(let r = 0, rlen = opt.remotes.length; r < rlen; r++){
13
- const m = opt.remotes[r];
14
- const aliasName = m.alias || m.name;
15
- const filename = m.filename || 'remote_entry.js';
16
- remoteMap[aliasName] = `${m.name}@${m.host}/${filename}`;
17
- if (Array.isArray(m.library)) {
18
- for(let i = 0, len = m.library.length; i < len; i++){
19
- aliasLibrary[m.library[i]] = `${aliasName}/${m.library[i]}`;
20
- }
21
- }
22
- }
23
- }
24
- if (Array.isArray(opt.exposes)) {
25
- for(let i = 0, len = opt.exposes.length; i < len; i++){
26
- const m = opt.exposes[i];
27
- if (typeof m === 'string') {
28
- exposesMap[`./${m}`] = resolve(m);
29
- } else if (Object.prototype.toString.call(m) === '[object Object]') {
30
- exposesMap[`./${m.name}`] = resolve(m.path);
31
- }
32
- }
33
- }
34
- return new ModuleFederationPlugin({
35
- filename: 'remote_entry.js',
36
- ...opt,
37
- remotes: remoteMap,
38
- exposes: exposesMap
39
- });
40
- });
41
- if (moduleFederation.length) {
42
- moduleFederation.push(new ExternalTemplateRemotesPlugin());
43
- moduleFederation.push(new NormalModuleReplacementPlugin(/(.*)/, (resource)=>{
44
- if (aliasLibrary[resource.request]) resource.request = aliasLibrary[resource.request];
45
- }));
46
- }
1
+ import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as l}from"./utils.js";let a=r.NormalModuleReplacementPlugin,i={},m={},n={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?m[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(m[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:n,exposes:m})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new a(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));