-
Notifications
You must be signed in to change notification settings - Fork 7
Description
In the recent incubator call the proposal at #5 was discussed, which proposes replacing string fragments with module identifiers that can be imported and exported.
I wanted to just follow up with one explicit workflow concern around these identifier versus string module fragments.
Consider a framework peer dependency like react
or lit
that is a base dependency in a component model. We bundle the primary application using module fragments.
Now at runtime if we want to load components that were not included in the original bundle, we cannot import components that are written using the common pattern:
import * as React from 'react';
As we would now need to effectively change this to use the identifier fragment double import pattern:
import { reactModule } from '/core-bundle.js';
import * as React from reactModule;
The concern here is that it creates a requirement on all subsequent code loaded that it is syntactically changed based on knowing the internal bundling pattern and assumptions.
With the current module fragments proposal one could just define an import map:
<script type="importmap">
{
"imports": {
"react": "/bundle.js#react"
}
}
</script>
which would allow the third-party code to correctly reference the bundled framework.
Because such techniques are no longer possible, this instead places a very specific semantic burden on any subsequently loaded code that inhibits code portability between bundles.
I think we need to think carefully about this problem and ensure there are solutions available if wanting to move forward with such a scheme.