plasmo
plasmo copied to clipboard
[RFC] Progressive migration for messaging
How do you envision this feature/change to look/work like?
If you already have a chrome.runtime.onMessage.addListener, then messaging does not work.
This makes it unrealistically challenging to migrate an existing app - as every single command needs to be migrated simultaneously.
I think it would be quite strightforward to provide a migration-path:
- When sending events, add a "plasmoVersion: x" - or some other metadata which makes it clear this was a framework-sent event
- Provide a method to manually trigger the Plasmo event handler
This way if you need to run the listener yourself, you can check for the existence of plasmoVersion on the event & pass it through to Plasmo's handler.
I am proposing "plasmoVersion" as the key here because it's extremely unlikely to have collisions (unlike something like "from").
What is the purpose of this change/feature? Why?
To provide a gradual migration path with existing projects which already have listeners (or anyone who needs to have a listener for any other purpose).
(OPTIONAL) Example implementations
No response
(OPTIONAL) Contribution
- [ ] I would like to contribute to this RFC via a PR
Verify canary release
- [X] I verified that the issue exists in
plasmo
canary release
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I checked the current issues for duplicate problems.