diff --git a/package.json b/package.json index a5ba4d9ea10b62..27a555bf973c39 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@types/picomatch": "^4.0.3", "@types/stylus": "^0.48.43", "@types/ws": "^8.18.1", - "@vitejs/release-scripts": "^1.7.0", + "@vitejs/release-scripts": "^1.7.1", "eslint": "^9.39.4", "eslint-plugin-import-x": "^4.16.2", "eslint-plugin-n": "^18.0.1", diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index 9f4875dd1db7fb..5926915bc33387 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,26 @@ +## [8.0.2](https://github.com/vitejs/vite/compare/plugin-legacy@8.0.1...plugin-legacy@8.0.2) (2026-05-14) +### Bug Fixes + +* **deps:** update all non-major dependencies ([#22143](https://github.com/vitejs/vite/issues/22143)) ([22b0166](https://github.com/vitejs/vite/commit/22b016612703320db45c64a2fe44472051ef5ec5)) +* **deps:** update all non-major dependencies ([#22382](https://github.com/vitejs/vite/issues/22382)) ([5c0cfcb](https://github.com/vitejs/vite/commit/5c0cfcb83dde2c6e25b6c3215dd622956bf29631)) +* **plugin-legacy:** remove modulepreload links for legacy-only builds ([#22332](https://github.com/vitejs/vite/issues/22332)) ([f3a0bc9](https://github.com/vitejs/vite/commit/f3a0bc90bcc529a12a520469b9d0fb6fa751107c)) + +### Miscellaneous Chores + +* **deps:** update dependency tsdown to ^0.21.10 ([#22333](https://github.com/vitejs/vite/issues/22333)) ([3b51e05](https://github.com/vitejs/vite/commit/3b51e050214c5a817c163838ab8643fe34c7d0c3)) +* **deps:** update dependency tsdown to ^0.21.9 ([#22267](https://github.com/vitejs/vite/issues/22267)) ([a0aef50](https://github.com/vitejs/vite/commit/a0aef50f6b51120df95cc11a7354af2afabe6a4a)) +* **deps:** update rolldown-related dependencies ([#21989](https://github.com/vitejs/vite/issues/21989)) ([0ded627](https://github.com/vitejs/vite/commit/0ded6274579e8bda6b22a7ba93b15d15b4c28b78)) +* **deps:** update rolldown-related dependencies ([#22421](https://github.com/vitejs/vite/issues/22421)) ([66b9eb3](https://github.com/vitejs/vite/commit/66b9eb35188007e0e9a1bd03b4be820016cad60b)) + +### Code Refactoring + +* upgrade to typescript 6 ([#22110](https://github.com/vitejs/vite/issues/22110)) ([cc41398](https://github.com/vitejs/vite/commit/cc41398c2cf0bb5061cf0ca5dc3b408ae7e41191)) + +### Build System + +* handle tsdown inlineOnly deprecation ([#22111](https://github.com/vitejs/vite/issues/22111)) ([86cbc6e](https://github.com/vitejs/vite/commit/86cbc6e5571aefd6278d6ecbbfb5ede8d4061940)) +* improve typecheck and linting ([#22230](https://github.com/vitejs/vite/issues/22230)) ([3770a53](https://github.com/vitejs/vite/commit/3770a53064e8da27d4cb8d595a2b038413e6abdb)) + ## [8.0.1](https://github.com/vitejs/vite/compare/plugin-legacy@8.0.0...plugin-legacy@8.0.1) (2026-03-26) ### Bug Fixes diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 91c21093abc78e..ce175cdf193eb3 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "8.0.1", + "version": "8.0.2", "type": "module", "license": "MIT", "author": "Evan You", diff --git a/packages/plugin-legacy/src/__tests__/index.spec.ts b/packages/plugin-legacy/src/__tests__/index.spec.ts new file mode 100644 index 00000000000000..2cbbc93d0b8028 --- /dev/null +++ b/packages/plugin-legacy/src/__tests__/index.spec.ts @@ -0,0 +1,45 @@ +import { describe, expect, test } from 'vitest' +import { modulePreloadLinkRE } from '../index' + +describe('modulePreloadLinkRE', () => { + const matches: Array<[string, string]> = [ + ['rel first', ''], + [ + 'rel after other attributes', + '', + ], + ['rel only', ''], + ['self-closing', ''], + ['self-closing with space', ''], + ['single quotes', ""], + [ + 'attributes across multiple lines', + '', + ], + ] + + for (const [name, html] of matches) { + test(`matches: ${name}`, () => { + expect(html.replace(modulePreloadLinkRE, '')).toBe('') + }) + } + + const nonMatches: Array<[string, string]> = [ + ['tag name with suffix', ''], + ['custom element with hyphen', ''], + ['bare link tag', ''], + ['stylesheet link', ''], + ['preload (not modulepreload)', ''], + [ + 'attribute name ending in rel', + '', + ], + ['mismatched quotes', `]*>/g // browsers supporting dynamic import + import.meta.resolve + async generator const modernTargetsEsbuild = [ @@ -641,7 +643,9 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { } } if (!genModern) { - html = html.replace(/ diff --git a/playground/hmr-full-bundle-mode/main.js b/playground/hmr-full-bundle-mode/main.js index 9438bf643f1960..752e33219a2537 100644 --- a/playground/hmr-full-bundle-mode/main.js +++ b/playground/hmr-full-bundle-mode/main.js @@ -19,6 +19,10 @@ workerUrl.addEventListener('message', (e) => { text('.worker-url', e.data) }) +document.querySelector('#load-dynamic').addEventListener('click', () => { + import('./dynamic.js') +}) + function text(el, text) { document.querySelector(el).textContent = text } diff --git a/playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts b/playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts index 4e6a3d7d0eb58b..4a57a8386ca13b 100644 --- a/playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts +++ b/playground/legacy/__tests__/no-polyfills/legacy-no-polyfills.spec.ts @@ -14,3 +14,11 @@ test.runIf(isBuild)('includes a script tag for SystemJS', async () => { .poll(() => page.getAttribute('#vite-legacy-entry', 'data-src')) .toMatch(/.\/assets\/index-legacy-(.+)\.js/) }) + +test.runIf(isBuild)( + 'does not emit modulepreload links for legacy-only output', + async () => { + await page.goto(viteTestUrl + '/no-polyfills.html') + expect(await page.content()).not.toContain('modulepreload') + }, +) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b86df33c6d3e43..ba5417aaf9cef7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: specifier: ^8.18.1 version: 8.18.1 '@vitejs/release-scripts': - specifier: ^1.7.0 - version: 1.7.0(conventional-commits-filter@5.0.0) + specifier: ^1.7.1 + version: 1.7.1(conventional-commits-filter@5.0.0) eslint: specifier: ^9.39.4 version: 9.39.4(jiti@2.6.1)(ms@2.1.3) @@ -4528,8 +4528,8 @@ packages: vite: workspace:* vue: ^3.2.25 - '@vitejs/release-scripts@1.7.0': - resolution: {integrity: sha512-4C+eoDs6yp/6kmnfOtuOWK+Dq0W3ws0eCs9k7w50P4YD7z+gMRUIyDbs0sGsJ4GjxN1WsS3qNfTT7ZpimtgeyA==} + '@vitejs/release-scripts@1.7.1': + resolution: {integrity: sha512-8YpovUu73Yb+ZnXIsR9VoF/yhbd2wTMhvJKDOjlB0bbOdm+ATl1l7Z7rskdX4CGzN7UfdvLcE6vGaHDCsirdpw==} '@vitejs/require@file:playground/json/dep-json-require': resolution: {directory: playground/json/dep-json-require, type: directory} @@ -7472,8 +7472,8 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true - semver@7.7.4: - resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==} + semver@7.8.0: + resolution: {integrity: sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==} engines: {node: '>=10'} hasBin: true @@ -9121,7 +9121,7 @@ snapshots: dependencies: '@simple-libs/child-process-utils': 1.0.1 '@simple-libs/stream-utils': 1.2.0 - semver: 7.7.4 + semver: 7.8.0 optionalDependencies: conventional-commits-filter: 5.0.0 conventional-commits-parser: 6.4.0 @@ -9948,7 +9948,7 @@ snapshots: '@pnpm/error': 1000.1.0 '@pnpm/semver.peer-range': 1000.0.0 '@pnpm/types': 1001.3.0 - semver: 7.7.4 + semver: 7.8.0 '@pnpm/read-project-manifest@1001.2.6': dependencies: @@ -9968,7 +9968,7 @@ snapshots: '@pnpm/semver.peer-range@1000.0.0': dependencies: - semver: 7.7.4 + semver: 7.8.0 '@pnpm/text.comments-parser@1000.0.0': dependencies: @@ -10598,7 +10598,7 @@ snapshots: '@typescript-eslint/visitor-keys': 8.59.2 debug: obug@1.0.2(ms@2.1.3) minimatch: 10.2.5 - semver: 7.7.4 + semver: 7.8.0 tinyglobby: 0.2.16 ts-api-utils: 2.5.0(typescript@6.0.2) typescript: 6.0.2 @@ -10826,7 +10826,7 @@ snapshots: vite: link:packages/vite vue: 3.5.34(typescript@6.0.2) - '@vitejs/release-scripts@1.7.0(conventional-commits-filter@5.0.0)': + '@vitejs/release-scripts@1.7.1(conventional-commits-filter@5.0.0)': dependencies: conventional-changelog: 7.2.0(conventional-commits-filter@5.0.0) conventional-changelog-conventionalcommits: 9.3.1 @@ -10834,7 +10834,7 @@ snapshots: picocolors: 1.1.1 prompts: 2.4.2 publint: 0.3.20 - semver: 7.7.4 + semver: 7.8.0 tinyexec: 1.1.2 transitivePeerDependencies: - conventional-commits-filter @@ -11668,7 +11668,7 @@ snapshots: conventional-commits-filter: 5.0.0 handlebars: 4.7.8 meow: 13.2.0 - semver: 7.7.4 + semver: 7.8.0 conventional-changelog@7.2.0(conventional-commits-filter@5.0.0): dependencies: @@ -11943,7 +11943,7 @@ snapshots: eslint-compat-utils@0.5.1(eslint@9.39.4): dependencies: eslint: 9.39.4(jiti@2.6.1)(ms@2.1.3) - semver: 7.7.4 + semver: 7.8.0 eslint-import-context@0.1.9(unrs-resolver@1.11.1): dependencies: @@ -11969,7 +11969,7 @@ snapshots: eslint-import-context: 0.1.9(unrs-resolver@1.11.1) is-glob: 4.0.3 minimatch: 10.2.5 - semver: 7.7.4 + semver: 7.8.0 stable-hash-x: 0.2.0 unrs-resolver: 1.11.1 optionalDependencies: @@ -11987,7 +11987,7 @@ snapshots: globals: 15.15.0 globrex: 0.1.2 ignore: 5.3.2 - semver: 7.7.4 + semver: 7.8.0 optionalDependencies: typescript: 6.0.2 @@ -13182,7 +13182,7 @@ snapshots: normalize-package-data@7.0.1: dependencies: hosted-git-info: 8.1.0 - semver: 7.7.4 + semver: 7.8.0 validate-npm-package-license: 3.0.4 normalize-path@3.0.0: {} @@ -14032,7 +14032,7 @@ snapshots: semver@6.3.1: {} - semver@7.7.4: {} + semver@7.8.0: {} send@1.2.1: dependencies: @@ -14061,7 +14061,7 @@ snapshots: dependencies: '@img/colour': 1.0.0 detect-libc: 2.1.2 - semver: 7.7.4 + semver: 7.8.0 optionalDependencies: '@img/sharp-darwin-arm64': 0.34.5 '@img/sharp-darwin-x64': 0.34.5 @@ -14448,7 +14448,7 @@ snapshots: picomatch: 4.0.4 rolldown: 1.0.1 rolldown-plugin-dts: 0.25.0(rolldown@1.0.1)(typescript@6.0.2)(vue-tsc@3.2.8) - semver: 7.7.4 + semver: 7.8.0 tinyexec: 1.1.2 tinyglobby: 0.2.16 tree-kill: 1.2.2