don't rename default exports unnecessarily #166
Merged
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 scratches an itch I've had for quite some time. Due to the way esperanto avoids variable name conflicts, something like this...
...gets transpiled to this inside a bundle:
A large enough codebase will be littered with this sort of thing. Or, if
foo.js
is inside a directory, sayutils
, it will come out asvar utils__foo = foo
, or something like that.Clearly it's unnecessary - we should just use
foo
throughout. The one exception is wherefoo
is updated or assigned to after it has been exported, since IIRC default bindings aren't live, like regular bindings (can't find the reference now, spotty wifi - correct me if I'm wrong!).In other words, this...
...should become this:
That edge case is dealt with, at the cost of some pretty funky code, which I might try and clean up a little before merging this in.
I've tried this out on a few examples and the difference is huge - the code looks handwritten rather than generated, and is accordingly much easier to read in its bundled state.