Skip to content

Commit e77e23d

Browse files
committed
wip: update
1 parent 9f740e2 commit e77e23d

File tree

6 files changed

+39
-39
lines changed

6 files changed

+39
-39
lines changed

packages/vite/src/node/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
RollupError,
2222
RollupLog,
2323
WarningHandlerWithDefault,
24+
WatcherOptions,
2425
} from 'rolldown'
2526
import {
2627
loadFallbackPlugin as nativeLoadFallbackPlugin,
@@ -70,7 +71,6 @@ import { ssrManifestPlugin } from './ssr/ssrManifestPlugin'
7071
import { buildLoadFallbackPlugin } from './plugins/loadFallback'
7172
import { findNearestMainPackageData, findNearestPackageData } from './packages'
7273
import type { PackageCache } from './packages'
73-
import type { WatcherOptions } from './watch'
7474
import {
7575
convertToNotifyOptions,
7676
getResolvedOutDirs,

packages/vite/src/node/watch.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { EventEmitter } from 'node:events'
22
import path from 'node:path'
33
import type { FSWatcher, WatchOptions } from 'dep-types/chokidar'
4-
import type { InputOptions, OutputOptions } from 'rolldown'
4+
import type { OutputOptions, WatcherOptions } from 'rolldown'
55
import colors from 'picocolors'
66
import { escapePath } from 'tinyglobby'
77
import { withTrailingSlash } from '../shared/utils'
88
import { arraify, normalizePath } from './utils'
99
import type { Logger } from './logger'
1010

11-
// TODO: expose type from rolldown
12-
export type WatcherOptions = Exclude<InputOptions['watch'], false | undefined>
13-
1411
export function getResolvedOutDirs(
1512
root: string,
1613
outDir: string,

playground/assets/__tests__/assets.spec.ts

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getColor,
99
isBuild,
1010
isServe,
11+
isWindows,
1112
listAssets,
1213
notifyRebuildComplete,
1314
page,
@@ -633,31 +634,35 @@ test.runIf(isBuild)('manifest', async () => {
633634
}
634635
})
635636

636-
describe.runIf(isBuild)('css and assets in css in build watch', () => {
637-
test('css will not be lost and css does not contain undefined', async () => {
638-
editFile('index.html', (code) => code.replace('Assets', 'assets'))
639-
await notifyRebuildComplete(watcher)
640-
const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo')
641-
expect(cssFile).not.toBe('')
642-
expect(cssFile).not.toMatch(/undefined/)
643-
})
637+
// TODO: skip on Windows due to https://github.com/rolldown/rolldown/issues/4385
638+
describe.runIf(isBuild && !isWindows)(
639+
'css and assets in css in build watch',
640+
() => {
641+
test('css will not be lost and css does not contain undefined', async () => {
642+
editFile('index.html', (code) => code.replace('Assets', 'assets'))
643+
await notifyRebuildComplete(watcher)
644+
const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo')
645+
expect(cssFile).not.toBe('')
646+
expect(cssFile).not.toMatch(/undefined/)
647+
})
644648

645-
test('import module.css', async () => {
646-
expect(await getColor('#foo')).toBe('red')
647-
editFile('css/foo.module.css', (code) => code.replace('red', 'blue'))
648-
await notifyRebuildComplete(watcher)
649-
await page.reload()
650-
expect(await getColor('#foo')).toBe('blue')
651-
})
649+
test('import module.css', async () => {
650+
expect(await getColor('#foo')).toBe('red')
651+
editFile('css/foo.module.css', (code) => code.replace('red', 'blue'))
652+
await notifyRebuildComplete(watcher)
653+
await page.reload()
654+
expect(await getColor('#foo')).toBe('blue')
655+
})
652656

653-
test('import with raw query', async () => {
654-
expect(await page.textContent('.raw-query')).toBe('foo')
655-
editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'))
656-
await notifyRebuildComplete(watcher)
657-
await page.reload()
658-
expect(await page.textContent('.raw-query')).toBe('zoo')
659-
})
660-
})
657+
test('import with raw query', async () => {
658+
expect(await page.textContent('.raw-query')).toBe('foo')
659+
editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'))
660+
await notifyRebuildComplete(watcher)
661+
await page.reload()
662+
expect(await page.textContent('.raw-query')).toBe('zoo')
663+
})
664+
},
665+
)
661666

662667
test('inline style test', async () => {
663668
expect(await getBg('.inline-style')).toMatch(assetMatch)

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"convert-source-map": "^2.0.0",
1111
"css-color-names": "^1.0.1",
1212
"kill-port": "^1.6.1",
13-
"rolldown": "1.0.0-beta.8-commit.2686eb1"
13+
"rolldown": "1.0.0-beta.8-commit.a720367"
1414
}
1515
}

playground/vitestSetup.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ import {
2020
preview,
2121
} from 'vite'
2222
import type { Browser, Page } from 'playwright-chromium'
23-
import type { RolldownWatcher, RollupError } from 'rolldown'
23+
import type {
24+
RolldownWatcher,
25+
RolldownWatcherEvent,
26+
RollupError,
27+
} from 'rolldown'
2428
import type { RunnerTestFile } from 'vitest'
2529
import { beforeAll, inject } from 'vitest'
2630

27-
type RolldownWatcherEvent = any // TODO: export type from rolldown
28-
2931
// #region env
3032

3133
export const workspaceRoot = path.resolve(__dirname, '../')
@@ -309,11 +311,7 @@ export async function notifyRebuildComplete(
309311
resolveFn = resolve
310312
})
311313

312-
// During tests we edit the files too fast and sometimes chokidar
313-
// misses change events, so wait 100ms for consistency
314-
await new Promise<void>((resolve) => setTimeout(resolve, 100))
315-
316-
// TODO: not supported yet
314+
// TODO: not supported yet (https://github.com/rolldown/rolldown/issues/4382)
317315
// return watcher.off('event', callback)
318316
return watcher
319317
}

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)