refactor: separate export default from function declaration #858
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.
The issue
Currently all classes (I know they are not technically ES6 classes, but I'm sure you know what I mean) are the default export of the package, which is fine, but since the declaration reads
export default function ClassName(){}
, when the typings are generated and documentation from those typings, all the class names become nameddefault
. See this from https://joe.skeen.rocks/diagram-js/classes/core_ElementFactory.default.html:This leads to a potentially confusing experience for those consuming typings or docs from the library.
Proposed solution
This PR exports each class as its own export, but also sets the default export to that class. The only change should be an additional export with the name of the class attached. This enables documentation to work better, as the names will exist in the docs, as well as links between referenced types.
How the code changes were made
In VSCode, I did a RegEx global search in
lib/**/*.js
for:and replaced it with:
Related to #78
Related to #857