Skip to content

fix(plugin-legacy): remove modulepreload links for legacy-only builds - #22332

Merged
sapphi-red merged 3 commits into
vitejs:mainfrom
cyphercodes:fix-legacy-preload-modern-disabled
May 14, 2026
Merged

sapphi-red merged 3 commits into
vitejs:mainfrom
cyphercodes:fix-legacy-preload-modern-disabled

Conversation

@cyphercodes

Copy link
Copy Markdown
Contributor

Summary

  • remove rel="modulepreload" links when plugin-legacy builds legacy-only HTML
  • keep the existing removal of modern module scripts in the same branch
  • add build-mode coverage for the legacy-only no-polyfills playground

Fixes #22320

Verification

  • pnpm install --ignore-scripts --frozen-lockfile
  • pnpm exec oxfmt --check packages/plugin-legacy/src/index.ts playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts
  • pnpm exec eslint --cache packages/plugin-legacy/src/index.ts playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts
  • pnpm --filter='./packages/vite' run build
  • pnpm --filter='./packages/plugin-legacy' run build
  • VITE_TEST_BUILD=1 pnpm exec vitest run playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts -c vitest.config.e2e.ts

Note: my fork's default branch is stale enough that pushing a branch directly from current upstream was rejected by GitHub for workflow-scope reasons. I pushed the same focused change on top of the fork branch instead.

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) feat: library mode labels May 14, 2026

@sapphi-red sapphi-red left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The regex wasn't working so I updated it. Also added some tests

@sapphi-red
sapphi-red merged commit f3a0bc9 into vitejs:main May 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-edge-case Bug, but has workaround or limited in scope (priority) plugin: legacy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-legacy: <link rel="modulepreload"> emitted for SystemJS chunks when renderModernChunks: false

2 participants