-
Notifications
You must be signed in to change notification settings - Fork 37
Make @webext-core/proxy-service Tree-Shakeable
#111
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
Open
natereprogle
wants to merge
6
commits into
aklinker1:main
Choose a base branch
from
natereprogle:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fbe1610
Work on making defineProxyService shakable. One test is failing and I…
6ff8b1e
Update definition of registration
8820956
Async race condition was causing failures. Removed ability to make as…
b94b168
Remove all promises from shakable tree proxy entirely. Don't make asy…
5283ba9
Finish tree shaking functionality. Had to end up writing defineServic…
natereprogle 1a0ca94
Merge branch 'main' into main
aklinker1 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
Binary file not shown.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| export default defineBackground(() => { | ||
| registerMathService(); | ||
| registerMathService(async () => { | ||
| const { MathService } = await import('../utils/math-service'); | ||
| return new MathService(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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 is something I'm confused about. I saw in the PR description something about dynamic imports and top-level awaits being required... but that's not true?
You could just import the
math-servicemodule here like normal, right? You just can't import it in the entrypoints that use proxies instead.Here's what I'm thinking, might be a nicer API:
We could even do something like what Vue does with provide/inject keys and support a custom branded type that let's us infer the service type from the key
That way the key and type are tied together.
Uh oh!
There was an error while loading. Please reload this page.
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.
Wow, I was very inconsistent in the naming in my suggestions lol. Since the package is called "proxy service", we should stick with that when naming things. I'm OK releasing a major version and straight up dropping the
defineProxyServicefunction without any deprecation notice.So I'm proposing 3 functions:
registerProxyService- takes in a key and actual service implementation, registering messaging listeners for itcreateProxyService- takes in just a key and returns the proxy objectcreateProxyServiceKey- Helper for defining a branded type that the above 2 functions can infer the service type fromThis is still in the brainstorming phase, so I'm open for naming changes to any of those APIs. I'm just trying to summarize my suggestions from the last comment.