diff --git a/examples/react16/package.json b/examples/react16/package.json index 19ce6d9d..116496b2 100644 --- a/examples/react16/package.json +++ b/examples/react16/package.json @@ -27,6 +27,11 @@ "eslint-webpack-plugin": "^3.1.1", "file-loader": "^6.2.0", "fs-extra": "^10.0.0", + "hel-lodash": "^2.1.7", + "hel-micro": "^4.8.11", + "hel-micro-core": "^4.8.11", + "hel-micro-react": "^4.8.10", + "hel-types": "^4.3.3", "html-webpack-plugin": "^5.5.0", "identity-obj-proxy": "^3.0.0", "jest": "^27.4.3", diff --git a/examples/react16/src/App.js b/examples/react16/src/App.js index 46fe42ee..0ab60552 100644 --- a/examples/react16/src/App.js +++ b/examples/react16/src/App.js @@ -5,6 +5,8 @@ import Location from "./Location"; import Communication from "./Communication"; import React17 from "./nest"; import Font from "./Font"; +import RemoteComp from "./RemoteComp"; +import RemoteFnCall from "./RemoteFnCall"; import logo from "./logo.svg"; import Tag from "antd/es/tag"; import Button from "antd/es/button"; @@ -49,7 +51,8 @@ export default function App() {
@@ -75,6 +78,12 @@ export default function App() { + + + + + + diff --git a/examples/react16/src/RemoteComp.js b/examples/react16/src/RemoteComp.js new file mode 100644 index 00000000..eb44d6dc --- /dev/null +++ b/examples/react16/src/RemoteComp.js @@ -0,0 +1,17 @@ +import React from "react"; +import { useRemoteComp } from 'hel-micro-react'; + +export default function RemoteComp() { + const Comp = useRemoteComp( + // see https://github.com/hel-e co/hel-tpl-remote-react-comp + "hel-tpl-remote-react-comps", + // see https://github.com/hel-eco/hel-tpl-remote-react-comp-ts + // "hel-tpl-remote-react-comps-ts", + "HelloRemoteReactComp", + { versionId: "1.3.2" } + ); + return
+

这是一个懒加载的远程react组件

+ +
; +} diff --git a/examples/react16/src/RemoteFnCall.js b/examples/react16/src/RemoteFnCall.js new file mode 100644 index 00000000..87440ddb --- /dev/null +++ b/examples/react16/src/RemoteFnCall.js @@ -0,0 +1,19 @@ +import React from "react"; +import m from 'hel-lodash'; + +export default function RemoteComp() { + const [tip, setTip] = React.useState(''); + const changeTip = () => { + setTip(`${m.myUtils.myMod.sayHelloToHel()}_${Date.now()}`); + }; + + + return
+

这是一个预加载的远程方法调用示例:

+

lodash version is: {m.VERSION}

+

tip is: {tip}

+ +
; +} diff --git a/examples/react16/src/index.js b/examples/react16/src/index.js index 91e27435..1d1bba77 100644 --- a/examples/react16/src/index.js +++ b/examples/react16/src/index.js @@ -1,29 +1,10 @@ import React from "react"; import ReactDOM from "react-dom"; -import App from "./App"; -import { BrowserRouter } from "react-router-dom"; -import "./styles.css"; +import { bindReactRuntime, preFetchLib } from 'hel-micro'; -const basename = process.env.NODE_ENV === "production" ? "/demo-react16/" : ""; +bindReactRuntime({ React, ReactDOM }); -if (window.__POWERED_BY_WUJIE__) { - // eslint-disable-next-line no-undef - window.__WUJIE_MOUNT = () => { - ReactDOM.render( - - - , - document.getElementById("root") - ); - }; - window.__WUJIE_UNMOUNT = () => { - ReactDOM.unmountComponentAtNode(document.getElementById("root")); - }; -} else { - ReactDOM.render( - - - , - document.getElementById("root") - ); -} +(async function () { + await preFetchLib('hel-lodash','2.3.0'); // 预加载 hel-lodash,方便其他地方可以静态导入 hel-lodash + await import('./loadApp'); +})().catch(console.error); diff --git a/examples/react16/src/loadApp.js b/examples/react16/src/loadApp.js new file mode 100644 index 00000000..d8d47ca1 --- /dev/null +++ b/examples/react16/src/loadApp.js @@ -0,0 +1,30 @@ +import React from "react"; +import ReactDOM from "react-dom"; +import App from "./App"; +import { BrowserRouter } from "react-router-dom"; +import "./styles.css"; + +const basename = process.env.NODE_ENV === "production" ? "/demo-react16/" : ""; + +if (window.__POWERED_BY_WUJIE__) { + // eslint-disable-next-line no-undef + window.__WUJIE_MOUNT = () => { + ReactDOM.render( + + + , + document.getElementById("root") + ); + }; + window.__WUJIE_UNMOUNT = () => { + ReactDOM.unmountComponentAtNode(document.getElementById("root")); + }; + window.__WUJIE.mount(); +} else { + ReactDOM.render( + + + , + document.getElementById("root") + ); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e188b030..f8ab294d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -144,7 +144,7 @@ importers: webpack-dev-server: ^4.6.0 webpack-manifest-plugin: ^4.0.2 workbox-webpack-plugin: ^6.4.1 - wujie-react: ^1.0.0-rc.15 + wujie-react: workspace:^1.0.0-rc.23 dependencies: '@ant-design/icons': 4.7.0_sfoxds7t5ydpegc3knd667wn6m '@babel/core': 7.18.13 @@ -221,8 +221,8 @@ importers: vue: ^2.6.11 vue-router: ^3.2.0 vue-template-compiler: ^2.6.11 - wujie: ^1.0.0-rc.15 - wujie-vue2: ^1.0.0-rc.15 + wujie: workspace:^1.0.0-rc.23 + wujie-vue2: workspace:^1.0.0-rc.23 dependencies: ant-design-vue: 1.7.8_42puyn3dcxirnpdjnosl7pbb6a core-js: 3.25.0 @@ -269,6 +269,11 @@ importers: eslint-webpack-plugin: ^3.1.1 file-loader: ^6.2.0 fs-extra: ^10.0.0 + hel-lodash: ^2.1.7 + hel-micro: ^4.8.11 + hel-micro-core: ^4.8.11 + hel-micro-react: ^4.8.10 + hel-types: ^4.3.3 html-webpack-plugin: ^5.5.0 identity-obj-proxy: ^3.0.0 jest: ^27.4.3 @@ -301,7 +306,7 @@ importers: webpack-dev-server: ^4.6.0 webpack-manifest-plugin: ^4.0.2 workbox-webpack-plugin: ^6.4.1 - wujie-react: ^1.0.0-rc.15 + wujie-react: workspace:^1.0.0-rc.23 dependencies: '@babel/core': 7.18.13 '@pmmmwh/react-refresh-webpack-plugin': 0.5.7_wt5p3h66kg5yz5633zrrqkcxnm @@ -327,6 +332,11 @@ importers: eslint-webpack-plugin: 3.2.0_skpnekq7gq3zdkwzxpcrmjcczy file-loader: 6.2.0_webpack@5.74.0 fs-extra: 10.1.0 + hel-lodash: 2.1.7_l3m2cjn4pyyrginxem3qizdjcy + hel-micro: 4.8.11_l3m2cjn4pyyrginxem3qizdjcy + hel-micro-core: 4.8.11_hel-types@4.3.3 + hel-micro-react: 4.8.10_hbwf4fannmhs2gqwkj3zph6isu + hel-types: 4.3.3 html-webpack-plugin: 5.5.0_webpack@5.74.0 identity-obj-proxy: 3.0.0 jest: 27.5.1 @@ -681,7 +691,7 @@ importers: prop-types: ^15.8.1 webpack: ^5.61.0 webpack-cli: ^4.9.1 - wujie: ^1.0.0-rc.15 + wujie: workspace:^1.0.0-rc.23 dependencies: prop-types: 15.8.1 wujie: link:../wujie-core @@ -708,7 +718,7 @@ importers: eslint-plugin-vue: ^8.0.3 webpack: ^5.61.0 webpack-cli: ^4.9.1 - wujie: ^1.0.0-rc.15 + wujie: workspace:^1.0.0-rc.23 dependencies: wujie: link:../wujie-core devDependencies: @@ -734,7 +744,7 @@ importers: vue: ^3.0.0 webpack: ^5.61.0 webpack-cli: ^4.9.1 - wujie: ^1.0.0-rc.15 + wujie: workspace:^1.0.0-rc.23 dependencies: wujie: link:../wujie-core devDependencies: @@ -6538,7 +6548,7 @@ packages: lru-cache: 6.0.0 mkdirp: 1.0.4 npm-pick-manifest: 6.1.1 - promise-inflight: 1.0.1 + promise-inflight: 1.0.1_bluebird@3.7.2 promise-retry: 2.0.1 semver: 7.3.5 which: 2.0.2 @@ -8383,7 +8393,7 @@ packages: '@vue/cli-service': ^3.0.0 || ^4.0.0-0 eslint: '>= 1.6.0 < 7.0.0' dependencies: - '@vue/cli-service': 4.5.19_42puyn3dcxirnpdjnosl7pbb6a + '@vue/cli-service': 4.5.19_lkq4ousnc7vzls4uafs2kgxwfm '@vue/cli-shared-utils': 4.5.19 eslint: 6.8.0 eslint-loader: 2.2.1_pfvmeq6opgydpezktw7j2dwffi @@ -8422,7 +8432,7 @@ packages: peerDependencies: '@vue/cli-service': ^3.0.0 || ^4.0.0-0 dependencies: - '@vue/cli-service': 4.5.19_42puyn3dcxirnpdjnosl7pbb6a + '@vue/cli-service': 4.5.19_lkq4ousnc7vzls4uafs2kgxwfm '@vue/cli-shared-utils': 4.5.19 dev: true @@ -8431,7 +8441,7 @@ packages: peerDependencies: '@vue/cli-service': ^3.0.0 || ^4.0.0-0 dependencies: - '@vue/cli-service': 4.5.19_42puyn3dcxirnpdjnosl7pbb6a + '@vue/cli-service': 4.5.19_lkq4ousnc7vzls4uafs2kgxwfm dev: true /@vue/cli-service/4.5.19_42puyn3dcxirnpdjnosl7pbb6a: @@ -11006,7 +11016,7 @@ packages: mississippi: 3.0.0 mkdirp: 0.5.6 move-concurrently: 1.0.1 - promise-inflight: 1.0.1 + promise-inflight: 1.0.1_bluebird@3.7.2 rimraf: 2.7.1 ssri: 6.0.2 unique-filename: 1.1.1 @@ -11028,7 +11038,7 @@ packages: minipass-pipeline: 1.2.4 mkdirp: 1.0.4 p-map: 4.0.0 - promise-inflight: 1.0.1 + promise-inflight: 1.0.1_bluebird@3.7.2 rimraf: 3.0.2 ssri: 8.0.1 tar: 6.1.11 @@ -11054,7 +11064,7 @@ packages: minipass-pipeline: 1.2.4 mkdirp: 1.0.4 p-map: 4.0.0 - promise-inflight: 1.0.1 + promise-inflight: 1.0.1_bluebird@3.7.2 rimraf: 3.0.2 ssri: 8.0.1 tar: 6.1.11 @@ -15898,7 +15908,7 @@ packages: resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} engines: {node: '>= 4.0'} os: [darwin] - deprecated: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. + deprecated: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 requiresBuild: true dependencies: bindings: 1.5.0 @@ -16406,6 +16416,75 @@ packages: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true + /hel-html-parser/1.1.2: + resolution: {integrity: sha512-fbkzG7LkkDB/GHozwom+8h8EqMs3m4xDgAxvf7KV9JvweoaVOST0asrqClDNqym/VpewivJ2EruBs6iO3zxskg==} + dependencies: + hel-types: 4.3.3 + dev: false + + /hel-lib-proxy/3.9.3_l3m2cjn4pyyrginxem3qizdjcy: + resolution: {integrity: sha512-VH9iIJjVcFMoQjaJYe/o2Ds/PTXiGL21HdkkRcV7Z8VedfPSBEH3BL/xyey31ujuo/qEIpKLMyL+DUH7QR/4IQ==} + peerDependencies: + hel-micro-core: '>=3.9.3' + hel-types: '>=3.7.0' + dependencies: + hel-micro-core: 4.8.11_hel-types@4.3.3 + hel-types: 4.3.3 + dev: false + + /hel-lodash/2.1.7_l3m2cjn4pyyrginxem3qizdjcy: + resolution: {integrity: sha512-YICHkHFmRDnntKRcspW+g6kCBGZwUI3ZOD/YcWbqpCd9h08MRRsrpZVendMZHdyi83t0WW7XJ8HHaAJpxcFd3A==} + requiresBuild: true + dependencies: + '@types/lodash': 4.14.184 + hel-lib-proxy: 3.9.3_l3m2cjn4pyyrginxem3qizdjcy + lodash: 4.17.21 + transitivePeerDependencies: + - hel-micro-core + - hel-types + dev: false + + /hel-micro-core/4.8.11_hel-types@4.3.3: + resolution: {integrity: sha512-p7brqaGdEdxMsyE85K7EBqNXiPFwtll/0MCkJt+9tOcoDnmXEJIdh4nV5ne/0jsFJKeF2frm+A8LxjXOnilieA==} + peerDependencies: + hel-types: ^4.3.3 + dependencies: + hel-types: 4.3.3 + dev: false + + /hel-micro-react/4.8.10_hbwf4fannmhs2gqwkj3zph6isu: + resolution: {integrity: sha512-/sgS/158wJxXjW7nlwPG5wNMAwFOiS/iU8OtP55qW9oNanlwbZZLbrgDN2H5jf1r3MCOE07YCiGt0aHBVXeRfA==} + peerDependencies: + hel-micro: ^4.8.11 + hel-micro-core: ^4.8.7 + hel-types: ^4.3.3 + react: '>=16.10.2' + react-dom: '>=16.10.2' + dependencies: + '@types/react': 17.0.48 + '@types/react-dom': 17.0.17 + hel-micro: 4.8.11_l3m2cjn4pyyrginxem3qizdjcy + hel-micro-core: 4.8.11_hel-types@4.3.3 + hel-types: 4.3.3 + react: 16.13.1 + react-dom: 16.13.1_react@16.13.1 + dev: false + + /hel-micro/4.8.11_l3m2cjn4pyyrginxem3qizdjcy: + resolution: {integrity: sha512-mmiZBuwnzvjl6OxJ2d1zAksJt/SE6opl33sKMNoFXTW7vUdBr/t6nfZeKYO09qw+5Jz54t8nont1kFY4YecvnQ==} + peerDependencies: + hel-micro-core: ^4.8.7 + hel-types: ^4.3.3 + dependencies: + hel-html-parser: 1.1.2 + hel-micro-core: 4.8.11_hel-types@4.3.3 + hel-types: 4.3.3 + dev: false + + /hel-types/4.3.3: + resolution: {integrity: sha512-Oluh82FIi0XvM1kfXYpYqZ9j70hHVrLEDEeWc3Hf9yl1eYDKBlomTXppXN7cQN9yn82+3Mk7BYrJx8D/Y63CjA==} + dev: false + /hex-color-regex/1.1.0: resolution: {integrity: sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==} @@ -22575,6 +22654,17 @@ packages: peerDependenciesMeta: bluebird: optional: true + dev: true + + /promise-inflight/1.0.1_bluebird@3.7.2: + resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==} + peerDependencies: + bluebird: '*' + peerDependenciesMeta: + bluebird: + optional: true + dependencies: + bluebird: 3.7.2 /promise-retry/2.0.1: resolution: {integrity: sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==}