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

javascript.statements.import - not supported in ServiceWorkers in Firefox #23554

Closed
James-E-A opened this issue Jun 28, 2024 · 0 comments · Fixed by #23555
Closed

javascript.statements.import - not supported in ServiceWorkers in Firefox #23554

James-E-A opened this issue Jun 28, 2024 · 0 comments · Fixed by #23555
Labels
data:js Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript

Comments

@James-E-A
Copy link

James-E-A commented Jun 28, 2024

What type of issue is this?

Incorrect support data (example: BrowserX says "86" but support was added in "40")

What information was incorrect, unhelpful, or incomplete?

The MDN article on the import statement claims that the import statement is "Available in service workers"[sic] as of Firefox version 114.

What browsers does this problem apply to, if applicable?

Firefox

What did you expect to see?

I expected to see a service worker that used the import statement in its body not fail to evaluate on Firefox version 115.

Did you test this? If so, how?

I tested this on Firefox 115.12.0esr (64-bit) on Windows.

I also tested this on Microsoft Edge version 126.0.2592.68 (Official build) (64-bit) on Windows; but the documentation isn't unambiguously wrong in that case, since Edge — unlike Firefox — supports "module" service workers, which do support the import statement.

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

To be clear, the problem is with the import statement, not the import() function, which is described on a different page and about which I have no complaints today.

Do you have anything more you want to share?

Miminal Reproducible Example: stick these 3 files in a folder and call python -m http.server on it; open localhost:8000 in Firefox, press F12, and check the console for complaints. (Edge has the same error, but puts more informative and relevant details directly into the page's error console.)

<!-- index.html -->
<script type="module">
await navigator.serviceWorker.register('./sw.js');
</script>
/* sw.js */
import { onmessage_sw, onfetch_sw } from "./mod.mjs";

addEventListener('message', onmessage_sw);
addEventListener('fetch', onfetch_sw);
/* mod.mjs */
export function onmessage_sw(event) {
	console.info("Got message event: %o", event);
}

export function onfetch_sw(event) {
	console.info("Got fetch event: %o", event);
}

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

MDN metadata

MDN page report details
  • Query: javascript.statements.import
  • Report started: 2024-06-28T19:39:42.992Z
@queengooborg queengooborg added the data:js Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript label Jun 29, 2024
queengooborg added a commit to queengooborg/browser-compat-data that referenced this issue Jun 29, 2024
…upport

This PR updates and corrects version values for Firefox and Firefox Android for the `import.service_worker_support` member of the `statements` JavaScript feature. This fixes mdn#23554, which contains the supporting evidence for this change.

Additional Notes: It is worth noting that this feature, and a subfeature of `ServiceWorker` indicating ECMAScript module support, were both added in mdn#19835. It has been confirmed that ECMAScript modules aren't supported in Service Workers in Firefox yet.
@Elchi3 Elchi3 closed this as completed in 319f3bd Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:js Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript
Projects
None yet
2 participants