@worktile/planet 12.1.0 → 12.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/.all-contributorsrc +84 -0
  2. package/.circleci/config.yml +17 -0
  3. package/.coveralls.yml +1 -0
  4. package/.docgeni/public/assets/favicon.ico +0 -0
  5. package/.docgeni/public/index.html +13 -0
  6. package/.docgenirc.js +35 -0
  7. package/.dockerignore +1 -0
  8. package/.editorconfig +22 -0
  9. package/.github/FUNDING.yml +12 -0
  10. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  11. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  12. package/.prettierignore +7 -0
  13. package/.prettierrc +28 -0
  14. package/.travis.yml +26 -0
  15. package/.wpmrc.js +11 -0
  16. package/CHANGELOG.md +391 -0
  17. package/CODE_OF_CONDUCT.md +76 -0
  18. package/Dockerfile +11 -0
  19. package/LICENSE +21 -0
  20. package/README.md +348 -0
  21. package/README.zh-CN.md +307 -0
  22. package/SECURITY.md +21 -0
  23. package/angular.json +373 -0
  24. package/commitlint.config.js +6 -0
  25. package/docs/api/defineApplication.md +46 -0
  26. package/docs/api/globalEventDispatcher.md +51 -0
  27. package/docs/api/index.md +5 -0
  28. package/docs/api/planet.md +117 -0
  29. package/docs/guides/getting-started.md +174 -0
  30. package/docs/guides/index.md +5 -0
  31. package/docs/guides/intro.md +216 -0
  32. package/examples/app1/browserslist +11 -0
  33. package/examples/app1/extra-webpack.config.js +33 -0
  34. package/examples/app1/karma.conf.js +31 -0
  35. package/examples/app1/postcss.config.js +1 -0
  36. package/examples/app1/src/app/app.module.ts +44 -0
  37. package/examples/app1/src/app/app.routing.ts +49 -0
  38. package/examples/app1/src/app/counter.service.ts +16 -0
  39. package/examples/app1/src/app/dashboard/dashboard.component.html +51 -0
  40. package/examples/app1/src/app/dashboard/dashboard.component.ts +70 -0
  41. package/examples/app1/src/app/detail/detail.component.html +8 -0
  42. package/examples/app1/src/app/detail/detail.component.ts +18 -0
  43. package/examples/app1/src/app/overlay.ts +26 -0
  44. package/examples/app1/src/app/projects/dialog/projects-dialog.component.html +10 -0
  45. package/examples/app1/src/app/projects/dialog/projects-dialog.component.ts +41 -0
  46. package/examples/app1/src/app/projects/projects.component.ts +33 -0
  47. package/examples/app1/src/app/root/root.component.css +3 -0
  48. package/examples/app1/src/app/root/root.component.html +16 -0
  49. package/examples/app1/src/app/root/root.component.ts +35 -0
  50. package/examples/app1/src/app/services/initialized-data.resolver.ts +15 -0
  51. package/examples/app1/src/app/shared.module.ts +57 -0
  52. package/examples/app1/src/app/user/detail/user-detail.component.html +5 -0
  53. package/examples/app1/src/app/user/detail/user-detail.component.ts +20 -0
  54. package/examples/app1/src/app/user/user-list.component.html +7 -0
  55. package/examples/app1/src/app/user/user-list.component.ts +20 -0
  56. package/examples/app1/src/app/user/user.module.ts +31 -0
  57. package/examples/app1/src/assets/.gitkeep +0 -0
  58. package/examples/app1/src/assets/github.png +0 -0
  59. package/examples/app1/src/assets/main.css +3 -0
  60. package/examples/app1/src/environments/environment.prod.ts +3 -0
  61. package/examples/app1/src/environments/environment.ts +16 -0
  62. package/examples/app1/src/favicon.ico +0 -0
  63. package/examples/app1/src/index.html +14 -0
  64. package/examples/app1/src/main.ts +35 -0
  65. package/examples/app1/src/polyfills.ts +84 -0
  66. package/examples/app1/src/styles.scss +35 -0
  67. package/examples/app1/src/test.ts +14 -0
  68. package/examples/app1/temp.js +221 -0
  69. package/examples/app1/tsconfig.app.json +10 -0
  70. package/examples/app1/tsconfig.spec.json +18 -0
  71. package/examples/app1/tslint.json +17 -0
  72. package/examples/app1/webpack.config.js +127 -0
  73. package/examples/app2/browserslist +11 -0
  74. package/examples/app2/extra-webpack.config.js +32 -0
  75. package/examples/app2/karma.conf.js +31 -0
  76. package/examples/app2/src/app/app.module.ts +90 -0
  77. package/examples/app2/src/app/dashboard/dashboard.component.html +21 -0
  78. package/examples/app2/src/app/dashboard/dashboard.component.ts +27 -0
  79. package/examples/app2/src/app/overlay.ts +26 -0
  80. package/examples/app2/src/app/projects/detail/detail.component.html +16 -0
  81. package/examples/app2/src/app/projects/detail/detail.component.ts +21 -0
  82. package/examples/app2/src/app/projects/project-list.component.html +29 -0
  83. package/examples/app2/src/app/projects/project-list.component.ts +58 -0
  84. package/examples/app2/src/app/projects/project.resolver.ts +15 -0
  85. package/examples/app2/src/app/projects/projects.service.ts +28 -0
  86. package/examples/app2/src/app/projects/tasks/tasks.component.html +10 -0
  87. package/examples/app2/src/app/projects/tasks/tasks.component.ts +16 -0
  88. package/examples/app2/src/app/projects/view/view.component.html +1 -0
  89. package/examples/app2/src/app/projects/view/view.component.ts +20 -0
  90. package/examples/app2/src/app/root/root.component.html +14 -0
  91. package/examples/app2/src/app/root/root.component.scss +12 -0
  92. package/examples/app2/src/app/root/root.component.ts +28 -0
  93. package/examples/app2/src/app/shared.module.ts +59 -0
  94. package/examples/app2/src/assets/.gitkeep +0 -0
  95. package/examples/app2/src/environments/environment.prod.ts +3 -0
  96. package/examples/app2/src/environments/environment.ts +16 -0
  97. package/examples/app2/src/favicon.ico +0 -0
  98. package/examples/app2/src/index.html +14 -0
  99. package/examples/app2/src/main.ts +36 -0
  100. package/examples/app2/src/polyfills.ts +84 -0
  101. package/examples/app2/src/styles.scss +28 -0
  102. package/examples/app2/src/test.ts +14 -0
  103. package/examples/app2/tsconfig.app.json +10 -0
  104. package/examples/app2/tsconfig.spec.json +18 -0
  105. package/examples/app2/tslint.json +7 -0
  106. package/examples/app2/webpack.config.js +92 -0
  107. package/examples/common/app-root-context.ts +10 -0
  108. package/examples/common/cache.ts +82 -0
  109. package/examples/common/index.ts +13 -0
  110. package/examples/common/module.ts +10 -0
  111. package/examples/common/overlay-container.service.ts +28 -0
  112. package/examples/common/section-card/section-card.component.html +5 -0
  113. package/examples/common/section-card/section-card.component.scss +15 -0
  114. package/examples/common/section-card/section-card.component.ts +11 -0
  115. package/examples/common/utils.ts +0 -0
  116. package/examples/portal/src/app/a-detail/a-detail.component.html +8 -0
  117. package/examples/portal/src/app/a-detail/a-detail.component.ts +18 -0
  118. package/examples/portal/src/app/about/about.component.html +27 -0
  119. package/examples/portal/src/app/about/about.component.scss +0 -0
  120. package/examples/portal/src/app/about/about.component.spec.ts +26 -0
  121. package/examples/portal/src/app/about/about.component.ts +26 -0
  122. package/examples/portal/src/app/app-routing.module.ts +57 -0
  123. package/examples/portal/src/app/app.component.html +73 -0
  124. package/examples/portal/src/app/app.component.scss +58 -0
  125. package/examples/portal/src/app/app.component.spec.ts +33 -0
  126. package/examples/portal/src/app/app.component.ts +111 -0
  127. package/examples/portal/src/app/app.module.ts +64 -0
  128. package/examples/portal/src/app/custom-settings.service.ts +44 -0
  129. package/examples/portal/src/app/overlay.ts +26 -0
  130. package/examples/portal/src/app/settings/settings.component.html +31 -0
  131. package/examples/portal/src/app/settings/settings.component.scss +3 -0
  132. package/examples/portal/src/app/settings/settings.component.ts +43 -0
  133. package/examples/portal/src/assets/.gitkeep +0 -0
  134. package/examples/portal/src/assets/apps.json +29 -0
  135. package/examples/portal/src/assets/icons/sprite.defs.svg +1 -0
  136. package/examples/portal/src/assets/images/logo.svg +16 -0
  137. package/examples/portal/src/assets/ngx-planet-micro-front-end.gif +0 -0
  138. package/examples/portal/src/browserslist +11 -0
  139. package/examples/portal/src/environments/environment.prod.ts +3 -0
  140. package/examples/portal/src/environments/environment.ts +16 -0
  141. package/examples/portal/src/extra-webpack.config.js +32 -0
  142. package/examples/portal/src/favicon.ico +0 -0
  143. package/examples/portal/src/index.html +14 -0
  144. package/examples/portal/src/karma.conf.js +31 -0
  145. package/examples/portal/src/main.ts +18 -0
  146. package/examples/portal/src/polyfills.ts +84 -0
  147. package/examples/portal/src/reboot.scss +14 -0
  148. package/examples/portal/src/styles.scss +14 -0
  149. package/examples/portal/src/test.ts +14 -0
  150. package/examples/portal/src/tsconfig.app.json +10 -0
  151. package/examples/portal/src/tsconfig.spec.json +9 -0
  152. package/examples/portal/src/tslint.json +7 -0
  153. package/extra-webpack.config.js +5 -0
  154. package/nginx.conf +17 -0
  155. package/package.json +121 -16
  156. package/packages/planet/karma.conf.js +37 -0
  157. package/packages/planet/ng-package.json +7 -0
  158. package/packages/planet/package.json +10 -0
  159. package/packages/planet/src/application/planet-application-loader.spec.ts +1102 -0
  160. package/packages/planet/src/application/planet-application-loader.ts +549 -0
  161. package/packages/planet/src/application/planet-application-ref.spec.ts +233 -0
  162. package/packages/planet/src/application/planet-application-ref.ts +131 -0
  163. package/packages/planet/src/application/planet-application.service.spec.ts +145 -0
  164. package/packages/planet/src/application/planet-application.service.ts +88 -0
  165. package/packages/planet/src/application/portal-application.spec.ts +53 -0
  166. package/packages/planet/src/application/portal-application.ts +28 -0
  167. package/packages/planet/src/assets-loader.spec.ts +689 -0
  168. package/packages/planet/src/assets-loader.ts +247 -0
  169. package/packages/planet/src/component/planet-component-loader.spec.ts +187 -0
  170. package/packages/planet/src/component/planet-component-loader.ts +173 -0
  171. package/packages/planet/src/component/planet-component-ref.ts +8 -0
  172. package/{component/plant-component.config.d.ts → packages/planet/src/component/plant-component.config.ts} +4 -4
  173. package/packages/planet/src/debug.spec.ts +58 -0
  174. package/packages/planet/src/debug.ts +66 -0
  175. package/packages/planet/src/empty/empty.component.spec.ts +34 -0
  176. package/packages/planet/src/empty/empty.component.ts +7 -0
  177. package/packages/planet/src/global-event-dispatcher.spec.ts +81 -0
  178. package/packages/planet/src/global-event-dispatcher.ts +82 -0
  179. package/packages/planet/src/global-planet.spec.ts +39 -0
  180. package/packages/planet/src/global-planet.ts +73 -0
  181. package/packages/planet/src/helpers.spec.ts +242 -0
  182. package/packages/planet/src/helpers.ts +125 -0
  183. package/packages/planet/src/module.spec.ts +79 -0
  184. package/packages/planet/src/module.ts +25 -0
  185. package/{planet.class.d.ts → packages/planet/src/planet.class.ts} +26 -5
  186. package/packages/planet/src/planet.spec.ts +226 -0
  187. package/packages/planet/src/planet.ts +113 -0
  188. package/{public-api.d.ts → packages/planet/src/public-api.ts} +4 -1
  189. package/packages/planet/src/sandbox/constants.ts +6 -0
  190. package/packages/planet/src/sandbox/exec.ts +22 -0
  191. package/packages/planet/src/sandbox/index.ts +24 -0
  192. package/packages/planet/src/sandbox/proxy/patches/document.ts +13 -0
  193. package/packages/planet/src/sandbox/proxy/patches/eventListener.ts +49 -0
  194. package/packages/planet/src/sandbox/proxy/patches/index.ts +13 -0
  195. package/packages/planet/src/sandbox/proxy/patches/storage.ts +53 -0
  196. package/packages/planet/src/sandbox/proxy/patches/timer.ts +50 -0
  197. package/packages/planet/src/sandbox/proxy/proxies/common.ts +137 -0
  198. package/packages/planet/src/sandbox/proxy/proxies/document.ts +140 -0
  199. package/packages/planet/src/sandbox/proxy/proxies/window.ts +176 -0
  200. package/packages/planet/src/sandbox/proxy/proxy-sandbox.ts +59 -0
  201. package/{sandbox/proxy/types.d.ts → packages/planet/src/sandbox/proxy/types.ts} +8 -2
  202. package/packages/planet/src/sandbox/sandbox.ts +20 -0
  203. package/packages/planet/src/sandbox/snapshot/snapshot-sandbox.ts +12 -0
  204. package/packages/planet/src/sandbox/types.ts +1 -0
  205. package/packages/planet/src/test.ts +16 -0
  206. package/packages/planet/src/testing/app1.module.ts +34 -0
  207. package/packages/planet/src/testing/app2.module.ts +24 -0
  208. package/packages/planet/src/testing/applications.ts +58 -0
  209. package/packages/planet/src/testing/index.ts +2 -0
  210. package/packages/planet/src/testing/utils.ts +31 -0
  211. package/packages/planet/tsconfig.lib.json +27 -0
  212. package/packages/planet/tsconfig.lib.prod.json +9 -0
  213. package/packages/planet/tsconfig.spec.json +17 -0
  214. package/packages/planet/tslint.json +7 -0
  215. package/postcss.config.js +3 -0
  216. package/proxy.conf.js +15 -0
  217. package/tsconfig.json +23 -0
  218. package/tslint.json +80 -0
  219. package/application/planet-application-loader.d.ts +0 -70
  220. package/application/planet-application-loader.d.ts.map +0 -1
  221. package/application/planet-application-loader.ngfactory.d.ts.map +0 -1
  222. package/application/planet-application-ref.d.ts +0 -36
  223. package/application/planet-application-ref.d.ts.map +0 -1
  224. package/application/planet-application.service.d.ts +0 -19
  225. package/application/planet-application.service.d.ts.map +0 -1
  226. package/application/planet-application.service.ngfactory.d.ts.map +0 -1
  227. package/application/portal-application.d.ts +0 -15
  228. package/application/portal-application.d.ts.map +0 -1
  229. package/assets-loader.d.ts +0 -33
  230. package/assets-loader.d.ts.map +0 -1
  231. package/assets-loader.ngfactory.d.ts.map +0 -1
  232. package/bundles/worktile-planet.umd.js +0 -2552
  233. package/bundles/worktile-planet.umd.js.map +0 -1
  234. package/component/planet-component-loader.d.ts +0 -28
  235. package/component/planet-component-loader.d.ts.map +0 -1
  236. package/component/planet-component-loader.ngfactory.d.ts.map +0 -1
  237. package/component/planet-component-ref.d.ts +0 -8
  238. package/component/planet-component-ref.d.ts.map +0 -1
  239. package/component/plant-component.config.d.ts.map +0 -1
  240. package/debug.d.ts +0 -22
  241. package/debug.d.ts.map +0 -1
  242. package/empty/empty.component.d.ts +0 -3
  243. package/empty/empty.component.d.ts.map +0 -1
  244. package/empty/empty.component.ngfactory.d.ts.map +0 -1
  245. package/esm2015/application/planet-application-loader.js +0 -452
  246. package/esm2015/application/planet-application-ref.js +0 -94
  247. package/esm2015/application/planet-application.service.js +0 -87
  248. package/esm2015/application/portal-application.js +0 -16
  249. package/esm2015/assets-loader.js +0 -217
  250. package/esm2015/component/planet-component-loader.js +0 -155
  251. package/esm2015/component/planet-component-ref.js +0 -3
  252. package/esm2015/component/plant-component.config.js +0 -7
  253. package/esm2015/debug.js +0 -33
  254. package/esm2015/empty/empty.component.js +0 -10
  255. package/esm2015/global-event-dispatcher.js +0 -71
  256. package/esm2015/global-planet.js +0 -51
  257. package/esm2015/helpers.js +0 -119
  258. package/esm2015/module.js +0 -27
  259. package/esm2015/planet.class.js +0 -9
  260. package/esm2015/planet.js +0 -90
  261. package/esm2015/public-api.js +0 -18
  262. package/esm2015/sandbox/constants.js +0 -7
  263. package/esm2015/sandbox/exec.js +0 -15
  264. package/esm2015/sandbox/index.js +0 -20
  265. package/esm2015/sandbox/proxy/patches/document.js +0 -12
  266. package/esm2015/sandbox/proxy/patches/eventListener.js +0 -41
  267. package/esm2015/sandbox/proxy/patches/index.js +0 -11
  268. package/esm2015/sandbox/proxy/patches/storage.js +0 -40
  269. package/esm2015/sandbox/proxy/patches/timer.js +0 -43
  270. package/esm2015/sandbox/proxy/proxies/common.js +0 -132
  271. package/esm2015/sandbox/proxy/proxies/document.js +0 -126
  272. package/esm2015/sandbox/proxy/proxies/window.js +0 -155
  273. package/esm2015/sandbox/proxy/proxy-sandbox.js +0 -49
  274. package/esm2015/sandbox/proxy/types.js +0 -2
  275. package/esm2015/sandbox/sandbox.js +0 -7
  276. package/esm2015/sandbox/snapshot/snapshot-sandbox.js +0 -12
  277. package/esm2015/sandbox/types.js +0 -2
  278. package/esm2015/worktile-planet.js +0 -6
  279. package/fesm2015/worktile-planet.js +0 -2036
  280. package/fesm2015/worktile-planet.js.map +0 -1
  281. package/global-event-dispatcher.d.ts +0 -20
  282. package/global-event-dispatcher.d.ts.map +0 -1
  283. package/global-event-dispatcher.ngfactory.d.ts.map +0 -1
  284. package/global-planet.d.ts +0 -23
  285. package/global-planet.d.ts.map +0 -1
  286. package/helpers.d.ts +0 -39
  287. package/helpers.d.ts.map +0 -1
  288. package/module.d.ts +0 -6
  289. package/module.d.ts.map +0 -1
  290. package/module.ngfactory.d.ts.map +0 -1
  291. package/planet.class.d.ts.map +0 -1
  292. package/planet.d.ts +0 -25
  293. package/planet.d.ts.map +0 -1
  294. package/planet.ngfactory.d.ts.map +0 -1
  295. package/public-api.d.ts.map +0 -1
  296. package/sandbox/constants.d.ts +0 -7
  297. package/sandbox/constants.d.ts.map +0 -1
  298. package/sandbox/exec.d.ts +0 -3
  299. package/sandbox/exec.d.ts.map +0 -1
  300. package/sandbox/index.d.ts +0 -7
  301. package/sandbox/index.d.ts.map +0 -1
  302. package/sandbox/proxy/patches/document.d.ts +0 -3
  303. package/sandbox/proxy/patches/document.d.ts.map +0 -1
  304. package/sandbox/proxy/patches/eventListener.d.ts +0 -3
  305. package/sandbox/proxy/patches/eventListener.d.ts.map +0 -1
  306. package/sandbox/proxy/patches/index.d.ts +0 -3
  307. package/sandbox/proxy/patches/index.d.ts.map +0 -1
  308. package/sandbox/proxy/patches/storage.d.ts +0 -15
  309. package/sandbox/proxy/patches/storage.d.ts.map +0 -1
  310. package/sandbox/proxy/patches/timer.d.ts +0 -3
  311. package/sandbox/proxy/patches/timer.d.ts.map +0 -1
  312. package/sandbox/proxy/proxies/common.d.ts +0 -13
  313. package/sandbox/proxy/proxies/common.d.ts.map +0 -1
  314. package/sandbox/proxy/proxies/document.d.ts +0 -14
  315. package/sandbox/proxy/proxies/document.d.ts.map +0 -1
  316. package/sandbox/proxy/proxies/window.d.ts +0 -13
  317. package/sandbox/proxy/proxies/window.d.ts.map +0 -1
  318. package/sandbox/proxy/proxy-sandbox.d.ts +0 -16
  319. package/sandbox/proxy/proxy-sandbox.d.ts.map +0 -1
  320. package/sandbox/proxy/types.d.ts.map +0 -1
  321. package/sandbox/sandbox.d.ts +0 -12
  322. package/sandbox/sandbox.d.ts.map +0 -1
  323. package/sandbox/snapshot/snapshot-sandbox.d.ts +0 -9
  324. package/sandbox/snapshot/snapshot-sandbox.d.ts.map +0 -1
  325. package/sandbox/types.d.ts +0 -2
  326. package/sandbox/types.d.ts.map +0 -1
  327. package/worktile-planet.d.ts +0 -6
  328. package/worktile-planet.d.ts.map +0 -1
  329. package/worktile-planet.metadata.json +0 -1
