Lazy loading Stimulsoft in React +Vite

Stimulsoft Reports.JS discussion
Post Reply
mrapi
Posts: 290
Joined: Sat Dec 20, 2008 1:08 am

Lazy loading Stimulsoft in React +Vite

Post by mrapi »

Hi
it is possible to lazy loading Stimulsoft in React + Vite?

In vite.convig I've created a separate js chunk for Stimulsoft:

Code: Select all

  build: {
    outDir: "../API/wwwroot",
    
  modulePreload: {
      polyfill: false,
      resolveDependencies: (_filename, deps, _context) => {
        return deps.filter(dep => !dep.includes('stimulsoft'));
      }
    },
	
    rollupOptions: {
      output: {
        manualChunks: {
          'stimulsoft': ['stimulsoft-reports-js-react/viewer'],
        }
      }
    },
	
  },

I call load only on a button click,not import it up in the component

Code: Select all

 onClick={async () => {
    ....
           const { Stimulsoft } = await import('stimulsoft-reports-js-react/viewer');
     ..
but aways I see the js package(https://mysite.com/assets/stimulsoft-BD2YVTVO.js) in netwok tab every time I start my app

thanks
Lech Kulikowski
Posts: 7655
Joined: Tue Mar 20, 2018 5:34 am

Re: Lazy loading Stimulsoft in React +Vite

Post by Lech Kulikowski »

Hello,

For it to work, all modules must be loaded. Lazy loading is not possible on our side.

Thank you.
mrapi
Posts: 290
Joined: Sat Dec 20, 2008 1:08 am

Re: Lazy loading Stimulsoft in React +Vite

Post by mrapi »

k,thanks
Lech Kulikowski
Posts: 7655
Joined: Tue Mar 20, 2018 5:34 am

Re: Lazy loading Stimulsoft in React +Vite

Post by Lech Kulikowski »

Hello,

You are welcome.
Post Reply