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

Allow to use modules with type="text/partytown" #195

Closed
crisgrim opened this issue Jun 7, 2022 · 3 comments
Closed

Allow to use modules with type="text/partytown" #195

crisgrim opened this issue Jun 7, 2022 · 3 comments

Comments

@crisgrim
Copy link

crisgrim commented Jun 7, 2022

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.

@adamdbradley
Copy link
Contributor

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

@frandiox
Copy link

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="..." />.

@maiieul
Copy link

maiieul commented Jul 9, 2023

Seems like Firefox supports ESM since the 6th of June. Shouldn't this be reopened @adamdbradley?

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

No branches or pull requests

4 participants