agent-hel-react-comps 2.4.0
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/README.md +68 -0
- package/hel_dist/asset-manifest.json +19 -0
- package/hel_dist/favicon.ico +0 -0
- package/hel_dist/hel-meta.json +64 -0
- package/hel_dist/index.html +1 -0
- package/hel_dist/manifest.json +10 -0
- package/hel_dist/robots.txt +3 -0
- package/hel_dist/static/css/291.0bcd258f.chunk.css +2 -0
- package/hel_dist/static/css/291.0bcd258f.chunk.css.map +1 -0
- package/hel_dist/static/css/622.0bcd258f.chunk.css +2 -0
- package/hel_dist/static/css/622.0bcd258f.chunk.css.map +1 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js +3 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js.LICENSE.txt +9 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js.map +1 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js +3 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js.LICENSE.txt +9 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js.map +1 -0
- package/hel_dist/static/js/main.e596336d.js +3 -0
- package/hel_dist/static/js/main.e596336d.js.LICENSE.txt +16 -0
- package/hel_dist/static/js/main.e596336d.js.map +1 -0
- package/hel_dist/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg +1 -0
- package/hel_proxy/entry.js +23 -0
- package/hel_proxy_es/entry.js +14 -0
- package/lib/components/HelloRemoteReactComp/App.css +50 -0
- package/lib/components/HelloRemoteReactComp/App.test.tsx +10 -0
- package/lib/components/HelloRemoteReactComp/App.tsx +37 -0
- package/lib/components/HelloRemoteReactComp/index.css +13 -0
- package/lib/components/HelloRemoteReactComp/index.tsx +4 -0
- package/lib/components/HelloRemoteReactComp/logo.svg +1 -0
- package/lib/components/index.ts +7 -0
- package/lib/configs/subApp.ts +9 -0
- package/lib/entrance/libProperties.ts +5 -0
- package/lib/entrance/libTypes.ts +10 -0
- package/lib/index.tsx +36 -0
- package/lib/loadApp.tsx +20 -0
- package/lib/react-app-env.d.ts +71 -0
- package/lib/setupProxy.js +23 -0
- package/lib/setupTests.ts +5 -0
- package/package.json +131 -0
- package/scripts/build.js +217 -0
- package/scripts/check.js +13 -0
- package/scripts/meta.js +21 -0
- package/scripts/postinstall.js +10 -0
- package/scripts/prepublishOnly.js +28 -0
- package/scripts/replaceToRelativePath.js +31 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/components/HelloRemoteReactComp/App.css +50 -0
- package/src/components/HelloRemoteReactComp/App.test.tsx +10 -0
- package/src/components/HelloRemoteReactComp/App.tsx +37 -0
- package/src/components/HelloRemoteReactComp/index.css +13 -0
- package/src/components/HelloRemoteReactComp/index.tsx +4 -0
- package/src/components/HelloRemoteReactComp/logo.svg +1 -0
- package/src/components/index.ts +7 -0
- package/src/configs/subApp.ts +9 -0
- package/src/entrance/libProperties.ts +5 -0
- package/src/entrance/libTypes.ts +10 -0
- package/src/index.tsx +36 -0
- package/src/loadApp.tsx +20 -0
- package/src/react-app-env.d.ts +71 -0
- package/src/setupProxy.js +23 -0
- package/src/setupTests.ts +5 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LibProperties } from './libProperties';
|
|
2
|
+
import { exposeLib } from 'hel-lib-proxy';
|
|
3
|
+
import { LIB_NAME } from '../configs/subApp';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const lib = exposeLib<LibProperties>(LIB_NAME);
|
|
7
|
+
|
|
8
|
+
export type Lib = LibProperties;
|
|
9
|
+
|
|
10
|
+
export default lib;
|
package/lib/index.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
|
|
|
4
|
+
| 应用可能使用了头部 import 静态导入语法来使用hel模块,所以此处
|
|
5
|
+
| 将应用入口文件后移一层到 loadApp 里并使用 import() 函数载入,这样以后
|
|
6
|
+
| entrance/libProperties 和 loadApp 模块下有其他远程模块依赖且想在整个项目使用静态导入时,
|
|
7
|
+
| 可在此文件main 函数里使用 helMicro.preFetchLib 来提前加载别的远程依赖,
|
|
8
|
+
|
|
|
9
|
+
| @author: fantasticsoul
|
|
10
|
+
| @date: 2022-06-05
|
|
11
|
+
|--------------------------------------------------------------------------
|
|
12
|
+
*/
|
|
13
|
+
// import { preFetchLib } from 'hel-micro';
|
|
14
|
+
import { isMasterApp } from 'hel-iso';
|
|
15
|
+
import { libReady } from 'hel-lib-proxy';
|
|
16
|
+
import { LIB_NAME } from './configs/subApp';
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
// 如有其他包依赖,且需要在逻辑里静态导入,可在此处执行预抓取
|
|
20
|
+
// await helMicro.preFetchLib('other-lib');
|
|
21
|
+
|
|
22
|
+
const libProperties = await import('./entrance/libProperties');
|
|
23
|
+
console.log('libProperties', libProperties);
|
|
24
|
+
// 表示模块已准备就绪,注意此处传递的是 default
|
|
25
|
+
libReady(LIB_NAME, libProperties.default);
|
|
26
|
+
|
|
27
|
+
// 非子应用时(即不是被别的模块触发载入的情况),自己挂载渲染节点,方便本地调试
|
|
28
|
+
if (isMasterApp()) {
|
|
29
|
+
await import('./loadApp');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main().catch(console.error);
|
|
34
|
+
|
|
35
|
+
// avoid isolatedModules warning
|
|
36
|
+
export default 'Hel Module Index file';
|
package/lib/loadApp.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import comps from './components';
|
|
5
|
+
|
|
6
|
+
function getHostNode(id = 'root') {
|
|
7
|
+
let node = document.getElementById(id);
|
|
8
|
+
if (!node) {
|
|
9
|
+
node = document.createElement('div');
|
|
10
|
+
node.id = id;
|
|
11
|
+
document.body.appendChild(node);
|
|
12
|
+
}
|
|
13
|
+
return node;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { REACT_APP_COMP_TYPE = 'HelloRemoteReactComp' } = process.env;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const Comp = comps[REACT_APP_COMP_TYPE] || (() => <h1>comp {REACT_APP_COMP_TYPE} not defined</h1>);
|
|
19
|
+
|
|
20
|
+
ReactDOM.render(<Comp />, getHostNode('root'));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
/// <reference types="react-dom" />
|
|
4
|
+
|
|
5
|
+
declare namespace NodeJS {
|
|
6
|
+
interface ProcessEnv {
|
|
7
|
+
readonly NODE_ENV: 'development' | 'production' | 'test';
|
|
8
|
+
readonly PUBLIC_URL: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '*.avif' {
|
|
13
|
+
const src: string;
|
|
14
|
+
export default src;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module '*.bmp' {
|
|
18
|
+
const src: string;
|
|
19
|
+
export default src;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const src: string;
|
|
24
|
+
export default src;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '*.jpg' {
|
|
28
|
+
const src: string;
|
|
29
|
+
export default src;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare module '*.jpeg' {
|
|
33
|
+
const src: string;
|
|
34
|
+
export default src;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module '*.png' {
|
|
38
|
+
const src: string;
|
|
39
|
+
export default src;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare module '*.webp' {
|
|
43
|
+
const src: string;
|
|
44
|
+
export default src;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare module '*.svg' {
|
|
48
|
+
import * as React from 'react';
|
|
49
|
+
|
|
50
|
+
export const ReactComponent: React.FunctionComponent<React.SVGProps<
|
|
51
|
+
SVGSVGElement
|
|
52
|
+
> & { title?: string }>;
|
|
53
|
+
|
|
54
|
+
const src: string;
|
|
55
|
+
export default src;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare module '*.module.css' {
|
|
59
|
+
const classes: { readonly [key: string]: string };
|
|
60
|
+
export default classes;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.module.scss' {
|
|
64
|
+
const classes: { readonly [key: string]: string };
|
|
65
|
+
export default classes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module '*.module.sass' {
|
|
69
|
+
const classes: { readonly [key: string]: string };
|
|
70
|
+
export default classes;
|
|
71
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 配置 proxy, 代理到本地启动的mocker服务
|
|
5
|
+
* 这份文件是CRA读取的,不属于项目打包后会包含的代码,所以非ts后缀
|
|
6
|
+
*/
|
|
7
|
+
const { createProxyMiddleware: proxy } = require('http-proxy-middleware');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function makeProxyConfig(target) {
|
|
11
|
+
return {
|
|
12
|
+
target,
|
|
13
|
+
secure: false,
|
|
14
|
+
changeOrigin: true,
|
|
15
|
+
withCredentials: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// 如当前组件本地调试时需要发起的请求被代理出去,可配置此文件
|
|
21
|
+
module.exports = function (app) {
|
|
22
|
+
app.use(proxy('/somepath', makeProxyConfig('https://xxx.yyy.com')));
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-hel-react-comps",
|
|
3
|
+
"appGroupName": "agent-hel-react-comps",
|
|
4
|
+
"main": "hel_proxy/entry.js",
|
|
5
|
+
"module": "hel_proxy_es/entry.js",
|
|
6
|
+
"types": "lib/entrance/libTypes.ts",
|
|
7
|
+
"unpkg": "hel_dist/index.html",
|
|
8
|
+
"version": "2.4.0",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"hel-iso": "^4.3.2",
|
|
11
|
+
"hel-lib-proxy": "^4.7.0",
|
|
12
|
+
"hel-micro": "^4.7.1",
|
|
13
|
+
"react": ">=16.8.0",
|
|
14
|
+
"react-app-polyfill": "^3.0.0",
|
|
15
|
+
"react-dom": ">=16.8.0"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"hel-iso": "^4.3.2",
|
|
19
|
+
"hel-lib-proxy": "^4.7.0",
|
|
20
|
+
"hel-micro": "^4.7.1",
|
|
21
|
+
"react": ">=16.8.0",
|
|
22
|
+
"react-app-polyfill": "^3.0.0",
|
|
23
|
+
"react-dom": ">=16.8.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/core": "^7.16.0",
|
|
27
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
|
|
28
|
+
"@svgr/webpack": "^5.5.0",
|
|
29
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
30
|
+
"@testing-library/react": "^13.3.0",
|
|
31
|
+
"@testing-library/user-event": "^13.5.0",
|
|
32
|
+
"@types/jest": "^27.5.2",
|
|
33
|
+
"@types/node": "^16.11.56",
|
|
34
|
+
"@types/react": "^18.0.18",
|
|
35
|
+
"@types/react-dom": "^18.0.6",
|
|
36
|
+
"babel-jest": "^27.4.2",
|
|
37
|
+
"babel-loader": "^8.2.3",
|
|
38
|
+
"babel-plugin-named-asset-import": "^0.3.8",
|
|
39
|
+
"babel-preset-react-app": "^10.0.1",
|
|
40
|
+
"bfj": "^7.0.2",
|
|
41
|
+
"browserslist": "^4.18.1",
|
|
42
|
+
"camelcase": "^6.2.1",
|
|
43
|
+
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
44
|
+
"css-loader": "^6.5.1",
|
|
45
|
+
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
46
|
+
"dotenv": "^10.0.0",
|
|
47
|
+
"dotenv-expand": "^5.1.0",
|
|
48
|
+
"eslint": "^8.3.0",
|
|
49
|
+
"eslint-config-react-app": "^7.0.1",
|
|
50
|
+
"eslint-webpack-plugin": "^3.1.1",
|
|
51
|
+
"file-loader": "^6.2.0",
|
|
52
|
+
"fs-extra": "^10.0.0",
|
|
53
|
+
"hel-dev-utils": "^4.3.11",
|
|
54
|
+
"html-webpack-plugin": "^5.5.0",
|
|
55
|
+
"identity-obj-proxy": "^3.0.0",
|
|
56
|
+
"jest": "^27.4.3",
|
|
57
|
+
"jest-resolve": "^27.4.2",
|
|
58
|
+
"jest-watch-typeahead": "^1.0.0",
|
|
59
|
+
"mini-css-extract-plugin": "^2.4.5",
|
|
60
|
+
"postcss": "^8.4.4",
|
|
61
|
+
"postcss-flexbugs-fixes": "^5.0.2",
|
|
62
|
+
"postcss-loader": "^6.2.1",
|
|
63
|
+
"postcss-normalize": "^10.0.1",
|
|
64
|
+
"postcss-preset-env": "^7.0.1",
|
|
65
|
+
"prompts": "^2.4.2",
|
|
66
|
+
"react-dev-utils": "^12.0.1",
|
|
67
|
+
"react-refresh": "^0.11.0",
|
|
68
|
+
"replace-absolute-path": "^1.3.4",
|
|
69
|
+
"resolve": "^1.20.0",
|
|
70
|
+
"resolve-url-loader": "^4.0.0",
|
|
71
|
+
"rollup-plugin-typescript": "^1.0.1",
|
|
72
|
+
"sass-loader": "^12.3.0",
|
|
73
|
+
"semver": "^7.3.5",
|
|
74
|
+
"source-map-loader": "^3.0.0",
|
|
75
|
+
"style-loader": "^3.3.1",
|
|
76
|
+
"tailwindcss": "^3.0.2",
|
|
77
|
+
"terser-webpack-plugin": "^5.2.5",
|
|
78
|
+
"typescript": "4.8.4",
|
|
79
|
+
"web-vitals": "^2.1.4",
|
|
80
|
+
"webpack": "^5.64.4",
|
|
81
|
+
"webpack-dev-server": "^4.6.0",
|
|
82
|
+
"webpack-manifest-plugin": "^4.0.2",
|
|
83
|
+
"workbox-webpack-plugin": "^6.4.1"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"postinstall": "node ./scripts/postinstall.js",
|
|
87
|
+
"prepublishOnly": "node ./scripts/prepublishOnly.js",
|
|
88
|
+
"check": "node ./scripts/check.js",
|
|
89
|
+
"start": "cross-env PORT=3103 node scripts/start.js",
|
|
90
|
+
"build": "npm run check_name && npm run build_dist && npm run build_meta && npm run build_proxy",
|
|
91
|
+
"check_name": "node scripts/check.js",
|
|
92
|
+
"build_dist": "node scripts/build.js",
|
|
93
|
+
"build_meta": "node scripts/meta.js",
|
|
94
|
+
"build_proxy": "npm run build_proxy_umd && npm run build_proxy_es",
|
|
95
|
+
"build_proxy_umd": "tsc & node ./scripts/replaceToRelativePath.js & rollup -c",
|
|
96
|
+
"build_proxy_es": "tsc & node ./scripts/replaceToRelativePath.js & cross-env BUILD_ENV=es rollup -c",
|
|
97
|
+
"lint": "eslint ./src --ext ts,tsx",
|
|
98
|
+
"lintfix": "eslint ./src --ext ts,tsx --fix",
|
|
99
|
+
"build_cust": "npm run set_home_page \"npm run build_dist && npm run build_meta\"",
|
|
100
|
+
"set_home_page": "cross-env-shell HEL_APP_HOME_PAGE=http://127.0.0.1:8103",
|
|
101
|
+
"test": "jest",
|
|
102
|
+
"snap": "jest -u"
|
|
103
|
+
},
|
|
104
|
+
"browserslist": {
|
|
105
|
+
"production": [
|
|
106
|
+
">0.2%",
|
|
107
|
+
"not dead",
|
|
108
|
+
"not op_mini all"
|
|
109
|
+
],
|
|
110
|
+
"development": [
|
|
111
|
+
"last 1 chrome version",
|
|
112
|
+
"last 1 firefox version",
|
|
113
|
+
"last 1 safari version"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"babel": {
|
|
117
|
+
"presets": [
|
|
118
|
+
"react-app"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"files": [
|
|
122
|
+
"hel_dist",
|
|
123
|
+
"hel_proxy",
|
|
124
|
+
"hel_proxy_es",
|
|
125
|
+
"lib",
|
|
126
|
+
"src",
|
|
127
|
+
"README.md",
|
|
128
|
+
"tsconfig.json",
|
|
129
|
+
"scripts"
|
|
130
|
+
]
|
|
131
|
+
}
|
package/scripts/build.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
4
|
+
process.env.BABEL_ENV = 'production';
|
|
5
|
+
process.env.NODE_ENV = 'production';
|
|
6
|
+
|
|
7
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
8
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
9
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
10
|
+
process.on('unhandledRejection', err => {
|
|
11
|
+
throw err;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Ensure environment variables are read.
|
|
15
|
+
require('../config/env');
|
|
16
|
+
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const chalk = require('react-dev-utils/chalk');
|
|
19
|
+
const fs = require('fs-extra');
|
|
20
|
+
const bfj = require('bfj');
|
|
21
|
+
const webpack = require('webpack');
|
|
22
|
+
const configFactory = require('../config/webpack.config');
|
|
23
|
+
const paths = require('../config/paths');
|
|
24
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
25
|
+
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
26
|
+
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
|
27
|
+
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
28
|
+
const printBuildError = require('react-dev-utils/printBuildError');
|
|
29
|
+
|
|
30
|
+
const measureFileSizesBeforeBuild =
|
|
31
|
+
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
32
|
+
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
33
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
34
|
+
|
|
35
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
36
|
+
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
37
|
+
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
38
|
+
|
|
39
|
+
const isInteractive = process.stdout.isTTY;
|
|
40
|
+
|
|
41
|
+
// Warn and crash if required files are missing
|
|
42
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const argv = process.argv.slice(2);
|
|
47
|
+
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
|
48
|
+
|
|
49
|
+
// Generate configuration
|
|
50
|
+
const config = configFactory('production');
|
|
51
|
+
|
|
52
|
+
// We require that you explicitly set browsers and do not fall back to
|
|
53
|
+
// browserslist defaults.
|
|
54
|
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
55
|
+
checkBrowsers(paths.appPath, isInteractive)
|
|
56
|
+
.then(() => {
|
|
57
|
+
// First, read the current file sizes in build directory.
|
|
58
|
+
// This lets us display how much they changed later.
|
|
59
|
+
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
60
|
+
})
|
|
61
|
+
.then(previousFileSizes => {
|
|
62
|
+
// Remove all content but keep the directory so that
|
|
63
|
+
// if you're in it, you don't end up in Trash
|
|
64
|
+
fs.emptyDirSync(paths.appBuild);
|
|
65
|
+
// Merge with the public folder
|
|
66
|
+
copyPublicFolder();
|
|
67
|
+
// Start the webpack build
|
|
68
|
+
return build(previousFileSizes);
|
|
69
|
+
})
|
|
70
|
+
.then(
|
|
71
|
+
({ stats, previousFileSizes, warnings }) => {
|
|
72
|
+
if (warnings.length) {
|
|
73
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
74
|
+
console.log(warnings.join('\n\n'));
|
|
75
|
+
console.log(
|
|
76
|
+
'\nSearch for the ' +
|
|
77
|
+
chalk.underline(chalk.yellow('keywords')) +
|
|
78
|
+
' to learn more about each warning.'
|
|
79
|
+
);
|
|
80
|
+
console.log(
|
|
81
|
+
'To ignore, add ' +
|
|
82
|
+
chalk.cyan('// eslint-disable-next-line') +
|
|
83
|
+
' to the line before.\n'
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
console.log(chalk.green('Compiled successfully.\n'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log('File sizes after gzip:\n');
|
|
90
|
+
printFileSizesAfterBuild(
|
|
91
|
+
stats,
|
|
92
|
+
previousFileSizes,
|
|
93
|
+
paths.appBuild,
|
|
94
|
+
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
95
|
+
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
96
|
+
);
|
|
97
|
+
console.log();
|
|
98
|
+
|
|
99
|
+
const appPackage = require(paths.appPackageJson);
|
|
100
|
+
const publicUrl = paths.publicUrlOrPath;
|
|
101
|
+
const publicPath = config.output.publicPath;
|
|
102
|
+
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
103
|
+
printHostingInstructions(
|
|
104
|
+
appPackage,
|
|
105
|
+
publicUrl,
|
|
106
|
+
publicPath,
|
|
107
|
+
buildFolder,
|
|
108
|
+
useYarn
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
err => {
|
|
112
|
+
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
113
|
+
if (tscCompileOnError) {
|
|
114
|
+
console.log(
|
|
115
|
+
chalk.yellow(
|
|
116
|
+
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
printBuildError(err);
|
|
120
|
+
} else {
|
|
121
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
122
|
+
printBuildError(err);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
.catch(err => {
|
|
128
|
+
if (err && err.message) {
|
|
129
|
+
console.log(err.message);
|
|
130
|
+
}
|
|
131
|
+
process.exit(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Create the production build and print the deployment instructions.
|
|
135
|
+
function build(previousFileSizes) {
|
|
136
|
+
console.log('Creating an optimized production build...');
|
|
137
|
+
|
|
138
|
+
const compiler = webpack(config);
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
compiler.run((err, stats) => {
|
|
141
|
+
let messages;
|
|
142
|
+
if (err) {
|
|
143
|
+
if (!err.message) {
|
|
144
|
+
return reject(err);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let errMessage = err.message;
|
|
148
|
+
|
|
149
|
+
// Add additional information for postcss errors
|
|
150
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
151
|
+
errMessage +=
|
|
152
|
+
'\nCompileError: Begins at CSS selector ' +
|
|
153
|
+
err['postcssNode'].selector;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
messages = formatWebpackMessages({
|
|
157
|
+
errors: [errMessage],
|
|
158
|
+
warnings: [],
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
messages = formatWebpackMessages(
|
|
162
|
+
stats.toJson({ all: false, warnings: true, errors: true })
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (messages.errors.length) {
|
|
166
|
+
// Only keep the first error. Others are often indicative
|
|
167
|
+
// of the same problem, but confuse the reader with noise.
|
|
168
|
+
if (messages.errors.length > 1) {
|
|
169
|
+
messages.errors.length = 1;
|
|
170
|
+
}
|
|
171
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
172
|
+
}
|
|
173
|
+
if (
|
|
174
|
+
process.env.CI &&
|
|
175
|
+
(typeof process.env.CI !== 'string' ||
|
|
176
|
+
process.env.CI.toLowerCase() !== 'false') &&
|
|
177
|
+
messages.warnings.length
|
|
178
|
+
) {
|
|
179
|
+
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
|
180
|
+
const filteredWarnings = messages.warnings.filter(
|
|
181
|
+
w => !/Failed to parse source map/.test(w)
|
|
182
|
+
);
|
|
183
|
+
if (filteredWarnings.length) {
|
|
184
|
+
console.log(
|
|
185
|
+
chalk.yellow(
|
|
186
|
+
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
187
|
+
'Most CI servers set it automatically.\n'
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
return reject(new Error(filteredWarnings.join('\n\n')));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const resolveArgs = {
|
|
195
|
+
stats,
|
|
196
|
+
previousFileSizes,
|
|
197
|
+
warnings: messages.warnings,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (writeStatsJson) {
|
|
201
|
+
return bfj
|
|
202
|
+
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
|
|
203
|
+
.then(() => resolve(resolveArgs))
|
|
204
|
+
.catch(error => reject(new Error(error)));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return resolve(resolveArgs);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function copyPublicFolder() {
|
|
213
|
+
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
214
|
+
dereference: true,
|
|
215
|
+
filter: file => file !== paths.appHtml,
|
|
216
|
+
});
|
|
217
|
+
}
|
package/scripts/check.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
|
|
|
4
|
+
| 此脚本在流水线上会被触发,用于校验组名是否和应用里的组名保持一致
|
|
5
|
+
|
|
|
6
|
+
|--------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const helDevUtils = require('hel-dev-utils');
|
|
10
|
+
const pkg = require('../package.json');
|
|
11
|
+
|
|
12
|
+
const fileFullPath = path.join(__dirname, '../src/configs/subApp');
|
|
13
|
+
helDevUtils.check(pkg, { fileFullPath, checkEnv: false });
|
package/scripts/meta.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
|
|
|
4
|
+
| 生成meta
|
|
5
|
+
|
|
|
6
|
+
|--------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
const process = require('process');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const helDevUtils = require('hel-dev-utils');
|
|
11
|
+
const packageJson = require('../package.json');
|
|
12
|
+
const appInfo = require('../config/appInfo');
|
|
13
|
+
|
|
14
|
+
helDevUtils.extractHelMetaJson({
|
|
15
|
+
appInfo,
|
|
16
|
+
buildDirFullPath: path.join(__dirname, '../hel_dist'),
|
|
17
|
+
packageJson,
|
|
18
|
+
}).catch(err => {
|
|
19
|
+
console.error(err);
|
|
20
|
+
process.exit(-1);
|
|
21
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
console.log('---------------------------------------------------------------------------------------');
|
|
3
|
+
console.log('| ');
|
|
4
|
+
console.log('| Welcome to use hel remote component');
|
|
5
|
+
console.log('| this lib only offer types(may include source code), its dist file is nearly empty,');
|
|
6
|
+
console.log('| so it has no effect on your app webpack bundle size! ');
|
|
7
|
+
console.log('| you should use hel-micro to load remote component.');
|
|
8
|
+
console.log('| see https://tnfe.github.io/hel to know more details of hel-micro');
|
|
9
|
+
console.log('| ');
|
|
10
|
+
console.log('---------------------------------------------------------------------------------------');
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
| npm publush 前检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
|
|
4
|
+
|--------------------------------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const chalk = require("react-dev-utils/chalk");
|
|
8
|
+
const pkg = require("../package.json");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const helDistPath = path.resolve(__dirname, "../hel_dist/hel-meta.json");
|
|
12
|
+
const existHelMeata = fs.existsSync(helDistPath);
|
|
13
|
+
|
|
14
|
+
// 检查是否执行npm run build 打包命令
|
|
15
|
+
if (!existHelMeata) {
|
|
16
|
+
console.log(chalk.red("Run the 'npm run build' command first.\n"));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const { app } = JSON.parse(fs.readFileSync(helDistPath, "utf-8"));
|
|
20
|
+
// 检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
|
|
21
|
+
if (app?.build_version !== pkg.version) {
|
|
22
|
+
console.log(
|
|
23
|
+
chalk.red(
|
|
24
|
+
"The package.json version number and the hel_dist/hel-meta.json version number must be the same.\n"
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
|
|
|
4
|
+
| convert absolute path based baseUrl to relative path
|
|
5
|
+
|
|
|
6
|
+
| 配合 npm run build_types 命令执行的脚本
|
|
7
|
+
| 用于将所有的绝对引用路径转为相对应用路径
|
|
8
|
+
| 例如:import { isSubApp } from 'services/appEnv';
|
|
9
|
+
| 将转为:import { isSubApp } from '../../services/appEnv';
|
|
10
|
+
| 这样被别的项目引用时才能正确的导出整个项目的推导类型
|
|
11
|
+
|--------------------------------------------------------------------------
|
|
12
|
+
*/
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const replacePath = require('replace-absolute-path');
|
|
15
|
+
// const { replaceRelativePath: replacePath, DEFAULT_EXTS } = require('./replace-relative-path');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
(async function () {
|
|
19
|
+
const srcDir = process.env.BUNDLE === 'true' ? path.resolve(__dirname, '../lib-js') : path.resolve(__dirname, '../src');
|
|
20
|
+
const libDir = process.env.BUNDLE === 'true' ? path.resolve(__dirname, '../lib-js') : path.resolve(__dirname, '../lib');
|
|
21
|
+
replacePath({
|
|
22
|
+
inputDir: srcDir,
|
|
23
|
+
outputDir: libDir,
|
|
24
|
+
// includeExts: DEFAULT_EXTS.concat(['.md']),
|
|
25
|
+
afterReplaced: () => {
|
|
26
|
+
console.log('----------------------------------------------------------------------------------');
|
|
27
|
+
console.log(`| all files import statements been transformed to relative path for ${libDir} ^_^ |`);
|
|
28
|
+
console.log('----------------------------------------------------------------------------------');
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
})();
|