Skip to content

test: add configCase for ESM prefetch/preload under neutral target#20524

Merged
alexander-akait merged 1 commit intowebpack:mainfrom
aryanraj45:test/universal-esm-prefetch-preload
Feb 24, 2026
Merged

test: add configCase for ESM prefetch/preload under neutral target#20524
alexander-akait merged 1 commit intowebpack:mainfrom
aryanraj45:test/universal-esm-prefetch-preload

Conversation

@aryanraj45
Copy link
Contributor

Summary

ModuleChunkLoadingRuntimeModule enables prefetch/preload handlers for neutral platform targets (target: ["web", "node"]) via the isNeutralPlatform flag, and injects a typeof document === 'undefined' guard so they return early in Node environments. This code path had no test coverage.

This PR adds a configCase that compiles an ESM entry with webpackPrefetch/webpackPreload magic comments under target: ["web", "node"] and verifies:

  • web variant: prefetch (rel="prefetch") and preload (rel="modulepreload") links are correctly appended to document.head
  • node variant: handlers return early without crashing when document is not defined

What kind of change does this PR introduce?

test

Did you add tests for your changes?

This PR is the test. It adds test/configCases/target/universal-prefetch-preload/.

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?

No documentation needed

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

⚠️ No Changeset found

Latest commit: 583b3ab

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

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 24, 2026

Merging this PR will degrade performance by 29.37%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 142 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation benchmark "three-long", scenario '{"name":"mode-production","mode":"production"}' 3.2 s 2.6 s +22.1%
Memory benchmark "concatenate-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 555.2 KB 786.2 KB -29.37%

Comparing aryanraj45:test/universal-esm-prefetch-preload (583b3ab) with main (79ded34)

Open in CodSpeed

@alexander-akait alexander-akait merged commit 67c5aae into webpack:main Feb 24, 2026
53 of 55 checks passed
@github-actions
Copy link
Contributor

This PR is packaged and the instant preview is available (67c5aae).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@67c5aae
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@67c5aae
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@67c5aae

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