package/README.md ADDED
@@ -0,0 +1,348 @@
1
+ # ngx-planet
2
+
3
+ [![CircleCI](https://circleci.com/gh/worktile/ngx-planet.svg?style=shield)](https://circleci.com/gh/worktile/ngx-planet)
4
+ [![Coverage Status][coveralls-image]][coveralls-url]
5
+ [![npm (scoped)](https://img.shields.io/npm/v/@worktile/planet?style=flat)](https://www.npmjs.com/package/@worktile/planet)
6
+ [![npm](https://img.shields.io/npm/dm/@worktile/planet)](https://www.npmjs.com/package/@worktile/planet)
7
+ ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@worktile/planet) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
8
+
9
+ [coveralls-image]: https://coveralls.io/repos/github/worktile/ngx-planet/badge.svg?branch=master
10
+ [coveralls-url]: https://coveralls.io/github/worktile/ngx-planet
11
+
12
+ A powerful, reliable, fully-featured and production ready Micro Frontend library for Angular.
13
+
14
+ APIs consistent with angular style, currently only supports Angular, other frameworks are not supported.
15
+
16
+ English | [中文文档](https://github.com/worktile/ngx-planet/blob/master/README.zh-CN.md)
17
+
18
+ ## Features
19
+
20
+ - Rendering multiple applications at the same time
21
+ - Support two mode, coexist and default that switch to another app and destroy active apps
22
+ - Support application preload
23
+ - Support style isolation
24
+ - Built-in communication between multiple applications
25
+ - Cross application component rendering
26
+ - Comprehensive examples include routing configuration, lazy loading and all features
27
+
28
+ ## Alternatives
29
+
30
+ - [single-spa](https://github.com/CanopyTax/single-spa): A javascript front-end framework supports any frameworks.
31
+ - [mooa](https://github.com/phodal/mooa): A independent-deployment micro-frontend Framework for Angular from single-spa, `planet` is very similar to it, but `planet` is more powerful, reliable, productively and more angular.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ $ npm i @worktile/planet --save
37
+ // or
38
+ $ yarn add @worktile/planet
39
+ ```
40
+
41
+ ## Dependencies
42
+
43
+ - `@angular/cdk`, you should install `@angular/cdk`
44
+
45
+ ## Demo
46
+
47
+ [Try out our live demo](http://planet.ngnice.com)
48
+
49
+ ![ngx-planet-micro-front-end.gif](https://cdn.pingcode.com/open-sources/ngx-planet/ngx-planet-micro-front-end.gif)
50
+
51
+ ## Usage
52
+
53
+ ### 1. Loading NgxPlanetModule in the portal's AppModule
54
+
55
+ ```
56
+ import { NgxPlanetModule } from '@worktile/planet';
57
+
58
+ @NgModule({
59
+ imports: [
60
+ CommonModule,
61
+ NgxPlanetModule
62
+ ]
63
+ })
64
+ class AppModule {}
65
+ ```
66
+
67
+ ### 2. Register applications to planet use PlanetService in portal app
68
+
69
+ ```
70
+ @Component({
71
+ selector: 'app-portal-root',
72
+ template: `
73
+ <nav>
74
+ <a [routerLink]="['/app1']" routerLinkActive="active">应用1</a>
75
+ <a [routerLink]="['/app2']" routerLinkActive="active">应用2</a>
76
+ </nav>
77
+ <router-outlet></router-outlet>
78
+ <div id="app-host-container"></div>
79
+ <div *ngIf="!loadingDone">加载中...</div>
80
+ `
81
+ })
82
+ export class AppComponent implements OnInit {
83
+ title = 'ngx-planet';
84
+
85
+ get loadingDone() {
86
+ return this.planet.loadingDone;
87
+ }
88
+
89
+ constructor(
90
+ private planet: Planet
91
+ ) {}
92
+
93
+ ngOnInit() {
94
+ this.planet.setOptions({
95
+ switchMode: SwitchModes.coexist,
96
+ errorHandler: error => {
97
+ console.error(`Failed to load resource, error:`, error);
98
+ }
99
+ });
100
+
101
+ this.planet.registerApps([
102
+ {
103
+ name: 'app1',
104
+ hostParent: '#app-host-container',
105
+ hostClass: 'thy-layout',
106
+ routerPathPrefix: '/app1',
107
+ resourcePathPrefix: '/static/app1',
108
+ preload: true,
109
+ scripts: [
110
+ 'main.js'
111
+ ],
112
+ styles: [
113
+ 'styles.css'
114
+ ]
115
+ },
116
+ {
117
+ name: 'app2',
118
+ hostParent: '#app-host-container',
119
+ hostClass: 'thy-layout',
120
+ routerPathPrefix: '/app2',
121
+ preload: true,
122
+ scripts: [
123
+ '/static/app2/main.js'
124
+ ],
125
+ styles: [
126
+ '/static/app2/styles.css'
127
+ ]
128
+ }
129
+ ]);
130
+
131
+ // start monitor route changes
132
+ // get apps to active by current path
133
+ // load static resources which contains javascript and css
134
+ // bootstrap angular sub app module and show it
135
+ this.planet.start();
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### 3. Sub App define how to bootstrap AppModule
141
+
142
+ ```
143
+ defineApplication('app1', {
144
+ template: `<app1-root class="app1-root"></app1-root>`,
145
+ bootstrap: (portalApp: PlanetPortalApplication) => {
146
+ return platformBrowserDynamic([
147
+ {
148
+ provide: PlanetPortalApplication,
149
+ useValue: portalApp
150
+ },
151
+ {
152
+ provide: AppRootContext,
153
+ useValue: portalApp.data.appRootContext
154
+ }
155
+ ])
156
+ .bootstrapModule(AppModule)
157
+ .then(appModule => {
158
+ return appModule;
159
+ })
160
+ .catch(error => {
161
+ console.error(error);
162
+ return null;
163
+ });
164
+ }
165
+ });
166
+ ```
167
+
168
+ ## Documents
169
+
170
+ ### Sub app configurations
171
+
172
+ | Name | Type | Description | 中文描述 |
173
+ | ------------------ | --------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174
+ | name | string | Application's name | 子应用的名字 |
175
+ | routerPathPrefix | string | Application route path prefix | 子应用路由路径前缀,根据这个匹配应用 |
176
+ | selector | string | selector of app root component | 子应用的启动组件选择器,因为子应用是主应用动态加载的,所以主应用需要先创建这个选择器节点,再启动 AppModule |
177
+ | scripts | string[] | javascript static resource paths | JS 静态资源文件访问地址 |
178
+ | styles | string[] | style static resource paths | 样式静态资源文件访问地址 |
179
+ | resourcePathPrefix | string | path prefix of scripts and styles | 脚本和样式文件路径前缀,多个脚本可以避免重复写同样的前缀 |
180
+ | hostParent | string or HTMLElement | parent element for render | 应用渲染的容器元素, 指定子应用显示在哪个元素内部 |
181
+ | hostClass | string | added class for host which is selector | 宿主元素的 Class,也就是在子应用启动组件上追加的样式 |
182
+ | switchMode | default or coexist | it will be destroyed when set to default, it only hide app when set to coexist | 切换子应用的模式,默认切换会销毁,设置 coexist 后只会隐藏 |
183
+ | preload | boolean | start preload or not | 是否启用预加载,启动后刷新页面等当前页面的应用渲染完毕后预加载子应用 |
184
+ | loadSerial | boolean | serial load scripts | 是否串行加载脚本静态资源 |
185
+ | manifest | string | manifest json file path | manifest.json 文件路径地址,当设置了路径后会先加载这个文件,然后根据 scripts 和 styles 文件名去找到匹配的文件,因为生产环境的静态资文件是 hash 之后的命名,需要动态获取 |
186
+
187
+ ### Communication between applications use GlobalEventDispatcher
188
+
189
+ ```
190
+ import { GlobalEventDispatcher } from "@worktile/planet";
191
+
192
+ // app1 root module
193
+ export class AppModule {
194
+ constructor(private globalEventDispatcher: GlobalEventDispatcher) {
195
+ this.globalEventDispatcher.register('open-a-detail').subscribe(event => {
196
+ // dialog.open(App1DetailComponent);
197
+ });
198
+ }
199
+ }
200
+
201
+ // in other apps
202
+ export class OneComponent {
203
+ constructor(private globalEventDispatcher: GlobalEventDispatcher) {
204
+ }
205
+
206
+ openDetail() {
207
+ this.globalEventDispatcher.dispatch('open-a-detail', payload);
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### Cross application component rendering
213
+
214
+ ```
215
+ import { PlanetComponentLoader } from "@worktile/planet";
216
+
217
+ // in app1
218
+ export class AppModule {
219
+ constructor(private planetComponentLoader: PlanetComponentLoader) {
220
+ this.planetComponentLoader.register([{ name: 'app1-project-list', component: App1ProjectListComponent }]);
221
+ }
222
+ }
223
+
224
+ // in other apps
225
+ export class OneComponent {
226
+ constructor(private planetComponentLoader: PlanetComponentLoader) {
227
+ }
228
+
229
+ openDetail() {
230
+ this.planetComponentLoader.load('app1', 'app1-project-list', {
231
+ container: this.containerElementRef,
232
+ initialState: {}
233
+ });
234
+ }
235
+ }
236
+
237
+ ```
238
+
239
+ ## FAQ
240
+
241
+ ### infinite loop load portal app's js
242
+ Because the portal app and sub app are packaged through webpack, there will be conflicts in module dependent files, we should set up additional config `runtimeChunk` through `@angular-builders/custom-webpack`, we expect webpack 5 to support micro frontend better.
243
+ ```
244
+ // extra-webpack.config.js
245
+ {
246
+ optimization: {
247
+ runtimeChunk: false
248
+ }
249
+ };
250
+ ```
251
+
252
+ ### throw error `Cannot read property 'call' of undefined at __webpack_require__ (bootstrap:79)`
253
+ Similar to the reasons above, we should set `vendorChunk` as `false` for `build` and `serve` in `angular.json`
254
+
255
+ ```
256
+ ...
257
+ "build": {
258
+ "builder": "@angular-builders/custom-webpack:browser",
259
+ "options": {
260
+ "customWebpackConfig": {
261
+ "path": "./examples/app2/extra-webpack.config.js",
262
+ "mergeStrategies": {
263
+ "module.rules": "prepend"
264
+ },
265
+ "replaceDuplicatePlugins": true
266
+ },
267
+ ...
268
+ "vendorChunk": false,
269
+ ...
270
+ },
271
+ },
272
+ "serve": {
273
+ "builder": "@angular-builders/custom-webpack:dev-server",
274
+ "options": {
275
+ ...
276
+ "vendorChunk": false
277
+ ...
278
+ }
279
+ }
280
+ ...
281
+ ```
282
+
283
+ ### throw error `An accessor cannot be declared in an ambient context.`
284
+ this is TypeScript's issue, details see [an-accessor-cannot-be-declared](https://stackoverflow.com/questions/61248058/error-ngx-daterangepicker-material-an-accessor-cannot-be-declared-in-an-ambient
285
+ )
286
+ should setting `skipLibCheck` as true
287
+ ```
288
+ "compilerOptions": {
289
+ "skipLibCheck": true
290
+ }
291
+ ```
292
+
293
+ ### Production env throw error `Cannot read property 'call' of undefined` use router lazy load
294
+
295
+ In webpack 4 multiple webpack runtimes could conflict on the same HTML page, because they use the same global variable for chunk loading. To fix that it was needed to provide a custom name to the output.jsonpFunction configuration, details see [Automatic unique naming](https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-unique-naming).
296
+
297
+ you should set a unique name for each sub application in `extra-webpack.config.js`
298
+ ```
299
+ output: { jsonpFunction: "app1" }
300
+ ```
301
+
302
+ ## Development
303
+
304
+ ```
305
+ npm run start // open http://localhost:3000
306
+
307
+ or
308
+
309
+ npm run serve:portal // 3000
310
+ npm run serve:app1 // 3001
311
+ npm run serve:app2 // 3002
312
+
313
+ // test
314
+ npm run test
315
+ ```
316
+
317
+ ## Roadmap
318
+
319
+ - [ ] Ivy render engine
320
+ - [ ] Supports Other frameworks as React and Vue
321
+
322
+ ## Contributors ✨
323
+
324
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
325
+
326
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
327
+ <!-- prettier-ignore-start -->
328
+ <!-- markdownlint-disable -->
329
+ <table>
330
+ <tr>
331
+ <td align="center"><a href="https://www.zhihu.com/people/why520crazy/activities"><img src="https://avatars2.githubusercontent.com/u/3959960?v=4" width="100px;" alt=""/><br /><sub><b>why520crazy</b></sub></a><br /><a href="#question-why520crazy" title="Answering Questions">💬</a> <a href="#business-why520crazy" title="Business development">💼</a> <a href="https://github.com/worktile/ngx-planet/commits?author=why520crazy" title="Code">💻</a> <a href="#design-why520crazy" title="Design">🎨</a> <a href="https://github.com/worktile/ngx-planet/commits?author=why520crazy" title="Documentation">📖</a> <a href="#eventOrganizing-why520crazy" title="Event Organizing">📋</a> <a href="#infra-why520crazy" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-why520crazy" title="Maintenance">🚧</a> <a href="#projectManagement-why520crazy" title="Project Management">📆</a> <a href="https://github.com/worktile/ngx-planet/pulls?q=is%3Apr+reviewed-by%3Awhy520crazy" title="Reviewed Pull Requests">👀</a></td>
332
+ <td align="center"><a href="https://github.com/walkerkay"><img src="https://avatars1.githubusercontent.com/u/15701592?v=4" width="100px;" alt=""/><br /><sub><b>Walker</b></sub></a><br /><a href="https://github.com/worktile/ngx-planet/commits?author=walkerkay" title="Code">💻</a> <a href="#example-walkerkay" title="Examples">💡</a> <a href="#maintenance-walkerkay" title="Maintenance">🚧</a> <a href="https://github.com/worktile/ngx-planet/pulls?q=is%3Apr+reviewed-by%3Awalkerkay" title="Reviewed Pull Requests">👀</a></td>
333
+ <td align="center"><a href="https://whyour.cn"><img src="https://avatars3.githubusercontent.com/u/22700758?v=4" width="100px;" alt=""/><br /><sub><b>whyour</b></sub></a><br /><a href="https://github.com/worktile/ngx-planet/commits?author=whyour" title="Code">💻</a></td>
334
+ <td align="center"><a href="http://www.231jx.cn"><img src="https://avatars0.githubusercontent.com/u/19969080?v=4" width="100px;" alt=""/><br /><sub><b>张威</b></sub></a><br /><a href="https://github.com/worktile/ngx-planet/commits?author=aoilti" title="Code">💻</a></td>
335
+ <td align="center"><a href="https://github.com/luxiaobei"><img src="https://avatars1.githubusercontent.com/u/13583957?v=4" width="100px;" alt=""/><br /><sub><b>luxiaobei</b></sub></a><br /><a href="#infra-luxiaobei" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/worktile/ngx-planet/commits?author=luxiaobei" title="Tests">⚠️</a> <a href="https://github.com/worktile/ngx-planet/commits?author=luxiaobei" title="Code">💻</a></td>
336
+ <td align="center"><a href="https://github.com/mario56"><img src="https://avatars2.githubusercontent.com/u/7720722?v=4" width="100px;" alt=""/><br /><sub><b>mario_ma</b></sub></a><br /><a href="https://github.com/worktile/ngx-planet/commits?author=mario56" title="Code">💻</a></td>
337
+ </tr>
338
+ </table>
339
+
340
+ <!-- markdownlint-enable -->
341
+ <!-- prettier-ignore-end -->
342
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
343
+
344
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
345
+
346
+ ## LICENSE
347
+
348
+ [MIT License](https://github.com/worktile/ngx-planet/blob/master/LICENSE)
@@ -0,0 +1,307 @@
1
+ # ngx-planet
2
+
3
+ [![CircleCI](https://circleci.com/gh/worktile/ngx-planet.svg?style=shield)](https://circleci.com/gh/worktile/ngx-planet)
4
+ [![Coverage Status][coveralls-image]][coveralls-url]
5
+ [![npm (scoped)](https://img.shields.io/npm/v/@worktile/planet?style=flat)](https://www.npmjs.com/package/@worktile/planet)
6
+ [![npm](https://img.shields.io/npm/dm/@worktile/planet)](https://www.npmjs.com/package/@worktile/planet)
7
+ ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@worktile/planet) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
8
+
9
+ [coveralls-image]: https://coveralls.io/repos/github/worktile/ngx-planet/badge.svg?branch=master
10
+ [coveralls-url]: https://coveralls.io/github/worktile/ngx-planet
11
+
12
+ 一个强大、可靠、完善、完全可用于生产环境的 Angular 微前端库。
13
+ Angular 的 API 风格,目前只支持 Angular 框架,不支持其他 MV* 前端框架。
14
+
15
+ 中文文档 | [English README](https://github.com/worktile/ngx-planet/blob/master/README.md)
16
+
17
+ ## 功能
18
+
19
+ - 支持同时渲染多个子应用
20
+ - 支持并存(coexist)和默认(default)两种模式, 默认模式切换其他子应用销毁当前子应用,并存模式不会销毁,而是隐藏
21
+ - 支持子应用的预加载
22
+ - 支持样式隔离
23
+ - 内置多个应用之间的通信
24
+ - 支持跨应用组件的渲染
25
+ - 完善的示例,包含路由配置、懒加载等所有功能
26
+
27
+ ## 其他方案
28
+
29
+ - [single-spa](https://github.com/CanopyTax/single-spa): A javascript front-end framework supports any frameworks.
30
+ - [mooa](https://github.com/phodal/mooa): A independent-deployment micro-frontend Framework for Angular from single-spa, `planet` 和 `mooa` 非常相似, 但是 `planet` 更加强大、可靠,同时完全用于了生产环境,比如:https://pingcode.com
31
+
32
+ ## 安装
33
+
34
+ ```bash
35
+ $ npm i @worktile/planet --save
36
+ // 或者
37
+ $ yarn add @worktile/planet
38
+ ```
39
+
40
+ ## Dependencies
41
+
42
+ - `@angular/cdk`, 确保安装了 Angular 官方的 CDK `npm i @angular/cdk --save` 或者 `yarn add @angular/cdk`
43
+
44
+
45
+ ## 示例
46
+
47
+ [Try out our live demo](http://planet.ngnice.com)
48
+
49
+ ![ngx-planet-micro-front-end.gif](https://cdn.pingcode.com/open-sources/ngx-planet/ngx-planet-micro-front-end.gif)
50
+
51
+ ## 使用说明
52
+
53
+ ### 1. 在主应用的`AppModule`中引入`NgxPlanetModule`
54
+
55
+ ```
56
+ import { NgxPlanetModule } from '@worktile/planet';
57
+
58
+ @NgModule({
59
+ imports: [
60
+ CommonModule,
61
+ NgxPlanetModule
62
+ ]
63
+ })
64
+ class AppModule {}
65
+ ```
66
+
67
+ ### 2. 通过`Planet`服务在主应用中注册子应用
68
+
69
+ ```
70
+ @Component({
71
+ selector: 'app-portal-root',
72
+ template: `
73
+ <nav>
74
+ <a [routerLink]="['/app1']" routerLinkActive="active">应用1</a>
75
+ <a [routerLink]="['/app2']" routerLinkActive="active">应用2</a>
76
+ </nav>
77
+ <router-outlet></router-outlet>
78
+ <div id="app-host-container"></div>
79
+ <div *ngIf="!loadingDone">加载中...</div>
80
+ `
81
+ })
82
+ export class AppComponent implements OnInit {
83
+ title = 'ngx-planet';
84
+
85
+ get loadingDone() {
86
+ return this.planet.loadingDone;
87
+ }
88
+
89
+ constructor(
90
+ private planet: Planet
91
+ ) {}
92
+
93
+ ngOnInit() {
94
+ this.planet.setOptions({
95
+ switchMode: SwitchModes.coexist,
96
+ errorHandler: error => {
97
+ console.error(`Failed to load resource, error:`, error);
98
+ }
99
+ });
100
+
101
+ this.planet.registerApps([
102
+ {
103
+ name: 'app1',
104
+ hostParent: '#app-host-container',
105
+ hostClass: 'thy-layout',
106
+ routerPathPrefix: '/app1',
107
+ resourcePathPrefix: '/static/app1',
108
+ preload: true,
109
+ scripts: [
110
+ 'main.js'
111
+ ],
112
+ styles: [
113
+ 'styles.css'
114
+ ]
115
+ },
116
+ {
117
+ name: 'app2',
118
+ hostParent: '#app-host-container',
119
+ hostClass: 'thy-layout',
120
+ routerPathPrefix: '/app2',
121
+ preload: true,
122
+ scripts: [
123
+ '/static/app2/main.js'
124
+ ],
125
+ styles: [
126
+ '/static/app2/styles.css'
127
+ ]
128
+ }
129
+ ]);
130
+
131
+ // start monitor route changes
132
+ // get apps to active by current path
133
+ // load static resources which contains javascript and css
134
+ // bootstrap angular sub app module and show it
135
+ this.planet.start();
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### 3. 子应用通过`defineApplication`定义如何启动子应用的`AppModule`, 同时可以设置`PlanetPortalApplication`服务为主应用的全局服务。
141
+
142
+ ```
143
+ defineApplication('app1', (portalApp: PlanetPortalApplication) => {
144
+ return platformBrowserDynamic([
145
+ {
146
+ provide: PlanetPortalApplication,
147
+ useValue: portalApp
148
+ }
149
+ ])
150
+ .bootstrapModule(AppModule)
151
+ .then(appModule => {
152
+ return appModule;
153
+ })
154
+ .catch(error => {
155
+ console.error(error);
156
+ return null;
157
+ });
158
+ });
159
+ ```
160
+
161
+ ## 文档
162
+
163
+ ### 子应用
164
+
165
+ | Name | Type | Description | 中文描述 |
166
+ | ------------------ | --------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
167
+ | name | string | Application's name | 子应用的名字 |
168
+ | routerPathPrefix | string | Application route path prefix | 子应用路由路径前缀,根据这个匹配应用 |
169
+ | selector | string | selector of app root component | 子应用的启动组件选择器,因为子应用是主应用动态加载的,所以主应用需要先创建这个选择器节点,再启动 AppModule |
170
+ | scripts | string[] | javascript static resource paths | JS 静态资源文件访问地址 |
171
+ | styles | string[] | style static resource paths | 样式静态资源文件访问地址 |
172
+ | resourcePathPrefix | string | path prefix of scripts and styles | 脚本和样式文件路径前缀,多个脚本可以避免重复写同样的前缀 |
173
+ | hostParent | string or HTMLElement | parent element for render | 应用渲染的容器元素, 指定子应用显示在哪个元素内部 |
174
+ | hostClass | string | added class for host which is selector | 宿主元素的 Class,也就是在子应用启动组件上追加的样式 |
175
+ | switchMode | default or coexist | it will be destroyed when set to default, it only hide app when set to coexist | 切换子应用的模式,默认切换会销毁,设置 coexist 后只会隐藏 |
176
+ | preload | boolean | start preload or not | 是否启用预加载,启动后刷新页面等当前页面的应用渲染完毕后预加载子应用 |
177
+ | loadSerial | boolean | serial load scripts | 是否串行加载脚本静态资源 |
178
+ | manifest | string | manifest json file path | manifest.json 文件路径地址,当设置了路径后会先加载这个文件,然后根据 scripts 和 styles 文件名去找到匹配的文件,因为生产环境的静态资文件是 hash 之后的命名,需要动态获取 |
179
+
180
+ ### `GlobalEventDispatcher` 实现应用之间的通信
181
+
182
+ ```
183
+ import { GlobalEventDispatcher } from "@worktile/planet";
184
+
185
+ // app1 root module
186
+ export class AppModule {
187
+ constructor(private globalEventDispatcher: GlobalEventDispatcher) {
188
+ this.globalEventDispatcher.register('open-a-detail').subscribe(event => {
189
+ // dialog.open(App1DetailComponent);
190
+ });
191
+ }
192
+ }
193
+
194
+ // in other apps
195
+ export class OneComponent {
196
+ constructor(private globalEventDispatcher: GlobalEventDispatcher) {
197
+ }
198
+
199
+ openDetail() {
200
+ this.globalEventDispatcher.dispatch('open-a-detail', payload);
201
+ }
202
+ }
203
+ ```
204
+
205
+ ### 跨应用组件渲染
206
+
207
+ ```
208
+ import { PlanetComponentLoader } from "@worktile/planet";
209
+
210
+ // in app1
211
+ export class AppModule {
212
+ constructor(private planetComponentLoader: PlanetComponentLoader) {
213
+ this.planetComponentLoader.register([{ name: 'app1-project-list', component: App1ProjectListComponent }]);
214
+ }
215
+ }
216
+
217
+ // in other apps
218
+ export class OneComponent {
219
+ constructor(private planetComponentLoader: PlanetComponentLoader) {
220
+ }
221
+
222
+ openDetail() {
223
+ this.planetComponentLoader.load('app1', 'app1-project-list', {
224
+ container: this.containerElementRef,
225
+ initialState: {}
226
+ });
227
+ }
228
+ }
229
+
230
+ ```
231
+
232
+ ## FAQ
233
+
234
+ ### 无限循环加载主应用的js
235
+ 因为主应用和子应用都是通过Webpack打包的,打包的版本依赖会有冲突,需要通过`@angular-builders/custom-webpack`插件设置扩展的`Webpack`配置`runtimeChunk`, 期望 Webpack 5 对于微前端支持的更好。
236
+ ```
237
+ // extra-webpack.config.js
238
+ {
239
+ optimization: {
240
+ runtimeChunk: false
241
+ }
242
+ };
243
+ ```
244
+
245
+ ### 报错 `Cannot read property 'call' of undefined at __webpack_require__ (bootstrap:79)`
246
+ 和上面的原因类似,我们需要设置 `vendorChunk` 为 `false`,需要同时设置 `angular.json`中的`build`和`serve`, `serve` 按理说是应该继承 build 的配置的,好像在 Angular 8 中有缺陷,不起作用。
247
+
248
+ ```
249
+ ...
250
+ "build": {
251
+ "builder": "@angular-builders/custom-webpack:browser",
252
+ "options": {
253
+ "customWebpackConfig": {
254
+ "path": "./examples/app2/extra-webpack.config.js",
255
+ "mergeStrategies": {
256
+ "module.rules": "prepend"
257
+ },
258
+ "replaceDuplicatePlugins": true
259
+ },
260
+ ...
261
+ "vendorChunk": false,
262
+ ...
263
+ },
264
+ },
265
+ "serve": {
266
+ "builder": "@angular-builders/custom-webpack:dev-server",
267
+ "options": {
268
+ ...
269
+ "vendorChunk": false
270
+ ...
271
+ }
272
+ }
273
+ ...
274
+ ```
275
+
276
+ ### 报错 `An accessor cannot be declared in an ambient context.`
277
+ 这好像是 TypeScript 某个版本的缺陷,详细情况可以查看 see [an-accessor-cannot-be-declared](https://stackoverflow.com/questions/61248058/error-ngx-daterangepicker-material-an-accessor-cannot-be-declared-in-an-ambient
278
+ )
279
+ 临时解决通过设置 `skipLibCheck` 为 true,将来升级到高级版本的 TypeScript 可能就自动修复了。
280
+ ```
281
+ "compilerOptions": {
282
+ "skipLibCheck": true
283
+ }
284
+ ```
285
+ ### 使用路由延迟加载生产环境报错 `Cannot read property 'call' of undefined``
286
+
287
+ 在 Webpack 4 中,多个应用的运行时在同一个页面下会有冲突,因为它们使用了相同的全局变量加载 chunk,为了修复这个问题,你需要通过`output.jsonpFunction`配置项提供一个自定义的名字,详细信息参考:[Automatic unique naming](https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-unique-naming).
288
+
289
+ 你需要给每一个子应用的 `extra-webpack.config.js` 文件中配置一个唯一的名字
290
+ ```
291
+ output: { jsonpFunction: "app1" }
292
+ ```
293
+
294
+ ## 开发
295
+
296
+ ```
297
+ npm run start // open http://localhost:3000
298
+
299
+ or
300
+
301
+ npm run serve:portal // 3000
302
+ npm run serve:app1 // 3001
303
+ npm run serve:app2 // 3002
304
+
305
+ // test
306
+ npm run test
307
+ ```
package/SECURITY.md ADDED
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | 5.1.x | :white_check_mark: |
11
+ | 5.0.x | :x: |
12
+ | 4.0.x | :white_check_mark: |
13
+ | < 4.0 | :x: |
14
+
15
+ ## Reporting a Vulnerability
16
+
17
+ Use this section to tell people how to report a vulnerability.
18
+
19
+ Tell them where to go, how often they can expect to get an update on a
20
+ reported vulnerability, what to expect if the vulnerability is accepted or
21
+ declined, etc.