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

Use non-inline workers in browsers without module worker support #2029

Closed
NotWoods opened this issue Feb 14, 2021 · 1 comment
Closed

Use non-inline workers in browsers without module worker support #2029

NotWoods opened this issue Feb 14, 2021 · 1 comment

Comments

@NotWoods
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'd like to build an app using large Web Worker scripts that runs in the latest version of Firefix & Safari.

Describe the solution you'd like
I want to have an alternate worker bundle output that can be used as a fallback if {type:'module'} workers aren't available. The scripts are large enough that I don't want to inline them, but instead use separate chunks. Duplication in each chunk is OK (although preferably not).

The bundled version wouldn't have any import statements, nor import() functions as dynamic import isn't supported in worker threads in Firefox.

try {
  new Worker('./moduule.js', { type: 'module' })
} catch (err) {
  new Worker('./bundle.js')
}

Describe alternatives you've considered
I think inline workers already remove import statements.

@yyx990803
Copy link
Member

The built workers (even not inlined) are pre-bundled so for production it should work even if the browser doesn't support module workers. If it doesn't, please open a bug report.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants