From f6d2e25eab0572d5a48fd3de3f7a5123a3a6da87 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 30 Aug 2023 11:12:31 +0000 Subject: [PATCH] update changed APIs --- packages/next-swc/crates/next-core/js/src/dev/client.ts | 9 +++++++-- .../crates/next-core/js/src/dev/hot-reloader.tsx | 2 ++ .../next-swc/crates/next-core/js/src/entry/fallback.tsx | 2 ++ .../crates/next-core/js/src/entry/next-hydrate.tsx | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/next-swc/crates/next-core/js/src/dev/client.ts b/packages/next-swc/crates/next-core/js/src/dev/client.ts index 1c56f6a9ac70f..db9d09bef7d30 100644 --- a/packages/next-swc/crates/next-core/js/src/dev/client.ts +++ b/packages/next-swc/crates/next-core/js/src/dev/client.ts @@ -1,10 +1,15 @@ import { connect } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client' -import { connectHMR } from '@vercel/turbopack-ecmascript-runtime/dev/client/websocket' +import { + connectHMR, + addMessageListener, + sendMessage, +} from '@vercel/turbopack-ecmascript-runtime/dev/client/websocket' import { register, ReactDevOverlay } from '../overlay/client' export function initializeHMR(options: { assetPrefix: string }) { connect({ - assetPrefix: options.assetPrefix, + addMessageListener, + sendMessage, }) connectHMR({ assetPrefix: options.assetPrefix, diff --git a/packages/next-swc/crates/next-core/js/src/dev/hot-reloader.tsx b/packages/next-swc/crates/next-core/js/src/dev/hot-reloader.tsx index 0b1734bd4c140..77d5a4c74a57c 100644 --- a/packages/next-swc/crates/next-core/js/src/dev/hot-reloader.tsx +++ b/packages/next-swc/crates/next-core/js/src/dev/hot-reloader.tsx @@ -5,6 +5,7 @@ import { useRouter, usePathname } from 'next/dist/client/components/navigation' import { useEffect } from 'react' import { subscribeToUpdate } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client' import { ReactDevOverlay } from './client' +import { sendMessage } from '@vercel/turbopack-ecmascript-runtime/dev/client/websocket' type HotReloadProps = React.PropsWithChildren<{ assetPrefix?: string @@ -22,6 +23,7 @@ export default function HotReload({ children }: HotReloadProps) { rsc: '1', }, }, + sendMessage, (update) => { if (update.type !== 'issues') { router.refresh() diff --git a/packages/next-swc/crates/next-core/js/src/entry/fallback.tsx b/packages/next-swc/crates/next-core/js/src/entry/fallback.tsx index 90309991edfd0..dc5c9e2578757 100644 --- a/packages/next-swc/crates/next-core/js/src/entry/fallback.tsx +++ b/packages/next-swc/crates/next-core/js/src/entry/fallback.tsx @@ -4,6 +4,7 @@ import { createRoot } from 'react-dom/client' import { initializeHMR, ReactDevOverlay } from '../dev/client' import { subscribeToUpdate } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client' +import { sendMessage } from '@vercel/turbopack-ecmascript-runtime/dev/client/websocket' const pageChunkPath = location.pathname.slice(1) @@ -14,6 +15,7 @@ subscribeToUpdate( accept: 'text/html', }, }, + sendMessage, (update) => { if (update.type === 'restart' || update.type === 'notFound') { location.reload() diff --git a/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx b/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx index 94e32fff86d2a..a6cc01a017f89 100644 --- a/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx +++ b/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx @@ -9,6 +9,7 @@ import { import { formatWithValidation } from 'next/dist/shared/lib/router/utils/format-url' import { initializeHMR } from '../dev/client' import { subscribeToUpdate } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client' +import { sendMessage } from '@vercel/turbopack-ecmascript-runtime/dev/client/websocket' ;(self as any).__next_set_public_path__ = () => {} async function loadPageChunk(assetPrefix: string, chunkData: ChunkData) { @@ -83,6 +84,7 @@ function subscribeToPageManifest({ assetPrefix }: { assetPrefix: string }) { { path: '_next/static/development/_devPagesManifest.json', }, + sendMessage, (update) => { if (['restart', 'notFound', 'partial'].includes(update.type)) { return @@ -169,6 +171,7 @@ function subscribeToPageData({ 'x-nextjs-data': '1', }, }, + sendMessage, (update) => { if (update.type !== 'restart') { return