-
Notifications
You must be signed in to change notification settings - Fork 37
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
Convert to ES6 module syntax #198
Comments
I think this issue should also cover a restructuring of how we define modules. A couple thoughts:
|
Agreed, those are now "modules" because that is the structure we now have. Having said that, some of the "core" modules do have configurable settings so in that sense I think it is logical they might share some of the same code.
Agreed, the example code you envisioned there does make a whole lot more sense in the modern js landscape compared to what we have now. I am not sure it ever really made sense as it was thought up by people more familiar with other languages at the time ;)
Or possibly just create shortnames automatically from the long names. Although that makes it a bit harder to rename modules if need be as settings are now shortname related.
Can be ditched as far as I am concerned.
Agreed here.
Looks good to me. A closing thought here is that we probably want to split things out in tasks we can already do as foundation (storage possibly, maybe module listing, etc) and work that needs to be done at the same time. Also before we start with all this we should do a little proof of concept with the stackoverflow example you found to make sure it actually works and works as intended. |
I've found a case where this would be very useful while working on #316 and #317. In order to have the modbar module open the usernotes manager for a subreddit, it needs to create a button with a specific class and |
Got kinda bored and wrote a basic proof-of-concept extension demonstrating how we could structure Toolbox this way. https://github.com/Geo1088/webext-esm-poc Unfortunately I learned this afternoon that Firefox has a bug preventing dynamic |
Nice PoC, you need to get bored more often 👍 |
|
All our platforms support the module specification from ES6, and also support the currently stage 4 proposal for dynamic
import()
. These are all we need to convert the existing module structore to actual modules, allowing us to greatly simplify the init process.Rather than waiting for an event and registering themselves, each module can export a TBModule object which will be imported and registered elsewhere. This will also allow us to avoid IIFEs wrapping everything, because module code doesn't expose declarations to other files unless they are explicitly
export
ed.We can't make content scripts act as modules straight away, but we can use an async function to
import()
module code. Reference: https://stackoverflow.com/questions/48104433/how-to-import-es6-modules-in-content-script-for-chrome-extensionThe text was updated successfully, but these errors were encountered: