I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ but if not then ‘library B’ and so on.
Check out JS dynamic imports. import()
returns a Promise. If you serve both libraryA
and libraryB
you can dynamically import any of them depending on the logic that you implement.
Thanks. I believe Liveview uses default ESbuild. So to allow lazy loading perhaps it needs tinkering with?
Yes, to avoid including the library in the esbuild bundle you can use –external.