Closed crisgrim closed 2 years ago
At this time we'll hold off on this feature request since at this time web workers do not have have full support for ES module: https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker
It seems Safari already supports ESM, and the only one remaining is Firefox 😬
Question: when ESM is fully supported, would that mean a module script could run import
and new URL(import.meta.url)
? We are considering using something like this in @shopify/hydrogen
and would love to have compatibility with Partytown in the future by just changing <script type="module" src="..." />
to <script type="text/partytown" src="..." />
.
Seems like Firefox supports ESM since the 6th of June. Shouldn't this be reopened @adamdbradley?
@adamdbradley Firefox got support 1 year ago. Maybe consider support for ESM in partytown scripts
Any updates?
Is your feature request related to a problem? Please describe. I would like to try Partytown with some internal libraries that we are using with type="module" and nomodule. But the point is that if I include the
type="text/partytown"
then, when they are loaded they have been included as regular scripts. And it doesn't work.I received this error in the console: SyntaxError: Cannot use import statement outside a module.
Describe the solution you'd like Be able to use partytown with module and nomodule scripts.
Describe alternatives you've considered I think that I can provide you an idea about a possible solution. When you do the replacement of these assets on the page you can look for the extension and if the file ends with
.esm.js
is a module. If not, it's a nomodule.