Open KrishnaPG opened 4 years ago
I think this is what you need https://github.com/iShawnWang/kilobyte/issues/14 ~
which is typescript version of https://usehooks.com/useScript/
Thank you @iShawnWang . I think that useScripts
hook is referring to being able to load any script truly at runtime dynamically. Which is very powerful.
I was referring to much simpler option of being able to load the antd
, eCharts
, react
etc. from the <head>
section of the page, so that webpack does not need to bundle them. This improves the performance, due to reduced bundle size as well as loading from CDN heavily uses the network caches, browser caches etc.
The dynamic
loading part I was referring to was chunking by the webpack such that components are loaded on demand rather than in a single big module.
Ofcourse, if the useScript
hook can be used then it may solve all these problems too, but looks like it is slightly complex to implement. I could be wrong. If it is not complex, then it is also a good solution to consider.
Description
Currently the
antd
,react
,eCharts
etc. are hard-linked into the package, making the produced bundle size large. Please considerdynamic imports
This will reduce the bundle size, and webpack compile times will be small.
Solution
UMI documentation allows to use external scripts such as:
But in the code, in many places, the packages are hard coded as:
It would be great if the code loads such third party packages
window.React
is not already available. If already available, use it, instead of importing