From f22b339ef3385e6fd85d9efa41a688f1742570a6 Mon Sep 17 00:00:00 2001 From: Frederico Maia Date: Tue, 30 Jul 2024 21:24:55 -0300 Subject: [PATCH 1/4] Fix Assets issue using the new async function. --- packages/vite-bundler/loading/vite-connection-handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite-bundler/loading/vite-connection-handler.ts b/packages/vite-bundler/loading/vite-connection-handler.ts index 0005b804a..074e0f0f8 100644 --- a/packages/vite-bundler/loading/vite-connection-handler.ts +++ b/packages/vite-bundler/loading/vite-connection-handler.ts @@ -18,7 +18,7 @@ export class ViteDevScripts { } } - public stringTemplate(): string | Promise { + public async stringTemplate(): Promise> { const { viteClientUrl, entrypointUrl } = this.urls; const viteClient = ``; const viteEntrypoint = ``; @@ -27,7 +27,7 @@ export class ViteDevScripts { return `${viteClient}\n${viteEntrypoint}`; } - return Assets.getText('loading/dev-server-splash.html') as string; + return await Assets.getTextAsync('loading/dev-server-splash.html') as string; } public injectScriptsInDOM() { From c76f60605eae540fa60d2097c8ddeae59923ba0d Mon Sep 17 00:00:00 2001 From: Frederico Maia Date: Tue, 30 Jul 2024 21:35:22 -0300 Subject: [PATCH 2/4] Fix function return type. --- packages/vite-bundler/loading/vite-connection-handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite-bundler/loading/vite-connection-handler.ts b/packages/vite-bundler/loading/vite-connection-handler.ts index 074e0f0f8..a62c8ce5b 100644 --- a/packages/vite-bundler/loading/vite-connection-handler.ts +++ b/packages/vite-bundler/loading/vite-connection-handler.ts @@ -17,8 +17,8 @@ export class ViteDevScripts { viteClientUrl: `${baseUrl}/@vite/client`, } } - - public async stringTemplate(): Promise> { + + public async stringTemplate(): Promise { const { viteClientUrl, entrypointUrl } = this.urls; const viteClient = ``; const viteEntrypoint = ``; From 2196c515b25ce68d3360adb5e2e67280a0da98d3 Mon Sep 17 00:00:00 2001 From: Frederico Maia Date: Tue, 30 Jul 2024 21:38:18 -0300 Subject: [PATCH 3/4] Shouldn't be necessary to use `as string`. --- packages/vite-bundler/loading/vite-connection-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite-bundler/loading/vite-connection-handler.ts b/packages/vite-bundler/loading/vite-connection-handler.ts index a62c8ce5b..0c40b6079 100644 --- a/packages/vite-bundler/loading/vite-connection-handler.ts +++ b/packages/vite-bundler/loading/vite-connection-handler.ts @@ -27,7 +27,7 @@ export class ViteDevScripts { return `${viteClient}\n${viteEntrypoint}`; } - return await Assets.getTextAsync('loading/dev-server-splash.html') as string; + return await Assets.getTextAsync('loading/dev-server-splash.html'); } public injectScriptsInDOM() { From 357afd39f74ab09fa8a83f0ead5f0cd7d9bd40c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Vatle?= Date: Fri, 27 Sep 2024 18:00:40 +0300 Subject: [PATCH 4/4] Add type definition for getTextAsync() --- packages/vite-bundler/types/global.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vite-bundler/types/global.d.ts b/packages/vite-bundler/types/global.d.ts index 90e437d1a..15f2e08e7 100644 --- a/packages/vite-bundler/types/global.d.ts +++ b/packages/vite-bundler/types/global.d.ts @@ -30,6 +30,10 @@ declare global { } function getDefaultOptions(): CompileOptions; } + + module Assets { + function getTextAsync(path: string): Promise; + } } export {}