wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Deprecate `--target no-modules`

Open lukaslihotzki opened this issue 2 years ago • 7 comments

ES modules are the official, standardized way to structure JS code, supported by all currently used browsers and node and deno. The guide already mentions that no-modules is older and has some caveats. It does not explain any advantages of --no-modules. I know one reason for it: Firefox didn't support ES module web workers until the current version 111. ~~This is fixed now.~~ It's still behind a flag. Is there any other case where --target no-modules is needed?

If no-modules is deprecated, it should be removed in the next breaking change version (which is in the far future probably), but it also would add justification for primarily supporting ES modules in new features (like #3247 and #3034) to avoid additional effort (without breaking existing code, of course).

lukaslihotzki avatar Mar 14 '23 20:03 lukaslihotzki

I know one reason for it: Firefox didn't support ES module web workers until the current version 111. This is fixed now.

No, it's not. It's been implemented, but it's still behind a flag.

Once Firefox does support module workers, though, I think I'd be in favour of this. It would be kind of nice to be free of the baggage of no-modules.

@alexcrichton, do you have any thoughts on this?

Liamolucko avatar Mar 14 '23 22:03 Liamolucko

I'm in favor when Firefox actually stabilizes this and after that for a little bit until everybody updates.

Relevant issues

Being put behind a flag: https://bugzilla.mozilla.org/show_bug.cgi?id=1812628 Tracking issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1812591

daxpedda avatar Mar 14 '23 23:03 daxpedda

Seems reasonable to me to consider it deprecated!

alexcrichton avatar Mar 15 '23 14:03 alexcrichton

Worker modules are currently slated to be stable in Firefox 114.

See the release notes and the bugzilla tracking issue.

daxpedda avatar May 12 '23 21:05 daxpedda

Is there any other case where --target no-modules is needed?

Web workers. Workers are built with no-modules and loaded in new Worker(...) (such as with gloo-worker).

CC: @futursolo (as they implemented the gloo-worker crate)

ranile avatar Jun 04 '23 17:06 ranile

Please no. You can't make extensions or service workers without this

Mubelotix avatar May 12 '24 23:05 Mubelotix

Indeed, until all browsers, in this case Firefox (Bugzilla), support module workers in every context, this will have to wait.

Extensions don't support ES modules?

daxpedda avatar May 21 '24 14:05 daxpedda