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: check document before detect script rel #13559

Merged
merged 2 commits into from Jul 4, 2023

Conversation

manucorporat
Copy link
Contributor

Description

I am trying to experimentally reuse the same modules in main and worker thread, i keep getting crashes becasue of this function, which checks document before i have any chance to polyfill globalThis.

Additional context

This might be the beginning of reusing ES modules across main and worker thread.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jun 19, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@bluwy
Copy link
Member

bluwy commented Jun 20, 2023

Looks like it's added for module preloading. Would that work in worker threads? Or is it expected that it'll be a no-op in worker threads, but you'd still want to enable it generally?

@manucorporat
Copy link
Contributor Author

No, it wont work in worker threads (but i am fine with that), the issue is that this piece of code runs before i have the chance to polyfill any globalThis.document, crashing the worker, making it very hard to reuse the same modules in the worker.

bluwy
bluwy previously approved these changes Jun 21, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm fine with this for now. It would be even better if scriptRel can be computed lazily to also prevent this.

EDIT: there seems to be a formatting error.

@patak-dev patak-dev enabled auto-merge (squash) July 4, 2023 10:35
@patak-dev patak-dev merged commit be4b0c0 into vitejs:main Jul 4, 2023
13 checks passed
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

3 participants