Skip to content
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

Loader changes in version 0.10.0 #50

Open
MrOtherGuy opened this issue Apr 23, 2024 · 1 comment
Open

Loader changes in version 0.10.0 #50

MrOtherGuy opened this issue Apr 23, 2024 · 1 comment

Comments

@MrOtherGuy
Copy link
Owner

Currently @backgroundmodule scripts are loaded using ChromeUtils.import() which is old mechanism meant for loading .jsm modules. All jsm use has been removed for mozilla-central already, and while the mechanism does work still, it will be removed shortly after 128 cycle. I intend to remove support during 128 cycle.

It should be pretty simple to change your scripts to ES6 modules instead - just rename the file with .sys.mjs extension and the loader will treat it correctly, most of the time at least.

Afterwards, the @backgroundmodule header will be useless, since the loader will use file extension to determine if the script is background module or not. However, I might instead make the loader check if @backgroundmodule tag exists in the header, and then ignore such scripts with a warning.

@MrOtherGuy MrOtherGuy changed the title Remove support from jsm-style backgroundmodule scripts Loader changes in version 0.10.0 Jun 9, 2024
@MrOtherGuy
Copy link
Owner Author

MrOtherGuy commented Jun 9, 2024

I'll hijack this issue for discussion about all the changes in version 0.10.0.

tl;dr _ucUtils is no more, @backgroundmodule and @startup are ignored

  • _ucUtils was getting pretty annoying since it was mostly uncategorized and could not be imported very well. It is now replaced with UC_API symbol that's defined by the loader with more sane API.
  • @backgroundmodule is removed in favor of ES6 modules using .sys.mjs file extension
  • @startup was very confusing to use - but now that Windows.onCreated() exists it isn't needed any more

UC_API

This is provided as a module by and "interface script" - utils/uc_api.sys.mjs. This module can be imported into your ES6 module scripts whether they are window- or background-scripts and the properties it has should be "valid" at all times. In contrast, you could not just static-import utils.sys.mjs in all scripts because depending on situation it would not give you the actual instances that boot.sys.mjs uses which lead to problems in various cases. This new version at least to me feels much more ergonomic and simple to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant