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

No dynamic import in service worker #27699

Merged
merged 10 commits into from Feb 24, 2021
Merged

No dynamic import in service worker #27699

merged 10 commits into from Feb 24, 2021

Conversation

jakearchibald
Copy link
Contributor

@jakearchibald jakearchibald commented Feb 19, 2021

@jgraham this PR adds a new "service worker module" handler type, but I'm not confident I've done it correctly. The intent is to allow .any.serviceworker-module.html to run the equivalent .any.js in a service worker with type 'module'.

Part of whatwg/html#6395 and w3c/ServiceWorker#1356

@jakearchibald
Copy link
Contributor Author

jakearchibald commented Feb 19, 2021

@domenic you might be interested in this, as it's a pattern that could be extended to other module worker types

@jakearchibald
Copy link
Contributor Author

@annevk feedback addressed, cheers!

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good modulo that seemingly fundamental problem. I don't feel comfortable reviewing the infrastructure addition. I'll leave that to @jgraham and @stephenmcgruer.

@domenic
Copy link
Member

domenic commented Feb 19, 2021

The runs at e.g. https://github.com/web-platform-tests/wpt/pull/27699/checks?check_run_id=1936236036 show the new infrastructure isn't working right on CI---maybe that's as expected though.

The runs at https://github.com/web-platform-tests/wpt/pull/27699/checks?check_run_id=1936236067 and https://github.com/web-platform-tests/wpt/pull/27699/checks?check_run_id=1936051438 show that Firefox and Safari do support dynamic import, it seems.

@jakearchibald
Copy link
Contributor Author

@domenic those results look expected to me. No browsers support module service workers right now. And yes, dynamic import works (but not as intended) in Firefox and Safari.

@jakearchibald
Copy link
Contributor Author

I've gone ahead and added support for dedicated/shared worker modules too. May as well do the lot.

Copy link
Contributor

@jgraham jgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically I think this implementation is reasonable; just one comment.

if key == "title":
value = value.replace("\\", "\\\\").replace('"', '\\"')
return 'self.META_TITLE = "%s";' % value
return None


class AnyWorkerModuleHandler(AnyWorkerHandler):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I'd prefer if this and AnyWorkerHandler both inherited from a common base rather than having this one override parts of the behaviour in the other concrete class.

@jakearchibald
Copy link
Contributor Author

@jgraham heh, I forgot that Python auto-exports. I've renamed the other references.

@jakearchibald
Copy link
Contributor Author

@jgraham the failures seem unrelated to me (webrtc?), but I'm not really familiar with them

@jgraham
Copy link
Contributor

jgraham commented Feb 24, 2021

OK, I'm pretty sure I've seen that test failure in unrelated PRs, so it's probably broken on master. Will investigate.

@jgraham
Copy link
Contributor

jgraham commented Feb 24, 2021

Ah @stephenmcgruer already fixed it in #27744

@jgraham jgraham closed this Feb 24, 2021
@jgraham jgraham reopened this Feb 24, 2021
@jakearchibald jakearchibald merged commit a02460e into master Feb 24, 2021
@jakearchibald jakearchibald deleted the sw-no-dynamic-import branch February 24, 2021 11:37
@jakearchibald
Copy link
Contributor Author

@jgraham thanks!

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

Successfully merging this pull request may close these issues.

None yet

7 participants