Support exporting live-bindings from other chunks or external dependencies #2765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #2754
Description
With this PR, re-exported variables will be updated correctly even if the live binding is exported from another chunk or an external dependency. This is done similar to how Babel handles this by using getters. This will work for all formats that did not support this before, i.e. 'cjs', 'amd', 'iife' and 'umd', and also work for star re-exports. Examples:
The only unsupported case for now is mutable default exports as at the moment, this would mean that Rollup needs to re-run its interop each time the getter is accessed. I hope to find a better solution for this in the future but this might require rethinking how interop works at the moment.
For cross-chunk exports, the new logic will only be used if the binding is actually mutated, otherwise a simple assignment is used. For external reexports, however, we always assume the binding is mutated.