-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: exports for Base Plugin #3495
Merged
katspaugh
merged 9 commits into
katspaugh:main
from
brian-byassee:feat-base-plugin-export
Jan 19, 2024
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b715034
Feat: exports for Base Plugin
097e0f3
Feat: exports for Base Plugin
6303bb2
Feat: exports for Base Plugin
0cfd253
Revert "Feat: exports for Base Plugin"
489e384
Revert "Feat: exports for Base Plugin"
884476a
Feat: exports for BasePlugin and Dom
8b98182
Revert "Feat: exports for BasePlugin and Dom"
f73e8c5
Feat: add BasePlugin and createElement to wavesurfer class
d05b9f8
Feat: Add dom to WaveSurfer
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might backfire because the main bundle will have the same imports but a different copy thereof. So you would basically ship duplicate code, plus the class/type identity will differ. Wavesurfer expects plugins to be subclassesof that specific BasePlugin import, not another copy. Hope this makes sense, it barely does to me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I think this PR still has some issues beyond just that. Demoted it to a draft again and will look at it some more here in a bit. But I think I might just end up closing it for now.
More to come soon!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's possible to ignore named exports for CommonJS modules via a rollup plugin.
Another alternative, just to acommodate the CommonJS module, would be to expose BasePlugin as a static property of the WaveSurfer class instead of exporting it as a named export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, this is already an existing problem. The current exports do not use the same BasePlugin class instance. Let me give an example.
Both of these imports are distinct compilations of the source code with their own cjs/esm/min bundles. They contain the code for BasePlugin individually and are not referencing the same instance of the class.
This can be illustrated by running the following code:
Or using instanceof:
The way to fix this would be to modify the library to return a single bundle.
You can get this to work pretty easily by having a root index.js that contains the exports. Use rollup to build one single bundle and export it all. It lends itself to tree shaking this way, too.
But it would be a breaking change to people so this would require a major version bump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, and thanks for Index.ts pointer.