Open terragady opened 2 years ago
Up - have the same problem
Hi, I am using react v18 and I am trying to code split pdfmake module but no luck. I have tried to use Lazy load from react in the component I am importing pdfmake but it is still in main js, tried async import of pdfmake but also it stays in main.js. I am only using pdfmake in specific occasion but it increases my bundle size by 75%. Is it possible to somehow load it only when needed?
Why are you not use pdf make inside the worker? Load it dynamically with the component itself. have your worker file beside the component and just create new instance when you need.
const worker = useMemo(() => new Worker(new URL('./worker.js', import.meta.url)), []);
// your code interacting with worker
Hi, I am using react v18 and I am trying to code split pdfmake module but no luck. I have tried to use Lazy load from react in the component I am importing pdfmake but it is still in main js, tried async import of pdfmake but also it stays in main.js. I am only using pdfmake in specific occasion but it increases my bundle size by 75%. Is it possible to somehow load it only when needed?