test-hel-tpl-remote-lib-111 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +118 -0
- package/hel_dist/asset-manifest.json +16 -0
- package/hel_dist/hel-meta.json +42 -0
- package/hel_dist/hel_userChunk_1.js +1 -0
- package/hel_dist/index.html +1 -0
- package/hel_dist/manifest.json +10 -0
- package/hel_dist/precache-manifest.d376e39cbf960d26b36e995ad8603c00.js +26 -0
- package/hel_dist/robots.txt +3 -0
- package/hel_dist/service-worker.js +39 -0
- package/hel_dist/static/js/0.5c853936.chunk.js +2 -0
- package/hel_dist/static/js/0.5c853936.chunk.js.LICENSE.txt +14 -0
- package/hel_dist/static/js/main.c27f8348.chunk.js +2 -0
- package/hel_dist/static/js/main.c27f8348.chunk.js.LICENSE.txt +1 -0
- package/hel_dist/static/js/runtime-main.e18d2cf7.js +1 -0
- package/hel_proxy/entry.js +20 -0
- package/hel_proxy_es/entry.js +11 -0
- package/package.json +113 -0
- package/scripts/build.js +214 -0
- package/scripts/check.js +13 -0
- package/scripts/meta.js +21 -0
- package/scripts/postinstall.js +11 -0
- package/scripts/prepublishOnly.js +28 -0
- package/scripts/replaceToRelativePath.js +34 -0
- package/scripts/start.js +166 -0
- package/scripts/test.js +54 -0
package/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
## remote-lib-tpl
|
2
|
+
基于[hel-micro](https://github.com/tnfe/hel)搭建的远程仓库模板库
|
3
|
+
|
4
|
+
## 如何参与
|
5
|
+
- 改subApp
|
6
|
+
`src/configs/subApp.ts`改为你的hel模块名
|
7
|
+
```ts
|
8
|
+
export const APP_GROUP_NAME = 'hlib-xxx'; /// 名字随意,和 package.json name 一样即可
|
9
|
+
```
|
10
|
+
|
11
|
+
- 改package.json
|
12
|
+
将`hame`和`appGroupName`改为hel模块名(名字随意,保持一样即可)
|
13
|
+
```
|
14
|
+
"name": "hlib-xxx",
|
15
|
+
"appGroupName": "hlib-xxx",
|
16
|
+
```
|
17
|
+
|
18
|
+
- 改源代码
|
19
|
+
`src/utils/myMod.ts`
|
20
|
+
```ts
|
21
|
+
export function sayHelloToHel(from: string) {
|
22
|
+
const yourRtxName = ''; // 可改写为你的名字
|
23
|
+
return `hello hel, I am ${yourName}, I come from ${from}`;
|
24
|
+
}
|
25
|
+
```
|
26
|
+
|
27
|
+
- 改单测文件
|
28
|
+
`src/utils/__tests__/myMod.ts`
|
29
|
+
```ts
|
30
|
+
describe('test myMod', () => {
|
31
|
+
test('sayHelloToHel', () => {
|
32
|
+
const yourRtxName = ''; // 此处改写为你的rtx名字
|
33
|
+
const ret = `hello hel, I am ${yourRtxName}, I come from bj`;
|
34
|
+
expect(sayHelloToHel('bj') === ret).toBeTruthy();
|
35
|
+
});
|
36
|
+
});
|
37
|
+
```
|
38
|
+
|
39
|
+
- 执行单测
|
40
|
+
```
|
41
|
+
npm run test
|
42
|
+
```
|
43
|
+
|
44
|
+
- 发布源码和类型
|
45
|
+
```
|
46
|
+
npm run build
|
47
|
+
npm publish
|
48
|
+
```
|
49
|
+
|
50
|
+
## FAQ
|
51
|
+
### 为何入口文件采取动态模块导入写法
|
52
|
+
如果采用静态导入写法
|
53
|
+
|
54
|
+
```ts
|
55
|
+
import { libReady } from 'hel-lib-proxy';
|
56
|
+
import { LIB_NAME } from './configs/subApp';
|
57
|
+
|
58
|
+
async function main() {
|
59
|
+
const libProperties = await import('./entrance/libProperties');
|
60
|
+
libReady(LIB_NAME, libProperties.default);
|
61
|
+
};
|
62
|
+
|
63
|
+
main().catch(console.error);
|
64
|
+
export default 'REMOTE MOD';
|
65
|
+
```
|
66
|
+
|
67
|
+
需要将 `config/webpack.config.js`里的 `maxChunks`的值 1 改为 4
|
68
|
+
```js
|
69
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
70
|
+
maxChunks: 4,
|
71
|
+
}),
|
72
|
+
```
|
73
|
+
如果不改动,构建会报错
|
74
|
+
|
75
|
+
```bash
|
76
|
+
Creating an optimized production build...
|
77
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
78
|
+
npx browserslist@latest --update-db
|
79
|
+
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
|
80
|
+
Failed to compile.
|
81
|
+
|
82
|
+
chunk runtime-main [entry]
|
83
|
+
Cannot convert undefined or null to object
|
84
|
+
```
|
85
|
+
|
86
|
+
改动后构建产物如下
|
87
|
+
|
88
|
+
```bash
|
89
|
+
6.57 KB hel_dist/static/js/2.506e8c97.chunk.js
|
90
|
+
1.14 KB hel_dist/static/js/runtime-main.65c05a8a.js
|
91
|
+
499 B hel_dist/static/js/3.21d3206a.chunk.js
|
92
|
+
390 B hel_dist/static/js/main.15c0c746.chunk.js
|
93
|
+
```
|
94
|
+
|
95
|
+
改为动态导入写法后
|
96
|
+
|
97
|
+
```ts
|
98
|
+
async function main() {
|
99
|
+
const { libReady } = await import('hel-lib-proxy');
|
100
|
+
const { LIB_NAME } = await import('./configs/subApp');
|
101
|
+
|
102
|
+
const libProperties = await import('./entrance/libProperties');
|
103
|
+
libReady(LIB_NAME, libProperties.default);
|
104
|
+
};
|
105
|
+
|
106
|
+
main().catch(console.error);
|
107
|
+
export default 'HEL REMOTE MOD';
|
108
|
+
```
|
109
|
+
|
110
|
+
则支持 `config/webpack.config.js`里的 `maxChunks`的值设置为 1,此时构建产物如下
|
111
|
+
|
112
|
+
```bash
|
113
|
+
4.72 KB hel_dist/static/js/0.a104ee67.chunk.js
|
114
|
+
2.74 KB (+2.36 KB) hel_dist/static/js/main.070cd75c.chunk.js
|
115
|
+
1.14 KB (-2 B) hel_dist/static/js/runtime-main.a8e25f5a.js
|
116
|
+
```
|
117
|
+
|
118
|
+
相比比原来少一个 `chunk`,为了构建产物尽可能的少 `chunk`,选择了入口文件采取动态模块导入写法
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"files": {
|
3
|
+
"static/js/0.5c853936.chunk.js": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/0.5c853936.chunk.js",
|
4
|
+
"main.js": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js",
|
5
|
+
"runtime-main.js": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/runtime-main.e18d2cf7.js",
|
6
|
+
"index.html": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/index.html",
|
7
|
+
"precache-manifest.d376e39cbf960d26b36e995ad8603c00.js": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/precache-manifest.d376e39cbf960d26b36e995ad8603c00.js",
|
8
|
+
"service-worker.js": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/service-worker.js",
|
9
|
+
"static/js/0.5c853936.chunk.js.LICENSE.txt": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/0.5c853936.chunk.js.LICENSE.txt",
|
10
|
+
"static/js/main.c27f8348.chunk.js.LICENSE.txt": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js.LICENSE.txt"
|
11
|
+
},
|
12
|
+
"entrypoints": [
|
13
|
+
"static/js/runtime-main.e18d2cf7.js",
|
14
|
+
"static/js/main.c27f8348.chunk.js"
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"app": {
|
3
|
+
"name": "test-hel-tpl-remote-lib-111",
|
4
|
+
"app_group_name": "test-hel-tpl-remote-lib-111",
|
5
|
+
"git_repo_url": "",
|
6
|
+
"extract_mode": "build",
|
7
|
+
"online_version": "0.0.1",
|
8
|
+
"build_version": "0.0.1"
|
9
|
+
},
|
10
|
+
"version": {
|
11
|
+
"plugin_ver": "3.1.0",
|
12
|
+
"sub_app_name": "test-hel-tpl-remote-lib-111",
|
13
|
+
"sub_app_version": "0.0.1",
|
14
|
+
"src_map": {
|
15
|
+
"webDirPath": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist",
|
16
|
+
"htmlIndexSrc": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/index.html",
|
17
|
+
"iframeSrc": "",
|
18
|
+
"chunkCssSrcList": [],
|
19
|
+
"chunkJsSrcList": [
|
20
|
+
"https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/hel_userChunk_1.js",
|
21
|
+
"https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js"
|
22
|
+
],
|
23
|
+
"privCssSrcList": [],
|
24
|
+
"headAssetList": [],
|
25
|
+
"bodyAssetList": [
|
26
|
+
{
|
27
|
+
"tag": "script",
|
28
|
+
"attrs": {
|
29
|
+
"src": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/hel_userChunk_1.js"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"tag": "script",
|
34
|
+
"attrs": {
|
35
|
+
"src": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
]
|
39
|
+
},
|
40
|
+
"html_content": "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"/><title>remote-lib-tpl</title><meta name=\"description\" content=\"hel remote lib template\"/></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id=\"root\"></div><script>!function(e){function t(t){for(var n,i,l=t[0],a=t[1],c=t[2],f=0,p=[];f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,c||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==o[a]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={2:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,l=document.createElement(\"script\");l.charset=\"utf-8\",l.timeout=120,i.nc&&l.setAttribute(\"nonce\",i.nc),l.src=function(e){return i.p+\"static/js/\"+({}[e]||e)+\".\"+{0:\"5c853936\"}[e]+\".chunk.js\"}(e);var a=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(c);var r=o[e];if(0!==r){if(r){var n=t&&(\"load\"===t.type?\"missing\":t.type),u=t&&t.target&&t.target.src;a.message=\"Loading chunk \"+e+\" failed.\\n(\"+n+\": \"+u+\")\",a.name=\"ChunkLoadError\",a.type=n,a.request=u,r[1](a)}o[e]=void 0}};var c=setTimeout((function(){u({type:\"timeout\",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,\"a\",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p=\"https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/\",i.oe=function(e){throw console.error(e),e};var l=this[\"helJsonp_test-hel-tpl-remote-lib-111_1679058373255\"]=this[\"helJsonp_test-hel-tpl-remote-lib-111_1679058373255\"]||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var c=0;c<l.length;c++)t(l[c]);var s=a;r()}([])</script><script src=\"https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js\"></script></body></html>"
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e){function t(t){for(var n,i,l=t[0],a=t[1],c=t[2],f=0,p=[];f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,c||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==o[a]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={2:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{0:"5c853936"}[e]+".chunk.js"}(e);var a=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(c);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",a.name="ChunkLoadError",a.type=n,a.request=u,r[1](a)}o[e]=void 0}};var c=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/",i.oe=function(e){throw console.error(e),e};var l=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var c=0;c<l.length;c++)t(l[c]);var s=a;r()}([])
|
@@ -0,0 +1 @@
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><title>remote-lib-tpl</title><meta name="description" content="hel remote lib template"/></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,i,l=t[0],a=t[1],c=t[2],f=0,p=[];f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,c||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==o[a]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={2:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{0:"5c853936"}[e]+".chunk.js"}(e);var a=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(c);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",a.name="ChunkLoadError",a.type=n,a.request=u,r[1](a)}o[e]=void 0}};var c=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/",i.oe=function(e){throw console.error(e),e};var l=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var c=0;c<l.length;c++)t(l[c]);var s=a;r()}([])</script><script src="https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js"></script></body></html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
self.__precacheManifest = (self.__precacheManifest || []).concat([
|
2
|
+
{
|
3
|
+
"revision": "991621516ed57553e4914d2e86f00601",
|
4
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/index.html"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"revision": "59b9431318f2c4d3431b",
|
8
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/0.5c853936.chunk.js"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"revision": "114fa89da3636722bc04f5ae14df1de3",
|
12
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/0.5c853936.chunk.js.LICENSE.txt"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"revision": "9a378155806506cdb26e",
|
16
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"revision": "4e0e34f265fae8f33b01b27ae29d9d6f",
|
20
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/main.c27f8348.chunk.js.LICENSE.txt"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"revision": "af9954ccc47eeab258b4",
|
24
|
+
"url": "https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/static/js/runtime-main.e18d2cf7.js"
|
25
|
+
}
|
26
|
+
]);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* Welcome to your Workbox-powered service worker!
|
3
|
+
*
|
4
|
+
* You'll need to register this file in your web app and you should
|
5
|
+
* disable HTTP caching for this file too.
|
6
|
+
* See https://goo.gl/nhQhGp
|
7
|
+
*
|
8
|
+
* The rest of the code is auto-generated. Please don't update this file
|
9
|
+
* directly; instead, make changes to your Workbox build configuration
|
10
|
+
* and re-run your build process.
|
11
|
+
* See https://goo.gl/2aRDsh
|
12
|
+
*/
|
13
|
+
|
14
|
+
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
15
|
+
|
16
|
+
importScripts(
|
17
|
+
"https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/precache-manifest.d376e39cbf960d26b36e995ad8603c00.js"
|
18
|
+
);
|
19
|
+
|
20
|
+
self.addEventListener('message', (event) => {
|
21
|
+
if (event.data && event.data.type === 'SKIP_WAITING') {
|
22
|
+
self.skipWaiting();
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
workbox.core.clientsClaim();
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
|
30
|
+
* requests for URLs in the manifest.
|
31
|
+
* See https://goo.gl/S9QRab
|
32
|
+
*/
|
33
|
+
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
34
|
+
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|
35
|
+
|
36
|
+
workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/index.html"), {
|
37
|
+
|
38
|
+
blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
|
39
|
+
});
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! For license information please see 0.5c853936.chunk.js.LICENSE.txt */
|
2
|
+
(this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]||[]).push([[0],[,,function(e,t,r){"use strict";r.r(t);var n={get num1to9(){return/^[1-9]+[0-9]*$/},get en(){return/^[A-Za-z]+$/},get enSnake(){return/^[a-z][_0-9a-z]*[a-z0-9]+$/},get enOrNumOrUnderline(){return/^[A-Za-z0-9_]+$/},get enOrNum(){return/^[A-Za-z0-9]+$/}};t.default=n},function(e,t,r){"use strict";r.r(t),r.d(t,"canBeNum",(function(){return o})),r.d(t,"random",(function(){return a}));var n=r(2);function o(e){var t=typeof e;if("string"===t){if(e.includes(".")){var r=e.replace(/\./g,"");if(!n.default.num1to9.test(r))return!1;var o=parseFloat(e);return!Number.isNaN(o)}return n.default.num1to9.test(e)}return"number"===t}function a(e){return Math.floor(e*Math.random())}},function(e,t,r){"use strict";r.r(t),function(e){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!==typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,u=[],p=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;p=!1}else for(;!(p=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);p=!0);}catch(c){l=!0,o=c}finally{try{if(!p&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"===typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,"DEFAULT_ONLINE_VER",(function(){return J})),r.d(t,"allowLog",(function(){return Z})),r.d(t,"appReady",(function(){return ie})),r.d(t,"default",(function(){return Ie})),r.d(t,"getAppMeta",(function(){return de})),r.d(t,"getAppPlatform",(function(){return Ne})),r.d(t,"getAppStyleStr",(function(){return Me})),r.d(t,"getGlobalThis",(function(){return Q})),r.d(t,"getHelDebug",(function(){return Y})),r.d(t,"getHelEventBus",(function(){return ee})),r.d(t,"getPlatform",(function(){return $})),r.d(t,"getPlatformConfig",(function(){return ce})),r.d(t,"getPlatformHost",(function(){return ue})),r.d(t,"getSharedCache",(function(){return re})),r.d(t,"getUserEventBus",(function(){return te})),r.d(t,"getVerApp",(function(){return fe})),r.d(t,"getVerExtraCssList",(function(){return ye})),r.d(t,"getVerLib",(function(){return ge})),r.d(t,"getVerLoadStatus",(function(){return Ae})),r.d(t,"getVerStyleStrStatus",(function(){return _e})),r.d(t,"getVersion",(function(){return Ee})),r.d(t,"helEvents",(function(){return q})),r.d(t,"helLoadStatus",(function(){return K})),r.d(t,"initPlatformConfig",(function(){return le})),r.d(t,"isSubApp",(function(){return z})),r.d(t,"libReady",(function(){return ae})),r.d(t,"log",(function(){return W})),r.d(t,"resetGlobalThis",(function(){return B})),r.d(t,"setAppMeta",(function(){return me})),r.d(t,"setAppPlatform",(function(){return Se})),r.d(t,"setAppStyleStr",(function(){return we})),r.d(t,"setEmitApp",(function(){return se})),r.d(t,"setEmitLib",(function(){return ve})),r.d(t,"setGlobalThis",(function(){return X})),r.d(t,"setVerExtraCssList",(function(){return he})),r.d(t,"setVerLoadStatus",(function(){return be})),r.d(t,"setVerStyleStrStatus",(function(){return Le})),r.d(t,"setVersion",(function(){return Ve})),r.d(t,"tryGetAppName",(function(){return oe})),r.d(t,"tryGetVersion",(function(){return ne})),r.d(t,"trySetMasterAppLoadedSignal",(function(){return U}));var l={NOT_LOAD:0,LOADING:1,LOADED:2},c=["ht","tps",":/","/foo","tpri","nt.q","q.c","om/"].join("");function s(e){return"unpkg"===e?"https://unpkg.com":function(e){return"".concat(c).concat(e)}()}var f=null;function d(){if(f)return f;try{if("undefined"!==typeof window)return window;if("undefined"!==typeof self)return self;if("undefined"!==typeof e)return e;throw new Error("opps")}catch(t){throw new Error("unable to locate global object")}}function m(){return d()}var v=m().__HEL_MICRO_DEBUG__;function g(){return v}function h(e,t){return t.includes(",")?t.split(",").some((function(t){return e.includes(t)})):e.includes(t)}function y(){return 0!==A()}function b(e){var t=parseInt(e,10);[1,2].includes(t)&&(g().logMode=t)}function A(){return g().logMode}function L(e){g().logFilter=e}function _(){return g().logFilter}v?void 0===v.logMode&&(v.logMode=0,v.logFilter=""):(v={logMode:0,logFilter:"",isInit:!1},m().__HEL_MICRO_DEBUG__=v),function(){if(g().isInit)return;g().isInit=!0;var e=function(){var e=function(){try{var e,t;return(null===(e=d().top)||void 0===e||null===(t=e.location)||void 0===t?void 0:t.search)||""}catch(o){var r,n;return(null===(r=d())||void 0===r||null===(n=r.location)||void 0===n?void 0:n.search)||""}}(),t={};if(null!==e&&void 0!==e&&e.startsWith("?")){e.substring(1).split("&").forEach((function(e){var r=a(e.split("="),2),n=r[0],o=r[1];t[n]=o}))}return t}(),t=e.hellog,r=e.hellogf,n=d().localStorage;b(t||(null===n||void 0===n?void 0:n.getItem("HelConfig.logMode"))||0),L(r||(null===n||void 0===n?void 0:n.getItem("HelConfig.logFilter"))||"")}();var S=" %c--\x3e HEL LOG:",N="color:#ad4e00;font-weight:600";function E(){if(y()){for(var e=1===A()?console.log:console.trace||console.log,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var o=r[0],a=r.slice(1);if("string"!==typeof o)return e.apply(void 0,[S,N].concat(r));var u=_(),p=["".concat(S," ").concat(o),N].concat(i(a));u?h(o,u)&&e.apply(void 0,i(p)):e.apply(void 0,i(p))}}function V(){var e="";try{throw new Error("getJsRunLocation")}catch(r){var t=r.stack.split("\n");e=t[t.length-1]||""}return e}function M(e,t,r,n){w(e,t)[r]=n}function w(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e[t];return n||(n=r,e[t]=n),n}function I(e){return{isConfigOverwrite:!1,platform:e,initPack:"out",appName2Comp:{},appName2Lib:{},appName2isLibAssigned:{},appName2EmitApp:{},appName2verLoadStatus:{},appName2verEmitLib:{},appName2verEmitApp:{},appName2verStyleStr:{},appName2verStyleFetched:{},appName2verExtraCssList:{},appName2verAppVersion:{},appName2app:{},appName2appVersion:{},appName2styleStr:{},appGroupName2firstVer:{},isInnerHooksInit:!1,strictMatchVer:!0,apiMode:"jsonp",apiPrefix:"",apiSuffix:"",apiPathOfApp:"/openapi/v1/app/info",apiPathOfAppVersion:"",getUserName:null,prepareRequestInfo:null,getSubAppAndItsVersionFn:null,onFetchMetaFailed:null,userLsKey:""}}function O(){var e={};return{on:function(t,r){var n=e[t];if(!n){var o=[];e[t]=o,n=o}n.push(r)},emit:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];var a=e[t];if(a){var i=a.slice();i.forEach((function(e){return e.apply(void 0,n)}))}},off:function(t,r){var n=e[t];if(n)for(var o=0,a=n.length;o<a;o++){if(n[o]===r){n.splice(o,1);break}}}}}function P(){var e=x();if(e){var t=e.cacheRoot;w(t,"appGroupName2platform");var r=t.caches;return Object.keys(r).forEach((function(e){var t=r[e];w(t,"appGroupName2firstVer"),w(t,"appName2verExtraCssList")})),void(e.userEventBus||(e.userEventBus=O()))}e=function(){var e,t=I("hel"),r=I("unpkg"),n={platform:"unpkg",appName2platform:{},appGroupName2platform:{},caches:(e={},o(e,"hel",t),o(e,"unpkg",r),e)},a=O(),i=O();return{createFeature:V(),eventBus:a,userEventBus:i,cacheRoot:n,unpkgCache:r,helCache:t,dev:{setLogMode:b,setLogFilter:L}}}(),m().__HEL_MICRO_SHARED__=e}function x(){return m().__HEL_MICRO_SHARED__}function C(){return x().cacheRoot.platform||"unpkg"}function D(e){var t=e||C(),r=k(),n=r.caches[t];if(!n){var o=I(e);r.caches[t]=o,n=o}return n}function k(){return x().cacheRoot}var j=!1,F=!1;function G(e){if(e&&(j=!1,F=!1),!0!==F){F=!0;var t=d();void 0===t.__MASTER_APP_LOADED__&&(t.__MASTER_APP_LOADED__=!0,j=!0)}}function B(e){e&&X(e),G(!!e),P()}E("hel-micro-core ver ".concat("3.13.5")),B();var R=function(e,t,r,n){var o=n||{},a=o.versionId;M(re(o.platform)[r],e,a||J,t)},H=function(e,t,r){var n,o=r||{},a=o.versionId,i=re(o.platform)[t],u=a||J;return(null===(n=i[e])||void 0===n?void 0:n[u])||l.NOT_LOAD},T=function(e,t,r){if(!e[J]){var n=de(t,r),o=e[null===n||void 0===n?void 0:n.online_version];o&&(e[J]=o)}},U=G,z=function(){return!j},$=C,q={SUB_APP_LOADED:"subAppLoaded",SUB_LIB_LOADED:"SubLibLoaded",STYLE_STR_FETCHED:"StyleStrFetched"},K=l,J="__default_online_ver__",Z=y,W=E,Y=g,Q=d,X=function(e){f=e};function ee(){return x().eventBus}function te(){return x().userEventBus}function re(e){return D(e)}function ne(e,t){var r=V();E("[[ core:tryGetVersion ]] may include source > ".concat(r));var n=re(t).appGroupName2firstVer[e]||"";if(r.includes("https://")||r.includes("http://")){var o=a(r.split("//"),2)[1].split("/");if(n){if("unpkg"===t&&o.some((function(e){return e.includes(n)})))return n;if(o.includes(n))return n;if("static"===o[1]&&"js"===o[2]||"js"===o[1])return n}return"unpkg"===t?o[1].split("@")[1]||n:o[2]||n}return n}function oe(e,t){return e===J?t||"":e.includes("_")?e.substring(0,e.length-15):t||""}function ae(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.platform||Ne(e),o=r.versionId||ne(e,n),a=r.appName||oe(o,e),i=de(a,n);null!==i&&void 0!==i&&i.__fromCust&&(o=i.online_version,a=i.name);var u={platform:n,appName:a,appGroupName:e,versionId:o,appProperties:t,Comp:function(){},lifecycle:{}};ve(a,u,{appGroupName:e,platform:n}),be(a,K.LOADED,{versionId:o,platform:n});var p=ee();p.emit(q.SUB_LIB_LOADED,u)}function ie(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.lifecycle,o=r.platform||Ne(e),a=r.versionId||ne(e,o),i=r.appName||oe(a,e),u={Comp:t,appName:i,appGroupName:e,lifecycle:n,platform:o,versionId:a,isLib:!1};se(i,u),be(i,K.LOADED,{versionId:a,platform:o});var p=ee();p.emit(q.SUB_APP_LOADED,u)}function ue(e){var t=e||$(),r=re(t).apiPrefix;return r||s(t)}function pe(e){return{apiMode:e.apiMode,apiPrefix:e.apiPrefix,apiSuffix:e.apiSuffix,apiPathOfApp:e.apiPathOfApp,apiPathOfAppVersion:e.apiPathOfAppVersion,getSubAppAndItsVersionFn:e.getSubAppAndItsVersionFn,onFetchMetaFailed:e.onFetchMetaFailed,strictMatchVer:e.strictMatchVer,getUserName:e.getUserName,userLsKey:e.userLsKey,platform:e.platform,shouldUseGray:e.shouldUseGray}}function le(e,t){var r,n,o=D(t),a=pe(e);o.isConfigOverwrite||(o.isConfigOverwrite=!0,r=o,n=a,Object.keys(n).forEach((function(e){var t=n[e];[null,void 0,""].includes(t)||(r[e]=t)})))}function ce(e){return pe(D(e))}function se(e,t){W("[[ core:setEmitApp ]] appName,emitApp:",e,t);var r=t.versionId,n=re(t.platform),o=n.appName2verEmitApp,a=n.appName2Comp,i=n.appName2EmitApp;w(o,e)[J]||(a[e]=t.Comp,i[e]=t,M(o,e,J,t)),r&&M(o,e,r,t)}function fe(e,t){var r,n=t||{},o=n.versionId,a=n.platform,i=re(a),u=i.appName2verEmitApp,p=i.appName2Comp,l=i.strictMatchVer,c=i.appName2EmitApp,s=null!==(r=n.strictMatchVer)&&void 0!==r?r:l,f=w(u,e);T(f,e,a);var d=f[o||J],m=p[e],v=m?{Comp:m}:null,g=s?null:c[e]||v,h=d||g||null;return W("[[ core:getVerApp ]] appName,options,result:",e,n,h),h}function de(e,t){return re(t).appName2app[e]}function me(e,t){re(t).appName2app[e.name]=e}function ve(e,t,r){var o=(r||{}).appGroupName,a=t.versionId,i=t.appProperties,u=t.platform||r.platform,p=re(u),l=p.appName2verEmitLib,c=p.appName2Lib,s=p.appName2isLibAssigned,f=de(e,u),d=function(e){var t=c[e];t?"object"===n(t)&&0===Object.keys(t).length&&Object.assign(t,i):c[e]=i,s[e]=!0};d(e),o?d(o):f&&d(f.app_group_name),W("[[ core:setEmitLib ]] appMeta:",f),w(l,e)[J]||M(l,e,J,i),a&&M(l,e,a,i)}function ge(e,t){var r,n=t||{},o=n.versionId,a=re(n.platform),i=a.appName2verEmitLib,u=a.appName2Lib,p=a.strictMatchVer,l=a.appName2isLibAssigned,c=null!==(r=n.strictMatchVer)&&void 0!==r?r:p,s=w(i,e);T(s,e);var f=s[o||J],d=l[e]?u[e]:null,m=f||(c?null:d)||null;return W("[[ core:getVerLib ]] appName,options,result:",e,n,m),m}function he(e,t,r){var n=r||{},o=n.versionId,a=re(n.platform).appName2verExtraCssList;W("[[ core:setVerExtraCssList ]] cssList:",t),w(a,e)[J]||M(a,e,J,t),o&&M(a,e,o,t)}function ye(e,t){var r=t||{},n=r.versionId,o=w(re(r.platform).appName2verExtraCssList,e),a=o[n]||o[J]||[];return W("[[ core:getVerExtraCssList ]] options,cssList:",r,a),a}function be(e,t,r){R(e,t,"appName2verLoadStatus",r)}function Ae(e,t){return H(e,"appName2verLoadStatus",t)}function Le(e,t,r){R(e,t,"appName2verStyleFetched",r)}function _e(e,t){return H(e,"appName2verStyleFetched",t)}function Se(e,t){return k().appGroupName2platform[e]=t,Ne(e)}function Ne(e){return k().appGroupName2platform[e]||C()}function Ee(e,t){var r,n=t||{},o=n.platform,a=n.versionId,i=re(o),u=i.appName2verAppVersion,p=i.appName2appVersion[e]||null;return a&&(null===(r=u[e])||void 0===r?void 0:r[a])||p}function Ve(e,t,r){var n=(r||{}).platform,o=re(n),a=o.appName2verAppVersion,i=o.appGroupName2firstVer,u=o.appName2appVersion,p=t.sub_app_version;if(p){var l=de(e,n);w(a,e)[J]||(M(a,e,J,t),u[e]=t),M(a,e,p,t),i[l.app_group_name]=p}}function Me(e,t){var r,n=t||{},o=n.platform,a=n.versionId,i=re(o),u=i.appName2verStyleStr,p=i.appName2styleStr[e]||"";return a?(null===(r=u[e])||void 0===r?void 0:r[a])||p||"":p}function we(e,t,r){var n=r||{},o=n.platform,a=n.versionId,i=re(o),u=i.appName2verStyleStr,p=i.appName2verStyleFetched,l=i.appName2styleStr;a?(M(u,e,a,t),M(p,e,a,K.LOADED)):l[e]=t}var Ie={DEFAULT_ONLINE_VER:J,helLoadStatus:l,helEvents:q,isSubApp:z,trySetMasterAppLoadedSignal:G,getHelEventBus:ee,getUserEventBus:te,getHelDebug:g,getSharedCache:re,getPlatform:C,getPlatformHost:ue,getPlatformConfig:ce,getAppPlatform:Ne,setAppPlatform:Se,getVerApp:fe,setEmitApp:se,getVerLib:ge,setEmitLib:ve,getAppMeta:de,setAppMeta:me,getVersion:Ee,setVersion:Ve,getAppStyleStr:Me,setAppStyleStr:we,getVerLoadStatus:Ae,setVerLoadStatus:be,getVerStyleStrStatus:_e,setVerStyleStrStatus:Le,getVerExtraCssList:ye,setVerExtraCssList:he,tryGetVersion:ne,tryGetAppName:oe,initPlatformConfig:le,libReady:ae,appReady:ie,log:E,allowLog:y,getGlobalThis:d,setGlobalThis:X,resetGlobalThis:B}}.call(this,r(5))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(n){"object"===typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";r.r(t),r.d(t,"LIB_NAME",(function(){return n}));var n="test-hel-tpl-remote-lib-111"},function(e,t,r){!function(e,t){"use strict";var r=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(t),n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e){return e||"unpkg"}function a(e,r){var n=r||(null===t.getAppPlatform||void 0===t.getAppPlatform?void 0:t.getAppPlatform(e)),o=t.getSharedCache(n).appName2Lib;return o[e]||(o[e]={}),o[e]}r.default.log("hel-lib-proxy ver 3.13.2");var i=(0,r.default.getUserEventBus)();function u(e,t){var a=n({},t||{});return a.platform=o(),r.default.getVerLib(e,a)}function p(e,n){var i,u=!0,p="";n&&("string"==typeof n?p=n:(p=n.platform||"",u=null===(i=n.asProxy)||void 0===i||i));var l=a(e,p=p||o());return"function"==typeof Proxy&&u&&(l=function(e,r,n){return new Proxy(r,{get:function(r,o){var i=String(o);return t.log("[[getLibProxy]] call lib ["+e+"] method ["+i+"]"),Object.keys(r).length?r[i]:a(e,n)[i]}})}(e,l,p)),r.default.log("[[ exposeLib ]] libName, libObj",e,l),l}function l(e,t,a){var i=function(e){var t={allowDup:!1,platform:o()};return n(n({},t),e||{})}(a);r.default.libReady(e,t,i)}function c(e,t,n){r.default.appReady(e,t,n)}function s(e,t){return r.default.getVerApp(e,t)}function f(){return!r.default.isSubApp()}var d=r.default.isSubApp,m={libReady:l,exposeLib:p,getLib:u,isSubApp:d,isMasterApp:f,eventBus:i,appReady:c,exposeApp:s};e.appReady=c,e.default=m,e.eventBus=i,e.exposeApp=s,e.exposeLib=p,e.getLib=u,e.isMasterApp=f,e.isSubApp=d,e.libReady=l,Object.defineProperty(e,"__esModule",{value:!0})}(t,r(4))},function(e,t,r){"use strict";r.r(t);var n=r(6),o=r(3);window.__callMethod__=function(){var e=Object(o.random)(100);i("".concat(e,"_").concat(Date.now()))};var a='\n <span style="color:#c62d31">---\x3e lazy load mode</span>\n <pre style="background-color:lightgray;padding-top:12px">\n import helMicro from \'hel-micro\';\n\n export async function callRemoteMethod(){\n const remoteLib = await helMicro.preFetchLib(\''.concat(n.LIB_NAME,"');\n // now you can call the remote lib by 'remoteLib' reference\n }\n </pre>\n <span style=\"color:#c62d31\">---\x3e preload mode</span>\n <pre style=\"background-color:lightgray;padding-top:12px\">\n // call preFetchLib at entry js file\n (async function(){\n const helMicro = await import('hel-micro');\n await helMicro.preFetchLib('").concat(n.LIB_NAME,"');\n import('./loadApp'); // move your app original entry file content to this file and load it\n })();\n\n /** --------------------------------------------------------------------------- */\n import remoteLib from '").concat(n.LIB_NAME,"';\n remoteLib.num.random(19); // now you can call the remote safely just like local module\n </pre>\n");function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=document.querySelector("#container");t||((t=document.createElement("div")).id="container",document.body.append(t)),t.innerHTML='\n <div style="padding:60px;">\n <h1>Cool, as you see this is your hel remote module\n <a style="color:blue" href="https://github.com/hel-eco/test-hel-tpl-remote-lib-111" target="_blank" rel="noopener noreferrer">'.concat(n.LIB_NAME,'</a>\n </h1>\n <span style="color:red;">you can delete or edit this file, It will only run at master-app mode</span>,\n see the <a href="https://www.bilibili.com/video/BV1Dd4y1y7Wj/?vd_source=51bc50bf5f860e0d778c49b00d192cee" target="_blank" rel="noopener noreferrer">video</a>\n if you want to use local debug feature.\n <br />\n <h2>\n <button onclick="__callMethod__()" style="font-size:20px;background-color:#ff9800;color:white;border:none;padding:6px;">click me</button>\n to see changed result : ').concat(e,"\n </h2>\n <fieldset>\n <legend>usage snippet</legend>\n ").concat(a,'\n </fieldset>\n <p style="font-size:20px">\n <img width="30px" style="vertical-align:middle" src="https://tnfe.gtimg.com/image/1k4xi9izbk_1651642720099.png"></img>\n <a href="https://github.com/tnfe/hel" target="_blank" rel="noopener noreferrer">hel-micro</a>,\n a module federation SDK which is unrelated to tool\uff0cmore details see\n <a href="https://tnfe.github.io/hel/" target="_blank" rel="noopener noreferrer">doc</a>.\n </p>\n </div>\n ')}i()},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"sayHelloToHel",(function(){return i}));var o={};r.r(o),r.d(o,"regs",(function(){return a})),r.d(o,"num",(function(){return u})),r.d(o,"myMod",(function(){return n}));var a=r(2);function i(e){return"hello hel, I am ".concat("",", I come from ").concat(e)}var u=r(3);t.default=o}]]);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*! *****************************************************************************
|
2
|
+
Copyright (c) Microsoft Corporation.
|
3
|
+
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
5
|
+
purpose with or without fee is hereby granted.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
***************************************************************************** */
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! For license information please see main.c27f8348.chunk.js.LICENSE.txt */
|
2
|
+
(this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]||[]).push([[1],[function(t,r,e){t.exports=e(1)},function(t,r,e){"use strict";function n(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(h){return void e(h)}c.done?r(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var r=this,e=arguments;return new Promise((function(o,i){var a=t.apply(r,e);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){i=function(){return t};var t={},r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(k){u=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof f?r:f,i=Object.create(o.prototype),a=new _(n||[]);return i._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return j()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=L(a,e);if(c){if(c===l)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var u=s(t,r,e);if("normal"===u.type){if(n=e.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n="completed",e.method="throw",e.arg=u.arg)}}}(t,e,a),i}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(k){return{type:"throw",arg:k}}}t.wrap=h;var l={};function f(){}function p(){}function v(){}var d={};u(d,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(O([])));g&&g!==r&&e.call(g,o)&&(d=g);var m=v.prototype=f.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function x(t,r){var n;this._invoke=function(o,i){function a(){return new r((function(n,a){!function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&e.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function L(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,L(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function E(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function O(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=v,u(m,"constructor",v),u(v,"constructor",p),p.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new x(h(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=O,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=e.call(i,"catchLoc"),u=e.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),l},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),E(e),l}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;E(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:O(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),l}},t}function a(){return(a=o(i().mark((function t(){var r,n,o,a,c,u;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.e(0).then(e.t.bind(null,7,7));case 2:return r=t.sent,n=r.libReady,o=r.isMasterApp,t.next=7,e.e(0).then(e.bind(null,6));case 7:return a=t.sent,c=a.LIB_NAME,t.next=11,e.e(0).then(e.bind(null,9));case 11:if(u=t.sent,n(c,u.default),!o()){t.next=16;break}return t.next=16,e.e(0).then(e.bind(null,8));case 16:case"end":return t.stop()}}),t)})))).apply(this,arguments)}e.r(r),function(){return a.apply(this,arguments)}().catch(console.error);r.default="HEL REMOTE MOD"}],[[0,2]]]);
|
@@ -0,0 +1 @@
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e){function t(t){for(var n,i,l=t[0],a=t[1],c=t[2],f=0,p=[];f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,c||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==o[a]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={2:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{0:"5c853936"}[e]+".chunk.js"}(e);var a=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(c);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",a.name="ChunkLoadError",a.type=n,a.request=u,r[1](a)}o[e]=void 0}};var c=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="https://unpkg.com/test-hel-tpl-remote-lib-111@0.0.1/hel_dist/",i.oe=function(e){throw console.error(e),e};var l=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]=this["helJsonp_test-hel-tpl-remote-lib-111_1679058373255"]||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var c=0;c<l.length;c++)t(l[c]);var s=a;r()}([]);
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('hel-lib-proxy')) :
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'hel-lib-proxy'], factory) :
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["test-hel-tpl-remote-lib-111"] = {}, global.helLibProxy));
|
5
|
+
})(this, (function (exports, helLibProxy) { 'use strict';
|
6
|
+
|
7
|
+
// import { appGroupName } from '../../package.json'
|
8
|
+
// 如果从 package.json 直接导出 appGroupName
|
9
|
+
// rollup 打包需要配置 @rollup/plugin-json
|
10
|
+
// webpack 打包会把整个 package 对象打到运行代码里
|
11
|
+
const LIB_NAME = 'test-hel-tpl-remote-lib-111';
|
12
|
+
|
13
|
+
const lib = helLibProxy.exposeLib(LIB_NAME);
|
14
|
+
|
15
|
+
exports["default"] = lib;
|
16
|
+
exports.lib = lib;
|
17
|
+
|
18
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
19
|
+
|
20
|
+
}));
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { exposeLib } from 'hel-lib-proxy';
|
2
|
+
|
3
|
+
// import { appGroupName } from '../../package.json'
|
4
|
+
// 如果从 package.json 直接导出 appGroupName
|
5
|
+
// rollup 打包需要配置 @rollup/plugin-json
|
6
|
+
// webpack 打包会把整个 package 对象打到运行代码里
|
7
|
+
const LIB_NAME = 'test-hel-tpl-remote-lib-111';
|
8
|
+
|
9
|
+
const lib = exposeLib(LIB_NAME);
|
10
|
+
|
11
|
+
export { lib as default, lib };
|
package/package.json
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
{
|
2
|
+
"name": "test-hel-tpl-remote-lib-111",
|
3
|
+
"appGroupName": "test-hel-tpl-remote-lib-111",
|
4
|
+
"main": "hel_proxy/entry.js",
|
5
|
+
"module": "hel_proxy_es/entry.js",
|
6
|
+
"unpkg": "hel_dist/index.html",
|
7
|
+
"types": "lib/entrance/libTypes.ts",
|
8
|
+
"version": "0.0.1",
|
9
|
+
"dependencies": {
|
10
|
+
"@types/lodash": "^4.14.182",
|
11
|
+
"hel-lib-proxy": "3.13.2",
|
12
|
+
"hel-micro": "^3.13.7",
|
13
|
+
"lodash": "^4.17.21"
|
14
|
+
},
|
15
|
+
"peerDependencies": {
|
16
|
+
"hel-lib-proxy": "^3.10.2",
|
17
|
+
"hel-micro": "^3.11.6"
|
18
|
+
},
|
19
|
+
"scripts": {
|
20
|
+
"postinstall": "node ./scripts/postinstall.js",
|
21
|
+
"prepublishOnly": "node ./scripts/prepublishOnly.js",
|
22
|
+
"check": "node ./scripts/check",
|
23
|
+
"start": "cross-env PORT=3001 npm run app",
|
24
|
+
"app": "node scripts/start.js",
|
25
|
+
"build_stub": "npm run build && npm run build_bundle",
|
26
|
+
"build": "npm run check_name && npm run build_dist && npm run build_meta && npm run build_proxy",
|
27
|
+
"check_name": "node scripts/check.js",
|
28
|
+
"build_dist": "node scripts/build.js",
|
29
|
+
"build_meta": "node scripts/meta.js",
|
30
|
+
"build_proxy": "npm run build_proxy_umd && npm run build_proxy_es",
|
31
|
+
"build_proxy_umd": "tsc & node ./scripts/replaceToRelativePath.js & rollup -c",
|
32
|
+
"build_proxy_es": "tsc & node ./scripts/replaceToRelativePath.js & cross-env BUILD_ENV=es rollup -c",
|
33
|
+
"build_bundle": "tsc & cross-env BUNDLE=true node ./scripts/replaceToRelativePath.js & cross-env BUNDLE=true node scripts/build.js",
|
34
|
+
"build_cust": "npm run set_home_page \"npm run build\"",
|
35
|
+
"set_home_page": "cross-env-shell HEL_APP_HOME_PAGE=http://127.0.0.1:9001",
|
36
|
+
"lint": "eslint ./src --ext ts,tsx",
|
37
|
+
"lintfix": "eslint ./src --ext ts,tsx --fix",
|
38
|
+
"test": "jest"
|
39
|
+
},
|
40
|
+
"eslintConfig": {
|
41
|
+
"extends": "react-app"
|
42
|
+
},
|
43
|
+
"browserslist": {
|
44
|
+
"production": [
|
45
|
+
">0.2%",
|
46
|
+
"not dead",
|
47
|
+
"not op_mini all"
|
48
|
+
],
|
49
|
+
"development": [
|
50
|
+
"last 1 chrome version",
|
51
|
+
"last 1 firefox version",
|
52
|
+
"last 1 safari version"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
"babel": {
|
56
|
+
"presets": [
|
57
|
+
"react-app"
|
58
|
+
]
|
59
|
+
},
|
60
|
+
"license": "MIT",
|
61
|
+
"devDependencies": {
|
62
|
+
"@babel/core": "7.9.0",
|
63
|
+
"@testing-library/dom": "^8.17.1",
|
64
|
+
"@testing-library/user-event": "^7.1.2",
|
65
|
+
"@types/jest": "^24.9.1",
|
66
|
+
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
67
|
+
"@typescript-eslint/parser": "^4.17.0",
|
68
|
+
"babel-eslint": "10.1.0",
|
69
|
+
"babel-jest": "^24.9.0",
|
70
|
+
"babel-loader": "8.1.0",
|
71
|
+
"babel-plugin-named-asset-import": "^0.3.6",
|
72
|
+
"babel-preset-react-app": "^9.1.2",
|
73
|
+
"case-sensitive-paths-webpack-plugin": "2.3.0",
|
74
|
+
"cross-env": "^7.0.3",
|
75
|
+
"eslint": "^6.8.0",
|
76
|
+
"eslint-loader": "3.0.3",
|
77
|
+
"eslint-plugin-import": "2.20.1",
|
78
|
+
"file-loader": "4.3.0",
|
79
|
+
"fs-extra": "^10.1.0",
|
80
|
+
"hel-dev-utils": "^3.0.1",
|
81
|
+
"html-webpack-plugin": "4.0.0-beta.11",
|
82
|
+
"jest": "24.9.0",
|
83
|
+
"jest-resolve": "24.9.0",
|
84
|
+
"jest-watch-typeahead": "0.4.2",
|
85
|
+
"jsdom": "^20.0.0",
|
86
|
+
"lint-staged": "^10.5.3",
|
87
|
+
"pnp-webpack-plugin": "1.6.4",
|
88
|
+
"react-dev-utils": "^11.0.4",
|
89
|
+
"replace-absolute-path": "^1.0.0",
|
90
|
+
"resolve": "^1.22.1",
|
91
|
+
"resolve-url-loader": "^3.1.2",
|
92
|
+
"rollup": "^2.56.3",
|
93
|
+
"rollup-plugin-terser": "^7.0.2",
|
94
|
+
"rollup-plugin-typescript": "^1.0.1",
|
95
|
+
"terser-webpack-plugin": "2.3.5",
|
96
|
+
"ts-pnp": "1.1.6",
|
97
|
+
"tslib": "^2.4.0",
|
98
|
+
"typescript": "^4.1.3",
|
99
|
+
"url-loader": "2.3.0",
|
100
|
+
"webpack": "4.42.0",
|
101
|
+
"webpack-dev-server": "^3.11.2",
|
102
|
+
"webpack-manifest-plugin": "2.2.0",
|
103
|
+
"workbox-webpack-plugin": "4.3.1"
|
104
|
+
},
|
105
|
+
"files": [
|
106
|
+
"hel_proxy",
|
107
|
+
"hel_proxy_es",
|
108
|
+
"hel_bundle",
|
109
|
+
"hel_dist",
|
110
|
+
"lib",
|
111
|
+
"scripts"
|
112
|
+
]
|
113
|
+
}
|
package/scripts/build.js
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
5
|
+
process.env.BABEL_ENV = 'production';
|
6
|
+
process.env.NODE_ENV = 'production';
|
7
|
+
|
8
|
+
// Makes the script crash on unhandled rejections instead of silently
|
9
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
10
|
+
// terminate the Node.js process with a non-zero exit code.
|
11
|
+
process.on('unhandledRejection', err => {
|
12
|
+
throw err;
|
13
|
+
});
|
14
|
+
|
15
|
+
// Ensure environment variables are read.
|
16
|
+
require('../config/env');
|
17
|
+
|
18
|
+
|
19
|
+
const path = require('path');
|
20
|
+
const chalk = require('react-dev-utils/chalk');
|
21
|
+
const fs = require('fs-extra');
|
22
|
+
const webpack = require('webpack');
|
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 = FileSizeReporter.measureFileSizesBeforeBuild;
|
31
|
+
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
32
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
33
|
+
|
34
|
+
const configFactory = process.env.BUNDLE === 'true'
|
35
|
+
? require('../config/webpackBundle.config')
|
36
|
+
: require('../config/webpack.config');
|
37
|
+
|
38
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
39
|
+
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
40
|
+
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
41
|
+
|
42
|
+
const isInteractive = process.stdout.isTTY;
|
43
|
+
|
44
|
+
// Warn and crash if required files are missing
|
45
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
46
|
+
process.exit(1);
|
47
|
+
}
|
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
|
+
// We used to support resolving modules according to `NODE_PATH`.
|
137
|
+
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
138
|
+
// This lets you use absolute paths in imports inside large monorepos:
|
139
|
+
if (process.env.NODE_PATH) {
|
140
|
+
console.log(
|
141
|
+
chalk.yellow(
|
142
|
+
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
|
143
|
+
)
|
144
|
+
);
|
145
|
+
console.log();
|
146
|
+
}
|
147
|
+
|
148
|
+
console.log('Creating an optimized production build...');
|
149
|
+
|
150
|
+
const compiler = webpack(config);
|
151
|
+
return new Promise((resolve, reject) => {
|
152
|
+
compiler.run((err, stats) => {
|
153
|
+
let messages;
|
154
|
+
if (err) {
|
155
|
+
if (!err.message) {
|
156
|
+
return reject(err);
|
157
|
+
}
|
158
|
+
|
159
|
+
let errMessage = err.message;
|
160
|
+
|
161
|
+
// Add additional information for postcss errors
|
162
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
163
|
+
errMessage +=
|
164
|
+
'\nCompileError: Begins at CSS selector ' +
|
165
|
+
err['postcssNode'].selector;
|
166
|
+
}
|
167
|
+
|
168
|
+
messages = formatWebpackMessages({
|
169
|
+
errors: [errMessage],
|
170
|
+
warnings: [],
|
171
|
+
});
|
172
|
+
} else {
|
173
|
+
messages = formatWebpackMessages(
|
174
|
+
stats.toJson({ all: false, warnings: true, errors: true })
|
175
|
+
);
|
176
|
+
}
|
177
|
+
if (messages.errors.length) {
|
178
|
+
// Only keep the first error. Others are often indicative
|
179
|
+
// of the same problem, but confuse the reader with noise.
|
180
|
+
if (messages.errors.length > 1) {
|
181
|
+
messages.errors.length = 1;
|
182
|
+
}
|
183
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
184
|
+
}
|
185
|
+
if (
|
186
|
+
process.env.CI &&
|
187
|
+
(typeof process.env.CI !== 'string' ||
|
188
|
+
process.env.CI.toLowerCase() !== 'false') &&
|
189
|
+
messages.warnings.length
|
190
|
+
) {
|
191
|
+
console.log(
|
192
|
+
chalk.yellow(
|
193
|
+
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
194
|
+
'Most CI servers set it automatically.\n'
|
195
|
+
)
|
196
|
+
);
|
197
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
198
|
+
}
|
199
|
+
|
200
|
+
return resolve({
|
201
|
+
stats,
|
202
|
+
previousFileSizes,
|
203
|
+
warnings: messages.warnings,
|
204
|
+
});
|
205
|
+
});
|
206
|
+
});
|
207
|
+
}
|
208
|
+
|
209
|
+
function copyPublicFolder() {
|
210
|
+
fs.copySync(paths.appPublic, paths.appBuild, {
|
211
|
+
dereference: true,
|
212
|
+
filter: file => file !== paths.appHtml,
|
213
|
+
});
|
214
|
+
}
|
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 subApp = require('../config/subApp');
|
13
|
+
|
14
|
+
helDevUtils.extractHelMetaJson({
|
15
|
+
subApp,
|
16
|
+
buildDirFullPath: path.join(__dirname, '../hel_dist'),
|
17
|
+
packageJson,
|
18
|
+
}).catch(err => {
|
19
|
+
console.error(err);
|
20
|
+
process.exit(-1);
|
21
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
console.log('---------------------------------------------------------------------------------------');
|
3
|
+
console.log('| ');
|
4
|
+
console.log('| Welcome to use hel remote module');
|
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 module.');
|
8
|
+
console.log('| see https://github.com/tnfe/hel to know more details of hel-micro');
|
9
|
+
console.log('| ');
|
10
|
+
console.log('---------------------------------------------------------------------------------------');
|
11
|
+
|
@@ -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,34 @@
|
|
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 replacer = require('replace-absolute-path');
|
14
|
+
const path = require('path');
|
15
|
+
|
16
|
+
(async function () {
|
17
|
+
const srcDir = process.env.BUNDLE === 'true' ? path.resolve(__dirname, '../lib-js') : path.resolve(__dirname, '../src');
|
18
|
+
const libDir = process.env.BUNDLE === 'true' ? path.resolve(__dirname, '../lib-js') : path.resolve(__dirname, '../lib');
|
19
|
+
const strList = libDir.split('/');
|
20
|
+
const libDirShortName = strList[strList.length - 1];
|
21
|
+
|
22
|
+
await replacer({
|
23
|
+
inputDir: srcDir,
|
24
|
+
outputDir: libDir,
|
25
|
+
afterReplaced() {
|
26
|
+
console.log('----------------------------------------------------------------------------------');
|
27
|
+
console.log(`| all files import statements been transformed to relative path for ${libDirShortName} ^_^!`);
|
28
|
+
console.log('----------------------------------------------------------------------------------');
|
29
|
+
},
|
30
|
+
});
|
31
|
+
})()
|
32
|
+
|
33
|
+
|
34
|
+
// console.log(getAllFilePath(path.resolve(__dirname, './src')))
|
package/scripts/start.js
ADDED
@@ -0,0 +1,166 @@
|
|
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 = 'development';
|
5
|
+
process.env.NODE_ENV = 'development';
|
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
|
+
|
18
|
+
const fs = require('fs');
|
19
|
+
const chalk = require('react-dev-utils/chalk');
|
20
|
+
const webpack = require('webpack');
|
21
|
+
const WebpackDevServer = require('webpack-dev-server');
|
22
|
+
const clearConsole = require('react-dev-utils/clearConsole');
|
23
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
24
|
+
const {
|
25
|
+
choosePort,
|
26
|
+
createCompiler,
|
27
|
+
prepareProxy,
|
28
|
+
prepareUrls,
|
29
|
+
} = require('react-dev-utils/WebpackDevServerUtils');
|
30
|
+
const openBrowser = require('react-dev-utils/openBrowser');
|
31
|
+
const paths = require('../config/paths');
|
32
|
+
const configFactory = require('../config/webpack.config');
|
33
|
+
const createDevServerConfig = require('../config/webpackDevServer.config');
|
34
|
+
|
35
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
36
|
+
const isInteractive = process.stdout.isTTY;
|
37
|
+
|
38
|
+
// Warn and crash if required files are missing
|
39
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
40
|
+
process.exit(1);
|
41
|
+
}
|
42
|
+
|
43
|
+
// Tools like Cloud9 rely on this.
|
44
|
+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
45
|
+
const HOST = process.env.HOST || '0.0.0.0';
|
46
|
+
|
47
|
+
if (process.env.HOST) {
|
48
|
+
console.log(
|
49
|
+
chalk.cyan(
|
50
|
+
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
51
|
+
chalk.bold(process.env.HOST)
|
52
|
+
)}`
|
53
|
+
)
|
54
|
+
);
|
55
|
+
console.log(
|
56
|
+
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
57
|
+
);
|
58
|
+
console.log(
|
59
|
+
`Learn more here: ${chalk.yellow('https://bit.ly/CRA-advanced-config')}`
|
60
|
+
);
|
61
|
+
console.log();
|
62
|
+
}
|
63
|
+
|
64
|
+
// We require that you explicitly set browsers and do not fall back to
|
65
|
+
// browserslist defaults.
|
66
|
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
67
|
+
checkBrowsers(paths.appPath, isInteractive)
|
68
|
+
.then(() => {
|
69
|
+
// We attempt to use the default port but if it is busy, we offer the user to
|
70
|
+
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
71
|
+
return choosePort(HOST, DEFAULT_PORT);
|
72
|
+
})
|
73
|
+
.then(port => {
|
74
|
+
if (port == null) {
|
75
|
+
// We have not found a port.
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
const config = configFactory('development');
|
80
|
+
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
81
|
+
const appName = require(paths.appPackageJson).name;
|
82
|
+
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
83
|
+
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
84
|
+
const urls = prepareUrls(
|
85
|
+
protocol,
|
86
|
+
HOST,
|
87
|
+
port,
|
88
|
+
paths.publicUrlOrPath.slice(0, -1)
|
89
|
+
);
|
90
|
+
const devSocket = {
|
91
|
+
warnings: warnings =>
|
92
|
+
devServer.sockWrite(devServer.sockets, 'warnings', warnings),
|
93
|
+
errors: errors =>
|
94
|
+
devServer.sockWrite(devServer.sockets, 'errors', errors),
|
95
|
+
};
|
96
|
+
// Create a webpack compiler that is configured with custom messages.
|
97
|
+
const compiler = createCompiler({
|
98
|
+
appName,
|
99
|
+
config,
|
100
|
+
devSocket,
|
101
|
+
urls,
|
102
|
+
useYarn,
|
103
|
+
useTypeScript,
|
104
|
+
tscCompileOnError,
|
105
|
+
webpack,
|
106
|
+
});
|
107
|
+
// Load proxy config
|
108
|
+
const proxySetting = require(paths.appPackageJson).proxy;
|
109
|
+
const proxyConfig = prepareProxy(
|
110
|
+
proxySetting,
|
111
|
+
paths.appPublic,
|
112
|
+
paths.publicUrlOrPath
|
113
|
+
);
|
114
|
+
// Serve webpack assets generated by the compiler over a web server.
|
115
|
+
const serverConfig = createDevServerConfig(
|
116
|
+
proxyConfig,
|
117
|
+
urls.lanUrlForConfig
|
118
|
+
);
|
119
|
+
const devServer = new WebpackDevServer(compiler, serverConfig);
|
120
|
+
// Launch WebpackDevServer.
|
121
|
+
devServer.listen(port, HOST, err => {
|
122
|
+
if (err) {
|
123
|
+
return console.log(err);
|
124
|
+
}
|
125
|
+
if (isInteractive) {
|
126
|
+
clearConsole();
|
127
|
+
}
|
128
|
+
|
129
|
+
// We used to support resolving modules according to `NODE_PATH`.
|
130
|
+
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
131
|
+
// This lets you use absolute paths in imports inside large monorepos:
|
132
|
+
if (process.env.NODE_PATH) {
|
133
|
+
console.log(
|
134
|
+
chalk.yellow(
|
135
|
+
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
|
136
|
+
)
|
137
|
+
);
|
138
|
+
console.log();
|
139
|
+
}
|
140
|
+
|
141
|
+
console.log(chalk.cyan('Starting the development server...\n'));
|
142
|
+
openBrowser(urls.localUrlForBrowser);
|
143
|
+
});
|
144
|
+
|
145
|
+
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
146
|
+
process.on(sig, function() {
|
147
|
+
devServer.close();
|
148
|
+
process.exit();
|
149
|
+
});
|
150
|
+
});
|
151
|
+
|
152
|
+
if (isInteractive || process.env.CI !== 'true') {
|
153
|
+
// Gracefully exit when stdin ends
|
154
|
+
process.stdin.on('end', function() {
|
155
|
+
devServer.close();
|
156
|
+
process.exit();
|
157
|
+
});
|
158
|
+
process.stdin.resume();
|
159
|
+
}
|
160
|
+
})
|
161
|
+
.catch(err => {
|
162
|
+
if (err && err.message) {
|
163
|
+
console.log(err.message);
|
164
|
+
}
|
165
|
+
process.exit(1);
|
166
|
+
});
|
package/scripts/test.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
5
|
+
process.env.BABEL_ENV = 'test';
|
6
|
+
process.env.NODE_ENV = 'test';
|
7
|
+
process.env.PUBLIC_URL = '';
|
8
|
+
|
9
|
+
// Makes the script crash on unhandled rejections instead of silently
|
10
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
11
|
+
// terminate the Node.js process with a non-zero exit code.
|
12
|
+
process.on('unhandledRejection', err => {
|
13
|
+
throw err;
|
14
|
+
});
|
15
|
+
|
16
|
+
// Ensure environment variables are read.
|
17
|
+
require('../config/env');
|
18
|
+
|
19
|
+
|
20
|
+
const jest = require('jest');
|
21
|
+
const execSync = require('child_process').execSync;
|
22
|
+
let argv = process.argv.slice(2);
|
23
|
+
|
24
|
+
function isInGitRepository() {
|
25
|
+
try {
|
26
|
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
27
|
+
return true;
|
28
|
+
} catch (e) {
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
function isInMercurialRepository() {
|
34
|
+
try {
|
35
|
+
execSync('hg --cwd . root', { stdio: 'ignore' });
|
36
|
+
return true;
|
37
|
+
} catch (e) {
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Watch unless on CI or explicitly running all tests
|
43
|
+
if (
|
44
|
+
!process.env.CI &&
|
45
|
+
argv.indexOf('--watchAll') === -1 &&
|
46
|
+
argv.indexOf('--watchAll=false') === -1
|
47
|
+
) {
|
48
|
+
// https://github.com/facebook/create-react-app/issues/5210
|
49
|
+
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
50
|
+
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
jest.run(argv);
|