`import *` potentially doesn't need to parse/link
bmeck opened this issue · 3 comments
Given that there is no linkage required required for import *
likely it can avoid parsing or linkage if cycles are not present in some way. The only issue is with behaviors that can statically cyclically link:
// a
import 'b' with {layzInit: true};
// b
export * from 'a';
This would let things be done in an even more controlled manner but would need some kind of guard against cycles. Either stating a different kind of linkage or disallowing cycles to modules with lazy behaviors.
It would be good to at least investigate here as ahead of time fetch costs are some of the prohibitive costs still possible with this proposal.
But we need to throw syntax error or early errors before we run the code. It will be super strange to throw a syntax error at the time of your first visit to the deferred imports.
One thing I am discussing with various delegates is just how critical early errors are. Do they really add to developer experience if they are at parse time as opposed to execution time? Don't we already have this with dynamically loaded modules, as parse is deferred anyway?