Comment

Comment by ashu1461

Not sure if this can be made backward compatible.

Right now all the imports are getting resolved at runtime example in a code like below

  from file1 import function1
When you write this, the entire file1 module is executed right away, which may trigger side effects.

If lazy imports suddenly defer execution, those side effects won’t run until much later (or not at all, if the code path isn’t hit). That shift in timing could easily break existing code that depends on import-time behavior.

To avoid using lazy, this there is also a proposal of adding the modules you want to load lazily to a global `__lazy_modules__` variable.

parent ashu1461 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton