Skip to content

Conversation

pranjalisr
Copy link

@pranjalisr pranjalisr commented Oct 11, 2025

Summary
Added Cross-Domain and Dynamic Web Workers to fix issue 6716

What kind of change does this PR introduce?
Added Cross-Domain and Dynamic Web Workers

Did you add tests for your changes?
Not Required

Does this PR introduce a breaking change?
No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Copy link

vercel bot commented Oct 11, 2025

@pranjalisr is attempting to deploy a commit to the OpenJS Foundation Team on Vercel.

A member of the Team first needs to authorize it.

/* global __webpack_public_path__, __webpack_require__ */

// Ensure the worker knows where to load chunks from
__webpack_public_path__ = __webpack_require__.p = self.location.origin + '/assets/';
Copy link
Member

Choose a reason for hiding this comment

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

the documentation around public path is correct, but as a user you shouldnt tap into the generated bundle/file directly.

Copy link
Author

Choose a reason for hiding this comment

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

the documentation around public path is correct, but as a user you shouldnt tap into the generated bundle/file directly.

Thanks for pointing that out. I’ve made some changes that don’t go directly into the generated bundle/file. Please have a look and share your feedback.

---
Note that this is only available in ESM. `Worker` in CommonJS syntax is not supported by either webpack or Node.js.
## Advanced: Cross-Domain and Dynamic Web Workers
Copy link
Member

Choose a reason for hiding this comment

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

No need to prefix "Advanced"

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the prefix "Advanced". Do you suggest anymore changes?

### Setting a dynamic public path safely
The recommended approach is to define `__webpack_public_path__` at the beginning of your worker entry file, before any imports.
Copy link
Member

Choose a reason for hiding this comment

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

where did you find the documentation for this?

Copy link
Author

Choose a reason for hiding this comment

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

where did you find the documentation for this?

The note about defining webpack_public_path before any imports is based on the official https://webpack.js.org/guides/public-path/#on-the-fly documentation.

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.

2 participants