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

fix(compiler): try to create web worker with the workerPath before falling back to blob #3513

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeski-bright
Copy link

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Unit tests (npm test) were run locally and passed
  • E2E Tests (npm run test.karma.prod) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

GitHub Issue Number: #3512

Currently the worker plugin creates the Web Worker by first creating a blob of a script which loads the actual script via importScripts. However the path to the script is calculated via new URL(<file_name>, import.meta.url), which generates a relative path for some frameworks (as Nextjs mentioned in the issue). I would expect most SSR frameworks to do this to avoid mismatches between the server and client. The importScripts method fails on loading a relative path however.

What is the new behavior?

Before loading the worker in the current way, try to create it with the resolved script path directly. In case of error, fall back to the current implementation.
This is in line with src/compiler/sys/worker/web-worker-main.ts

Does this introduce a breaking change?

  • Yes
  • No

Testing

Clone the reproduction repo from the issue & apply this patch to stencil. The web worker should start now.

Other information

@jeski-bright jeski-bright requested a review from a team August 5, 2022 13:13
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

Successfully merging this pull request may close these issues.

None yet

1 participant