From 67412dbe65555613d1e343f859a919d5716ee3e6 Mon Sep 17 00:00:00 2001 From: Hana Date: Mon, 28 Sep 2026 15:29:10 +0800 Subject: [PATCH] test(bundled-dev): accept a rolldown dev runtime with no helper imports --- .../node/__tests__/plugins/clientInjections.spec.ts | 10 +++++----- .../__tests__/hmr-full-bundle-mode.spec.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/clientInjections.spec.ts b/packages/vite/src/node/__tests__/plugins/clientInjections.spec.ts index 172d3cba589fdf..b2a5e8a43228f2 100644 --- a/packages/vite/src/node/__tests__/plugins/clientInjections.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/clientInjections.spec.ts @@ -2,17 +2,17 @@ import path from 'node:path' import { expect, test } from 'vitest' import { getRolldownDevRuntimeFiles } from '../../plugins/clientInjections' -// The runtime entry imports its helper file with a relative path. Catch a rolldown layout -// change here, instead of as a 404 in the browser. +// Catch a rolldown layout change here, instead of as a 404 in the browser. The runtime may +// be one file with no imports, or an entry that imports helper files with relative paths. test('serves every file the rolldown dev runtime imports', () => { const files = getRolldownDevRuntimeFiles() - let checked = 0 + expect(files.get('@rolldown/experimental-runtime.mjs')).toContain( + 'DevRuntime', + ) for (const [urlPath, source] of files) { for (const match of source.matchAll(/\bfrom\s*['"](\.\.?\/[^'"]+)['"]/g)) { const imported = path.posix.join(path.posix.dirname(urlPath), match[1]) expect(files.has(imported), `${urlPath} imports ${match[1]}`).toBe(true) - checked++ } } - expect(checked).toBeGreaterThan(0) }) diff --git a/playground/hmr-full-bundle-mode/__tests__/hmr-full-bundle-mode.spec.ts b/playground/hmr-full-bundle-mode/__tests__/hmr-full-bundle-mode.spec.ts index 45dcaee5172327..447031b45841a8 100644 --- a/playground/hmr-full-bundle-mode/__tests__/hmr-full-bundle-mode.spec.ts +++ b/playground/hmr-full-bundle-mode/__tests__/hmr-full-bundle-mode.spec.ts @@ -48,7 +48,7 @@ if (isBuild) { expect(await client.text()).toContain(`from "${runtimeUrl.pathname}"`) const runtime = await page.request.get(runtimeUrl.href) expect(runtime.status()).toBe(200) - expect(await runtime.text()).toContain('class DevRuntime') + expect(await runtime.text()).toContain('DevRuntime') const loaded: string[] = await page.evaluate(() => performance.getEntriesByType('resource').map((entry) => entry.name), )