Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: support webpackPrefetch and webpackPreload for Worker chunks (#19373)#20299

Open
samarthsinh2660 wants to merge 1 commit intowebpack:mainfrom
samarthsinh2660:feat/19373-worker-prefetch-preload
Open

feat: support webpackPrefetch and webpackPreload for Worker chunks (#19373)#20299
samarthsinh2660 wants to merge 1 commit intowebpack:mainfrom
samarthsinh2660:feat/19373-worker-prefetch-preload

Conversation

@samarthsinh2660
Copy link
Contributor

Summary

This PR adds support for webpackPrefetch and webpackPreload magic comments for new Worker() chunks, addressing issue #19373.

Currently, dynamic imports support webpackPrefetch and webpackPreload magic comments to hint the browser to prefetch/preload chunks for better performance. This PR extends the same functionality to Worker chunks.

Example usage:

const worker = new Worker(
  /* webpackPrefetch: true */
  new URL("./worker.js", import.meta.url)
);

const worker2 = new Worker(
  /* webpackPreload: 5 */
  new URL("./heavy-worker.js", import.meta.url)
);

Closes #19373

What kind of change does this PR introduce?

feat - New feature extending prefetch/preload support to Worker chunks

Did you add tests for your changes?

Yes, added test case in test/configCases/worker/worker-prefetch-preload/:

  • should support webpackPrefetch for Worker
  • should support webpackPreload for Worker
  • should support webpackPrefetch with numeric order for Worker
  • should support webpackPreload with numeric order for Worker

Does this PR introduce a breaking change?

No. This is an additive feature using existing magic comment syntax.

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

Documentation should be updated to mention that webpackPrefetch and webpackPreload magic comments now work with new Worker() syntax, similar to dynamic import().

@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2026

⚠️ No Changeset found

Latest commit: c781429

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@samarthsinh2660 samarthsinh2660 force-pushed the feat/19373-worker-prefetch-preload branch 2 times, most recently from 61478c7 to 96e722e Compare January 12, 2026 09:30
@samarthsinh2660 samarthsinh2660 force-pushed the feat/19373-worker-prefetch-preload branch from 96e722e to c781429 Compare January 12, 2026 09:35
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 12, 2026

Merging this PR will not alter performance

✅ 72 untouched benchmarks


Comparing samarthsinh2660:feat/19373-worker-prefetch-preload (c781429) with main (d2a124d)

Open in CodSpeed

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.

support webpackPrefetch and webpackPreload for new Worker() chunk

1 participant