From e72b7d26650c8fd80e6d5eae499a91cbacb19d4c Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Wed, 11 May 2022 16:55:28 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20plugin-qiankun=E7=9A=84demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examples/app1/.eslintrc.js | 14 -- .../examples/app1/.gitignore | 11 - .../fes-plugin-qiankun/examples/app1/LICENSE | 21 -- .../examples/main/.eslintrc.js | 14 -- .../examples/main/.gitignore | 11 - .../fes-plugin-qiankun/examples/main/LICENSE | 21 -- .../examples/{app1 => micro}/.env | 0 .../examples/{app1 => micro}/.fes.js | 2 - .../examples/{app1 => micro}/package.json | 2 +- .../examples/{app1 => micro}/src/app.js | 14 +- .../src/components/PageLoading.vue | 9 +- .../examples/{app1 => micro}/src/global.css | 0 .../{app1 => micro}/src/images/icon.png | Bin .../app1 => micro/src/pages/micro}/index.vue | 12 +- .../app1 => micro/src/pages/micro}/test.vue | 12 +- .../examples/{app1 => micro}/tsconfig.json | 0 .../examples/{main => vite-main}/.env | 0 .../examples/vite-main/.fes.js | 44 ++++ .../examples/vite-main/index.html | 17 ++ .../examples/{main => vite-main}/package.json | 1 - .../src/app.js => vite-main/src/app.jsx} | 4 +- .../src/components/PageLoading.vue | 9 +- .../{main => vite-main}/src/global.css | 0 .../{main => vite-main}/src/images/icon.png | Bin .../src/pages/app1/index.vue | 4 +- .../src/pages/app1/test.vue | 4 +- .../{main => vite-main}/src/pages/index.vue | 16 +- .../{main => vite-main}/tsconfig.json | 0 .../examples/webpack-main/.env | 1 + .../examples/{main => webpack-main}/.fes.js | 9 +- .../examples/webpack-main/package.json | 51 +++++ .../examples/webpack-main/src/app.jsx | 15 ++ .../src/components/PageLoading.vue | 29 +++ .../examples/webpack-main/src/global.css | 3 + .../examples/webpack-main/src/images/icon.png | Bin 0 -> 5586 bytes .../examples/webpack-main/src/pages/index.vue | 41 ++++ .../webpack-main/src/pages/micro/index.vue | 7 + .../webpack-main/src/pages/micro/test.vue | 7 + .../examples/webpack-main/tsconfig.json | 37 ++++ packages/fes-plugin-qiankun/package.json | 5 +- .../fes-plugin-qiankun/src/micro/index.js | 209 +++++++++--------- 41 files changed, 403 insertions(+), 253 deletions(-) delete mode 100644 packages/fes-plugin-qiankun/examples/app1/.eslintrc.js delete mode 100644 packages/fes-plugin-qiankun/examples/app1/.gitignore delete mode 100644 packages/fes-plugin-qiankun/examples/app1/LICENSE delete mode 100644 packages/fes-plugin-qiankun/examples/main/.eslintrc.js delete mode 100644 packages/fes-plugin-qiankun/examples/main/.gitignore delete mode 100644 packages/fes-plugin-qiankun/examples/main/LICENSE rename packages/fes-plugin-qiankun/examples/{app1 => micro}/.env (100%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/.fes.js (99%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/package.json (98%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/src/app.js (66%) rename packages/fes-plugin-qiankun/examples/{main => micro}/src/components/PageLoading.vue (86%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/src/global.css (100%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/src/images/icon.png (100%) rename packages/fes-plugin-qiankun/examples/{app1/src/pages/app1 => micro/src/pages/micro}/index.vue (54%) rename packages/fes-plugin-qiankun/examples/{app1/src/pages/app1 => micro/src/pages/micro}/test.vue (54%) rename packages/fes-plugin-qiankun/examples/{app1 => micro}/tsconfig.json (100%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/.env (100%) create mode 100644 packages/fes-plugin-qiankun/examples/vite-main/.fes.js create mode 100644 packages/fes-plugin-qiankun/examples/vite-main/index.html rename packages/fes-plugin-qiankun/examples/{main => vite-main}/package.json (96%) rename packages/fes-plugin-qiankun/examples/{main/src/app.js => vite-main/src/app.jsx} (84%) rename packages/fes-plugin-qiankun/examples/{app1 => vite-main}/src/components/PageLoading.vue (86%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/src/global.css (100%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/src/images/icon.png (100%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/src/pages/app1/index.vue (52%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/src/pages/app1/test.vue (53%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/src/pages/index.vue (66%) rename packages/fes-plugin-qiankun/examples/{main => vite-main}/tsconfig.json (100%) create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/.env rename packages/fes-plugin-qiankun/examples/{main => webpack-main}/.fes.js (84%) create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/package.json create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/app.jsx create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/components/PageLoading.vue create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/global.css create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/images/icon.png create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/pages/index.vue create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/index.vue create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/test.vue create mode 100644 packages/fes-plugin-qiankun/examples/webpack-main/tsconfig.json diff --git a/packages/fes-plugin-qiankun/examples/app1/.eslintrc.js b/packages/fes-plugin-qiankun/examples/app1/.eslintrc.js deleted file mode 100644 index 6300816f..00000000 --- a/packages/fes-plugin-qiankun/examples/app1/.eslintrc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - extends: ['@webank/eslint-config-webank/vue.js'], - overrides: [ - { - files: [ - '**/__tests__/*.{j,t}s?(x)', - '**/tests/unit/**/*.spec.{j,t}s?(x)' - ] - } - ], - env: { - jest: true - } -}; diff --git a/packages/fes-plugin-qiankun/examples/app1/.gitignore b/packages/fes-plugin-qiankun/examples/app1/.gitignore deleted file mode 100644 index df903b98..00000000 --- a/packages/fes-plugin-qiankun/examples/app1/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.DS_Store - -# dependencies -/node_modules -/coverage - -# fes -/src/.fes -/src/.fes-production -/src/.fes-test -/.env.local diff --git a/packages/fes-plugin-qiankun/examples/app1/LICENSE b/packages/fes-plugin-qiankun/examples/app1/LICENSE deleted file mode 100644 index 0978fbf7..00000000 --- a/packages/fes-plugin-qiankun/examples/app1/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020-present webank - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/fes-plugin-qiankun/examples/main/.eslintrc.js b/packages/fes-plugin-qiankun/examples/main/.eslintrc.js deleted file mode 100644 index 6300816f..00000000 --- a/packages/fes-plugin-qiankun/examples/main/.eslintrc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - extends: ['@webank/eslint-config-webank/vue.js'], - overrides: [ - { - files: [ - '**/__tests__/*.{j,t}s?(x)', - '**/tests/unit/**/*.spec.{j,t}s?(x)' - ] - } - ], - env: { - jest: true - } -}; diff --git a/packages/fes-plugin-qiankun/examples/main/.gitignore b/packages/fes-plugin-qiankun/examples/main/.gitignore deleted file mode 100644 index df903b98..00000000 --- a/packages/fes-plugin-qiankun/examples/main/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.DS_Store - -# dependencies -/node_modules -/coverage - -# fes -/src/.fes -/src/.fes-production -/src/.fes-test -/.env.local diff --git a/packages/fes-plugin-qiankun/examples/main/LICENSE b/packages/fes-plugin-qiankun/examples/main/LICENSE deleted file mode 100644 index 0978fbf7..00000000 --- a/packages/fes-plugin-qiankun/examples/main/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020-present webank - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/fes-plugin-qiankun/examples/app1/.env b/packages/fes-plugin-qiankun/examples/micro/.env similarity index 100% rename from packages/fes-plugin-qiankun/examples/app1/.env rename to packages/fes-plugin-qiankun/examples/micro/.env diff --git a/packages/fes-plugin-qiankun/examples/app1/.fes.js b/packages/fes-plugin-qiankun/examples/micro/.fes.js similarity index 99% rename from packages/fes-plugin-qiankun/examples/app1/.fes.js rename to packages/fes-plugin-qiankun/examples/micro/.fes.js index 4540b6ee..42588498 100644 --- a/packages/fes-plugin-qiankun/examples/app1/.fes.js +++ b/packages/fes-plugin-qiankun/examples/micro/.fes.js @@ -1,6 +1,4 @@ // .fes.js 只负责管理编译时配置,只能使用plain Object - - export default { qiankun: { micro: {} diff --git a/packages/fes-plugin-qiankun/examples/app1/package.json b/packages/fes-plugin-qiankun/examples/micro/package.json similarity index 98% rename from packages/fes-plugin-qiankun/examples/app1/package.json rename to packages/fes-plugin-qiankun/examples/micro/package.json index 5c19aa38..05012303 100644 --- a/packages/fes-plugin-qiankun/examples/app1/package.json +++ b/packages/fes-plugin-qiankun/examples/micro/package.json @@ -1,5 +1,5 @@ { - "name": "app1", + "name": "micro", "version": "2.0.0", "description": "fes项目模版", "scripts": { diff --git a/packages/fes-plugin-qiankun/examples/app1/src/app.js b/packages/fes-plugin-qiankun/examples/micro/src/app.js similarity index 66% rename from packages/fes-plugin-qiankun/examples/app1/src/app.js rename to packages/fes-plugin-qiankun/examples/micro/src/app.js index 02d3cb29..7ccef9a4 100644 --- a/packages/fes-plugin-qiankun/examples/app1/src/app.js +++ b/packages/fes-plugin-qiankun/examples/micro/src/app.js @@ -1,4 +1,4 @@ -import PageLoading from '@/components/PageLoading'; +import PageLoading from '@/components/PageLoading.vue'; export const beforeRender = { loading: , @@ -8,24 +8,24 @@ export const beforeRender = { resolve(); }, 200); }); - } + }, }; export const qiankun = { // 应用加载之前 async bootstrap(props) { - console.log('app1 bootstrap', props); + console.log('micro bootstrap', props); }, // 应用 render 之前触发 async mount(props) { - console.log('app1 mount', props); + console.log('micro mount', props); }, // 当 props 更新时触发 async update(props) { - console.log('app1 update', props); + console.log('micro update', props); }, // 应用卸载之后触发 async unmount(props) { - console.log('app1 unmount', props); - } + console.log('micro unmount', props); + }, }; diff --git a/packages/fes-plugin-qiankun/examples/main/src/components/PageLoading.vue b/packages/fes-plugin-qiankun/examples/micro/src/components/PageLoading.vue similarity index 86% rename from packages/fes-plugin-qiankun/examples/main/src/components/PageLoading.vue rename to packages/fes-plugin-qiankun/examples/micro/src/components/PageLoading.vue index e544021a..3d5c1cf1 100644 --- a/packages/fes-plugin-qiankun/examples/main/src/components/PageLoading.vue +++ b/packages/fes-plugin-qiankun/examples/micro/src/components/PageLoading.vue @@ -8,16 +8,15 @@ import { FSpin } from '@fesjs/fes-design'; export default { components: { - FSpin + FSpin, }, setup() { - return { - }; - } + return {}; + }, }; + diff --git a/packages/fes-plugin-qiankun/examples/app1/src/pages/app1/test.vue b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue similarity index 54% rename from packages/fes-plugin-qiankun/examples/app1/src/pages/app1/test.vue rename to packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue index f20e10fd..043eb514 100644 --- a/packages/fes-plugin-qiankun/examples/app1/src/pages/app1/test.vue +++ b/packages/fes-plugin-qiankun/examples/micro/src/pages/micro/test.vue @@ -1,7 +1,5 @@ { @@ -12,11 +10,9 @@ - + diff --git a/packages/fes-plugin-qiankun/examples/app1/tsconfig.json b/packages/fes-plugin-qiankun/examples/micro/tsconfig.json similarity index 100% rename from packages/fes-plugin-qiankun/examples/app1/tsconfig.json rename to packages/fes-plugin-qiankun/examples/micro/tsconfig.json diff --git a/packages/fes-plugin-qiankun/examples/main/.env b/packages/fes-plugin-qiankun/examples/vite-main/.env similarity index 100% rename from packages/fes-plugin-qiankun/examples/main/.env rename to packages/fes-plugin-qiankun/examples/vite-main/.env diff --git a/packages/fes-plugin-qiankun/examples/vite-main/.fes.js b/packages/fes-plugin-qiankun/examples/vite-main/.fes.js new file mode 100644 index 00000000..9f5d1000 --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/vite-main/.fes.js @@ -0,0 +1,44 @@ +// .fes.js 只负责管理编译时配置,只能使用plain Object + + +export default { + access: { + roles: { + admin: ["*"] + } + }, + layout: { + title: "Fes.js", + footer: 'Created by MumbleFE', + multiTabs: false, + navigation: 'mixin', + menus: [{ + name: 'index', + }, { + title: "子应用", + children: [{ + name: 'micro-index' + },{ + name: 'micro-test' + }] + }] + }, + qiankun: { + main: { + apps: [ + { + name: 'micro', // 唯一 id + entry: '//localhost:8001', // html entry + props: {} // 传递给子应用的数据 + } + ] + } + }, + plugins: [ + require.resolve('../../../fes-build-vite/lib'), + require.resolve('../../../fes-plugin-model/lib'), + require.resolve('../../../fes-plugin-layout/lib'), + require.resolve('../../../fes-plugin-access/lib'), + require.resolve('../../../fes-plugin-qiankun/lib'), + ] +}; diff --git a/packages/fes-plugin-qiankun/examples/vite-main/index.html b/packages/fes-plugin-qiankun/examples/vite-main/index.html new file mode 100644 index 00000000..34868378 --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/vite-main/index.html @@ -0,0 +1,17 @@ + + + + + + + + <%= title %> + + + + + +
+ + + \ No newline at end of file diff --git a/packages/fes-plugin-qiankun/examples/main/package.json b/packages/fes-plugin-qiankun/examples/vite-main/package.json similarity index 96% rename from packages/fes-plugin-qiankun/examples/main/package.json rename to packages/fes-plugin-qiankun/examples/vite-main/package.json index 0979bb98..805dc35d 100644 --- a/packages/fes-plugin-qiankun/examples/main/package.json +++ b/packages/fes-plugin-qiankun/examples/vite-main/package.json @@ -44,7 +44,6 @@ }, "dependencies": { "@fesjs/fes": "^2.0.0", - "@fesjs/build-webpack": "^1.0.0", "vue": "^3.0.5", "@fesjs/fes-design": "^0.1.10" }, diff --git a/packages/fes-plugin-qiankun/examples/main/src/app.js b/packages/fes-plugin-qiankun/examples/vite-main/src/app.jsx similarity index 84% rename from packages/fes-plugin-qiankun/examples/main/src/app.js rename to packages/fes-plugin-qiankun/examples/vite-main/src/app.jsx index 52361d60..a942f014 100644 --- a/packages/fes-plugin-qiankun/examples/main/src/app.js +++ b/packages/fes-plugin-qiankun/examples/vite-main/src/app.jsx @@ -1,5 +1,5 @@ import { access as accessApi } from '@fesjs/fes'; -import PageLoading from '@/components/PageLoading'; +import PageLoading from '@/components/PageLoading.vue'; export const beforeRender = { loading: , @@ -11,5 +11,5 @@ export const beforeRender = { resolve(); }, 1000); }); - } + }, }; diff --git a/packages/fes-plugin-qiankun/examples/app1/src/components/PageLoading.vue b/packages/fes-plugin-qiankun/examples/vite-main/src/components/PageLoading.vue similarity index 86% rename from packages/fes-plugin-qiankun/examples/app1/src/components/PageLoading.vue rename to packages/fes-plugin-qiankun/examples/vite-main/src/components/PageLoading.vue index e544021a..3d5c1cf1 100644 --- a/packages/fes-plugin-qiankun/examples/app1/src/components/PageLoading.vue +++ b/packages/fes-plugin-qiankun/examples/vite-main/src/components/PageLoading.vue @@ -8,16 +8,15 @@ import { FSpin } from '@fesjs/fes-design'; export default { components: { - FSpin + FSpin, }, setup() { - return { - }; - } + return {}; + }, }; diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/src/global.css b/packages/fes-plugin-qiankun/examples/webpack-main/src/global.css new file mode 100644 index 00000000..b8e98c28 --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/webpack-main/src/global.css @@ -0,0 +1,3 @@ +html, body { + margin: 0; +} \ No newline at end of file diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/src/images/icon.png b/packages/fes-plugin-qiankun/examples/webpack-main/src/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ff46a842d654da25a975ac545798bbcc4fd57918 GIT binary patch literal 5586 zcmb_gXE>Zq+rD>|u!x@MRwu$LNf5*mEzzP!FRLsOEqc9mtJj2t<?%``J0I(O{(^NMLvHx8h*~k+Z+S@Vg1*C9lzf|_;(u(`lpy>3vE+DdtqhCOk_XC>_>vXCE7JtNqv)gxQT_JN=WuTS1w!fXr+6FjfDniPS96)ryWjQB^-;;py|Yw}^`gFcFYmhSWb!>YAqRt?ObFAr86qLCWC$+n z2lgt85SM1Y4?}pvzaGm;oe&~l5-(qSY|}Tuk7&58dO1q8Ok}1t_llbQMLtT4vN8)S zFgOqd_%E$|6TBR`h^1wuc(^?N3eULt!Y@e!;(Tk`$C-i-b7aR^VsmX(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oyLT($mnf35K69agndd=Mg*Y#s4<$>?2@TgIhm(m5MLcC3aVP z=2!22bszzuPKs`*l_YhDxT3fb#n_u?za3FdT&-%gUj&=MwCL68{ZorKw->n0lC3&< z4vss;c6?>qJEm5-vbIwXaC1TrmOsL|Bo-k>wx0*e*GIeUUu20|g3tT@z4V=mGpfgG6ifV(T?-=C!P{ zBL5cX{<~O8!x6qB0dB4c;n3vziJA{B{E}kzGj0-(-~bisGL31V@|n)dq-{3(+3q_Q zfj=i+>el;jUI+JNXC)l$l`C&-yipn`_|Rz!y-fOGpp*L;u*l9dKi6D&I@GsUcl%1M zsR6VP9HVK{kjy_-8i)|(sE%QZG97|ENs@CvrH&6zUVrU9`S7jld1J4}M~RwTfW`06 zf5ewFd1OF~XeZ^#qtmoxk|@#W)=d6QW}EActpLmJp_p==he(;};+TGC2`wz@LyFQM z$@eSt4d3GapH{{ohL!W{uPh4Eu6)vDN9K&|e>BDiG4f%N@|<&p^eC=Q1j>3_k(E9y3r0Pgoe7zu61mYMxWTY0heQ(~Btn^iD zIzMnBBL$5d!nSHbVANDlR=k0X%&tbX9hf134T)?HHY+l+Z|vE8_%%4Vm#0gg@`|hp ve&5jBQY9M?yDv +
+ main + + + + + + + + Content of Tab Pane 3 + +
+ + +{ + "name": "index", + "title": "首页" +} + + diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/index.vue b/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/index.vue new file mode 100644 index 00000000..13661b70 --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/index.vue @@ -0,0 +1,7 @@ + +{ + "name": "micro-index", + "title": "子应用1-首页", + "microApp": "micro" +} + diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/test.vue b/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/test.vue new file mode 100644 index 00000000..d77b3272 --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/webpack-main/src/pages/micro/test.vue @@ -0,0 +1,7 @@ + +{ + "name": "micro-test", + "title": "子应用1-测试", + "microApp": "micro" +} + diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/tsconfig.json b/packages/fes-plugin-qiankun/examples/webpack-main/tsconfig.json new file mode 100644 index 00000000..ea930c0b --- /dev/null +++ b/packages/fes-plugin-qiankun/examples/webpack-main/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "outDir": "build/dist", + "module": "esnext", + "target": "esnext", + "lib": ["esnext", "dom"], + "sourceMap": true, + "baseUrl": ".", + "jsx": "preserve", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "allowJs": true, + "skipLibCheck": true, + "experimentalDecorators": true, + "strict": true, + "paths": { + "@/*": ["./src/*"], + "@@/*": ["./src/.fes/*"] + } + }, + "include": [ + "src/**/*", + "tests/**/*", + "test/**/*", + "__test__/**/*", + "typings/**/*", + "config/**/*", + ".eslintrc.js", + ".stylelintrc.js", + ".prettierrc.js" + ], + "exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"] +} diff --git a/packages/fes-plugin-qiankun/package.json b/packages/fes-plugin-qiankun/package.json index 2a6a94e8..0941f9ab 100644 --- a/packages/fes-plugin-qiankun/package.json +++ b/packages/fes-plugin-qiankun/package.json @@ -8,8 +8,9 @@ ], "scripts": { "start": "npm-run-all --parallel start:*", - "start:master": "cd ./examples/main && fes dev", - "start:app1": "cd ./examples/app1 && fes dev" + "start:vite-main": "cd ./examples/vite-main && fes dev", + "start:webpack-main": "cd ./examples/webpack-main && fes dev", + "start:micro": "cd ./examples/micro && fes dev" }, "repository": { "type": "git", diff --git a/packages/fes-plugin-qiankun/src/micro/index.js b/packages/fes-plugin-qiankun/src/micro/index.js index 1b8a5edf..b97ab49b 100644 --- a/packages/fes-plugin-qiankun/src/micro/index.js +++ b/packages/fes-plugin-qiankun/src/micro/index.js @@ -19,117 +19,122 @@ export default function (api) { enableBy: () => isSlaveEnable(api), }); - api.modifyDefaultConfig((memo) => { - const initialMicroOptions = { - devSourceMap: true, - ...JSON.parse(process.env.INITIAL_QIANKUN_MIRCO_OPTIONS || '{}'), - ...(memo.qiankun || {}).micro, - }; - const modifiedDefaultConfig = { - ...memo, - qiankun: { - ...memo.qiankun, - slave: initialMicroOptions, + if (api.builder.isVite) { + // 处理 + } else { + api.modifyDefaultConfig((memo) => { + const initialMicroOptions = { + devSourceMap: true, + ...JSON.parse(process.env.INITIAL_QIANKUN_MIRCO_OPTIONS || '{}'), + ...(memo.qiankun || {}).micro, + }; + const modifiedDefaultConfig = { + ...memo, + qiankun: { + ...memo.qiankun, + slave: initialMicroOptions, + }, + }; + + const shouldNotModifyDefaultBase = api.userConfig.qiankun?.slave?.shouldNotModifyDefaultBase ?? initialMicroOptions.shouldNotModifyDefaultBase; + if (!shouldNotModifyDefaultBase) { + modifiedDefaultConfig.router.base = `/${api.pkg.name}`; + } + + return modifiedDefaultConfig; + }); + + const absRuntimePath = join(namespace, 'runtime.js'); + const absLifecyclesPath = join(namespace, 'lifecycles.js'); + const absMicroOptionsPath = join(namespace, 'slaveOptions.js'); + const absPublicPath = join(namespace, 'publicPath.js'); + const absModelPath = join(namespace, 'qiankunModel.js'); + + // 更改public path + api.addEntryImportsAhead(() => [{ source: `@@/${absPublicPath}` }]); + + api.register({ + key: 'addExtraModels', + fn: () => { + if (api.hasPlugins(['@fesjs/plugin-model'])) { + return [ + { + absPath: `@@/${absModelPath}`, + namespace: qiankunStateFromMainModelNamespace, + }, + ]; + } + return []; }, - }; - - const shouldNotModifyDefaultBase = api.userConfig.qiankun?.slave?.shouldNotModifyDefaultBase ?? initialMicroOptions.shouldNotModifyDefaultBase; - if (!shouldNotModifyDefaultBase) { - modifiedDefaultConfig.router.base = `/${api.pkg.name}`; - } - - return modifiedDefaultConfig; - }); - - const absRuntimePath = join(namespace, 'runtime.js'); - const absLifecyclesPath = join(namespace, 'lifecycles.js'); - const absMicroOptionsPath = join(namespace, 'slaveOptions.js'); - const absPublicPath = join(namespace, 'publicPath.js'); - const absModelPath = join(namespace, 'qiankunModel.js'); - - // 更改public path - api.addEntryImportsAhead(() => [{ source: `@@/${absPublicPath}` }]); - - api.register({ - key: 'addExtraModels', - fn: () => { - if (api.hasPlugins(['@fesjs/plugin-model'])) { - return [ - { - absPath: `@@/${absModelPath}`, - namespace: qiankunStateFromMainModelNamespace, - }, - ]; - } - return []; - }, - }); - - api.onGenerateFiles(() => { - const HAS_PLUGIN_MODEL = api.hasPlugins(['@fesjs/plugin-model']); - - api.writeTmpFile({ - path: absRuntimePath, - content: readFileSync(join(__dirname, 'runtime/runtime.tpl'), 'utf-8'), }); - api.writeTmpFile({ - path: absLifecyclesPath, - content: Mustache.render(readFileSync(join(__dirname, 'runtime/lifecycles.tpl'), 'utf-8'), { - HAS_PLUGIN_MODEL, - }), - }); + api.onGenerateFiles(() => { + const HAS_PLUGIN_MODEL = api.hasPlugins(['@fesjs/plugin-model']); - api.writeTmpFile({ - path: absPublicPath, - content: ` - if (window.__POWERED_BY_QIANKUN__) { - __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__; - window.public_path = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__; - } - `, - }); - - api.writeTmpFile({ - path: absMicroOptionsPath, - content: ` - let options = ${JSON.stringify((api.config.qiankun || {}).micro || {})}; - export const getSlaveOptions = () => options; - export const setSlaveOptions = (newOpts) => options = ({ ...options, ...newOpts }); - `, - }); - - if (HAS_PLUGIN_MODEL) { api.writeTmpFile({ - path: absModelPath, - content: readFileSync(join(__dirname, 'runtime/qiankunModel.tpl'), 'utf-8'), + path: absRuntimePath, + content: readFileSync(join(__dirname, 'runtime/runtime.tpl'), 'utf-8'), }); - } - }); - api.addRuntimePlugin(() => `@@/${absRuntimePath}`); + api.writeTmpFile({ + path: absLifecyclesPath, + content: Mustache.render(readFileSync(join(__dirname, 'runtime/lifecycles.tpl'), 'utf-8'), { + HAS_PLUGIN_MODEL, + }), + }); - api.chainWebpack((config) => { - assert(api.pkg.name, 'You should have name in package.json'); - config.output.libraryTarget('umd').library(`${api.pkg.name}-[name]`); - return config; - }); + api.writeTmpFile({ + path: absPublicPath, + content: ` + if (window.__POWERED_BY_QIANKUN__) { + __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__; + window.public_path = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__; + } + `, + }); - api.addEntryImports(() => ({ - source: `@@/${absLifecyclesPath}`, - specifier: '{ genMount as qiankun_genMount, genBootstrap as qiankun_genBootstrap, genUnmount as qiankun_genUnmount, genUpdate as qiankun_genUpdate }', - })); + api.writeTmpFile({ + path: absMicroOptionsPath, + content: ` + let options = ${JSON.stringify((api.config.qiankun || {}).micro || {})}; + export const getSlaveOptions = () => options; + export const setSlaveOptions = (newOpts) => options = ({ ...options, ...newOpts }); + `, + }); - api.addEntryCode( - () => ` -export const bootstrap = qiankun_genBootstrap(clientRender, app); -export const mount = qiankun_genMount('#${api.config.mountElementId}'); -export const unmount = qiankun_genUnmount(); -export const update = qiankun_genUpdate(); + if (HAS_PLUGIN_MODEL) { + api.writeTmpFile({ + path: absModelPath, + content: readFileSync(join(__dirname, 'runtime/qiankunModel.tpl'), 'utf-8'), + }); + } + }); -if (!window.__POWERED_BY_QIANKUN__) { - bootstrap().then(mount); -} -`, - ); + api.addRuntimePlugin(() => `@@/${absRuntimePath}`); + + api.chainWebpack((config) => { + assert(api.pkg.name, 'You should have name in package.json'); + config.output.libraryTarget('umd').library(`${api.pkg.name}-[name]`); + return config; + }); + + api.addEntryImports(() => ({ + source: `@@/${absLifecyclesPath}`, + specifier: + '{ genMount as qiankun_genMount, genBootstrap as qiankun_genBootstrap, genUnmount as qiankun_genUnmount, genUpdate as qiankun_genUpdate }', + })); + + api.addEntryCode( + () => ` + export const bootstrap = qiankun_genBootstrap(clientRender, app); + export const mount = qiankun_genMount('#${api.config.mountElementId}'); + export const unmount = qiankun_genUnmount(); + export const update = qiankun_genUpdate(); + + if (!window.__POWERED_BY_QIANKUN__) { + bootstrap().then(mount); + } + `, + ); + } }