Skip to content

Commit 746ee4e

Browse files
committed
wip: update
1 parent 5606b47 commit 746ee4e

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

packages/vite/src/client/client.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="rolldown/experimental/runtime-types" />
21
import type { ErrorPayload, HotPayload } from '#types/hmrPayload'
32
import type { ViteHotContext } from '#types/hot'
43
import { HMRClient, HMRContext } from '../shared/hmr'
@@ -618,24 +617,19 @@ export function injectQuery(url: string, queryToInject: string): string {
618617

619618
export { ErrorOverlay }
620619

620+
// TODO: proper types
621+
declare let DevRuntime: { new (socket: any): any } | undefined
622+
621623
if (isFullBundleMode && typeof DevRuntime !== 'undefined') {
622624
class ViteDevRuntime extends DevRuntime {
623-
override createModuleHotContext(moduleId: string) {
625+
createModuleHotContext(moduleId: string) {
624626
const ctx = createHotContext(moduleId)
625-
// @ts-expect-error TODO: support CSS
626-
ctx._internal = {
627-
updateStyle,
628-
removeStyle,
629-
}
630-
// @ts-expect-error TODO: support this function (used by plugin-react)
631-
ctx.getExports = async () =>
632-
// @ts-expect-error __rolldown_runtime__ / ctx.ownerPath
633-
__rolldown_runtime__.loadExports(ctx.ownerPath)
627+
// @ts-expect-error TODO: support CSS properly
628+
ctx._internal = { updateStyle, removeStyle }
634629
return ctx
635630
}
636631

637-
override applyUpdates(_boundaries: string[]): void {
638-
// TODO: how should this be handled?
632+
applyUpdates(_boundaries: string[]): void {
639633
// noop, handled in the HMR client
640634
}
641635
}

packages/vite/src/node/plugins/clientInjections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function getHmrImplementation(
138138
const replacer = await createClientConfigValueReplacer(config)
139139
return (
140140
replacer(content)
141-
// the rolldown runtime shouldn't be importer a module
141+
// the rolldown runtime cannot import a module
142142
.replace(/import\s*['"]@vite\/env['"]/, '')
143143
)
144144
}

packages/vite/src/node/plugins/define.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ export async function replaceDefine(
221221
})
222222

223223
if (result.errors.length > 0) {
224-
// TODO: better error message
225224
throw new AggregateError(result.errors, 'oxc transform error')
226225
}
227226

packages/vite/src/node/server/environments/fullBundleEnvironment.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ export class FullBundleDevEnvironment extends DevEnvironment {
247247
)
248248
}
249249

250-
// TODO: need to check if this is enough
251250
this.handleHmrOutput(client, [m.path], update, {
252251
firstInvalidatedBy: m.firstInvalidatedBy,
253252
})
@@ -286,10 +285,6 @@ export class FullBundleDevEnvironment extends DevEnvironment {
286285
output.assetFileNames = 'assets/[name]-[hash][extname]'
287286
output.minify = false
288287
output.sourcemap = true
289-
// output.advancedChunks ||= {}
290-
// output.advancedChunks.groups = [
291-
// { name: 'chunk', maxSize: 1024 * 1024 },
292-
// ]
293288
}
294289
} else {
295290
rolldownOptions.output ??= {}
@@ -298,12 +293,7 @@ export class FullBundleDevEnvironment extends DevEnvironment {
298293
rolldownOptions.output.assetFileNames = 'assets/[name]-[hash][extname]'
299294
rolldownOptions.output.minify = false
300295
rolldownOptions.output.sourcemap = true
301-
// rolldownOptions.output.advancedChunks ||= {}
302-
// rolldownOptions.output.advancedChunks.groups = [
303-
// { name: 'chunk', maxSize: 1024 * 1024 },
304-
// ]
305296
}
306-
// rolldownOptions.experimental.strictExecutionOrder = true
307297

308298
return rolldownOptions
309299
}

packages/vite/src/node/server/middlewares/indexHtml.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,26 @@ async function generateFallbackHtml(server: ViteDevServer) {
565565
${hmrRuntime.replaceAll('</script>', '<\\/script>')}
566566
</script>
567567
<style>
568+
:root {
569+
--page-bg: #ffffff;
570+
--text-color: #1d1d1f;
571+
--spinner-track: #f5f5f7;
572+
--spinner-accent: #0071e3;
573+
}
574+
@media (prefers-color-scheme: dark) {
575+
:root {
576+
--page-bg: #1e1e1e;
577+
--text-color: #f5f5f5;
578+
--spinner-track: #424242;
579+
}
580+
}
581+
568582
body {
569583
margin: 0;
570584
min-height: 100vh;
571585
display: flex;
586+
background-color: var(--page-bg);
587+
color: var(--text-color);
572588
}
573589
574590
.container {
@@ -582,8 +598,8 @@ async function generateFallbackHtml(server: ViteDevServer) {
582598
width: 3rem;
583599
height: 3rem;
584600
margin: 2rem auto;
585-
border: 3px solid #f5f5f7;
586-
border-top-color: #0071e3;
601+
border: 3px solid var(--spinner-track);
602+
border-top-color: var(--spinner-accent);
587603
border-radius: 50%;
588604
animation: spin 1s linear infinite;
589605
}

packages/vite/src/node/server/middlewares/rejectInvalidRequest.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { Connect } from '#dep-types/connect'
22

3-
// disallows request that contains `#` in the URL
3+
/**
4+
* disallows request that contains `#` in the URL
5+
*/
46
export function rejectInvalidRequestMiddleware(): Connect.NextHandleFunction {
57
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
68
return function viteRejectInvalidRequestMiddleware(req, res, next) {

0 commit comments

Comments
 (0)