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(worker): fix public path in worker #122

Merged
merged 1 commit into from
Mar 11, 2024
Merged

fix(worker): fix public path in worker #122

merged 1 commit into from
Mar 11, 2024

Conversation

kkirik
Copy link
Contributor

@kkirik kkirik commented Mar 11, 2024

The problem:
Worker doesn't work in storybook because webpack_public_path is empty string and dynamic imports inside worker get wrong public path.

@kkirik kkirik requested a review from ValeraS March 11, 2024 13:15
@@ -24,7 +24,7 @@ export {WebWorker as Worker, SharedWebWorker as SharedWorker};

function generateWorkerLoader(url: string | URL) {
// eslint-disable-next-line camelcase
const publicPath = __webpack_public_path__;
const publicPath = __webpack_public_path__ === '' ? '/' : __webpack_public_path__;
const workerPublicPath = publicPath.match(/^https?:\/\//)
? publicPath
: new URL(publicPath, window.location.href).toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it fix the problem?

Suggested change
: new URL(publicPath, window.location.href).toString();
: new URL(publicPath, window.location.origin).toString();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, It might works

@ValeraS ValeraS changed the title fix(worker): fixed public path in worker when __webpack_public_path__… fix(worker): fix public path in worker Mar 11, 2024
@kkirik kkirik merged commit 95babef into main Mar 11, 2024
2 checks passed
@kkirik kkirik deleted the fix/worker-path branch March 11, 2024 16:27
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