Another suggestion to try and work around the concern I raised at the last meeting, that might be worth working through regardless of outcome - treating deferred reexports as unavailable by default rather than available by default in namespaces.
To go through the semantics:
- There is still only one cached namespace object, and these optional names would be defined as throwing if access is attempted when they are not yet loaded / async ready.
- If any other importer in the graph had done an explicit import of one of these optionals (via
import { optional } from 'foo') they would have driven execution already so that the namespace access for anyone else in the graph would then work.
- In addition, we could possibly even use a (non-keying) import attribute to also hint the optional for the namespace case -
import * as foo from 'foo' with { optional ['optional'] }.
The hard failure is a rough edge still, but that is the same as import defer. Worth discussing nonetheless I think since it resolves the footgun question quite nicely by simply changing the default assumption.
Another suggestion to try and work around the concern I raised at the last meeting, that might be worth working through regardless of outcome - treating deferred reexports as unavailable by default rather than available by default in namespaces.
To go through the semantics:
import { optional } from 'foo') they would have driven execution already so that the namespace access for anyone else in the graph would then work.import * as foo from 'foo' with { optional ['optional'] }.The hard failure is a rough edge still, but that is the same as
import defer. Worth discussing nonetheless I think since it resolves the footgun question quite nicely by simply changing the default assumption.