-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support dynamic import() in background service worker #212
Comments
Chromium bug: https://crbug.com/1198822. The only workaround for now is a dynamic |
On the Chrome side we're considering making an extension-specific allowance for dynamic import in module service workers. I believe @wanderview has made public comments to this effect in service worker issues but I don't have links handy at the moment. I don't anticipate that we will be able to explore this further before the end of 2022.
For clarity, service workers cannot call You should not need to call |
Wrong. It can and it works because the essence of the trick is to have all future code present at the install phase. Once all modules were imported in the install event (when the extension was installed) we can import any of these modules dynamically (inside asynchronous code) at any time. |
According to past meeting minutes, I add supportive labels from Chrome and Firefox. I also open an issue at Web service worker, just let them know this WECG proposal for extension service worker. |
As documented in w3c/ServiceWorker#1585, dynamically importing modules is not supported in a service worker environment. This limitation applies to background service workers in MV3 as well. Ideally dynamic import() would be supported for service workers generally, but it doesn't look like there has been any progress on that front within the last year. Are there any plans to support this for browser extensions specifically?
This feature would be useful for extensions that require large dependencies that may only be necessary to load in certain contexts. For example, in our extension we dynamically load specific locale files after detecting the user's language.
The text was updated successfully, but these errors were encountered: