From 276d0bc247152af57ab99bad6a12ec7e87a4dbd1 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 1 Feb 2022 22:15:42 +0100 Subject: [PATCH 1/2] Group streaming experimental apis --- packages/next/client/index.tsx | 7 +++++-- packages/next/client/rsc/index.ts | 1 - packages/next/client/streaming/index.ts | 2 ++ packages/next/client/{rsc => streaming}/refresh.ts | 0 packages/next/client/{ => streaming}/vitals.ts | 2 +- packages/next/package.json | 6 ++---- packages/next/rsc.d.ts | 1 - packages/next/rsc.js | 1 - packages/next/streaming.d.ts | 1 + packages/next/streaming.js | 1 + packages/next/vitals.d.ts | 1 - packages/next/vitals.js | 4 ---- test/integration/relay-analytics-disabled/pages/index.js | 2 +- test/integration/relay-analytics/pages/index.js | 2 +- 14 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 packages/next/client/rsc/index.ts create mode 100644 packages/next/client/streaming/index.ts rename packages/next/client/{rsc => streaming}/refresh.ts (100%) rename packages/next/client/{ => streaming}/vitals.ts (95%) delete mode 100644 packages/next/rsc.d.ts delete mode 100644 packages/next/rsc.js create mode 100644 packages/next/streaming.d.ts create mode 100644 packages/next/streaming.js delete mode 100644 packages/next/vitals.d.ts delete mode 100644 packages/next/vitals.js diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index 3e7264a9663bb..5b258c0aa35e5 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -33,8 +33,11 @@ import measureWebVitals from './performance-relayer' import { RouteAnnouncer } from './route-announcer' import { createRouter, makePublicRouterInstance } from './router' import { getProperError } from '../lib/is-error' -import { flushBufferedVitalsMetrics, trackWebVitalMetric } from './vitals' -import { RefreshContext } from './rsc/refresh' +import { + flushBufferedVitalsMetrics, + trackWebVitalMetric, +} from './streaming/vitals' +import { RefreshContext } from './streaming/refresh' /// diff --git a/packages/next/client/rsc/index.ts b/packages/next/client/rsc/index.ts deleted file mode 100644 index 566fab06ab74b..0000000000000 --- a/packages/next/client/rsc/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { useRefreshRoot as unstable_useRefreshRoot } from './refresh' diff --git a/packages/next/client/streaming/index.ts b/packages/next/client/streaming/index.ts new file mode 100644 index 0000000000000..f6fc5aaf42e4b --- /dev/null +++ b/packages/next/client/streaming/index.ts @@ -0,0 +1,2 @@ +export { useRefreshRoot as unstable_useRefreshRoot } from './refresh' +export { useWebVitalsReport as unstable_useWebVitalsReport } from './vitals' diff --git a/packages/next/client/rsc/refresh.ts b/packages/next/client/streaming/refresh.ts similarity index 100% rename from packages/next/client/rsc/refresh.ts rename to packages/next/client/streaming/refresh.ts diff --git a/packages/next/client/vitals.ts b/packages/next/client/streaming/vitals.ts similarity index 95% rename from packages/next/client/vitals.ts rename to packages/next/client/streaming/vitals.ts index 32029868674d5..e239470457a57 100644 --- a/packages/next/client/vitals.ts +++ b/packages/next/client/streaming/vitals.ts @@ -1,5 +1,5 @@ import { useEffect, useRef } from 'react' -import { NextWebVitalsMetric } from '../pages/_app' +import { NextWebVitalsMetric } from '../../pages/_app' type ReportWebVitalsCallback = (webVitals: NextWebVitalsMetric) => any export const webVitalsCallbacks = new Set() diff --git a/packages/next/package.json b/packages/next/package.json index 1b31e1c960ec7..643194e658b47 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -44,10 +44,8 @@ "jest.d.ts", "amp.js", "amp.d.ts", - "vitals.js", - "vitals.d.ts", - "rsc.js", - "rsc.d.ts", + "streaming.js", + "streaming.d.ts", "index.d.ts", "types/index.d.ts", "types/global.d.ts", diff --git a/packages/next/rsc.d.ts b/packages/next/rsc.d.ts deleted file mode 100644 index 1e63004efc5fa..0000000000000 --- a/packages/next/rsc.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dist/client/rsc' diff --git a/packages/next/rsc.js b/packages/next/rsc.js deleted file mode 100644 index 64641581f242e..0000000000000 --- a/packages/next/rsc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/client/rsc') diff --git a/packages/next/streaming.d.ts b/packages/next/streaming.d.ts new file mode 100644 index 0000000000000..c0cc6709ecb1a --- /dev/null +++ b/packages/next/streaming.d.ts @@ -0,0 +1 @@ +export * from './dist/client/streaming' diff --git a/packages/next/streaming.js b/packages/next/streaming.js new file mode 100644 index 0000000000000..2d8b5c4f47e28 --- /dev/null +++ b/packages/next/streaming.js @@ -0,0 +1 @@ +module.exports = require('./dist/client/streaming') diff --git a/packages/next/vitals.d.ts b/packages/next/vitals.d.ts deleted file mode 100644 index ab967d34ab52e..0000000000000 --- a/packages/next/vitals.d.ts +++ /dev/null @@ -1 +0,0 @@ -export { useWebVitalsReport as unstable_useWebVitalsReport } from './dist/client/vitals' diff --git a/packages/next/vitals.js b/packages/next/vitals.js deleted file mode 100644 index 0cf2911ed439f..0000000000000 --- a/packages/next/vitals.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - unstable_useWebVitalsReport: require('./dist/client/vitals') - .useWebVitalsReport, -} diff --git a/test/integration/relay-analytics-disabled/pages/index.js b/test/integration/relay-analytics-disabled/pages/index.js index b5832179bbd84..d8064b2d5b1ad 100644 --- a/test/integration/relay-analytics-disabled/pages/index.js +++ b/test/integration/relay-analytics-disabled/pages/index.js @@ -1,4 +1,4 @@ -import { getBufferedVitalsMetrics } from 'next/dist/client/vitals' +import { getBufferedVitalsMetrics } from 'next/dist/client/streaming/vitals' if (typeof navigator !== 'undefined') { window.__BEACONS = window.__BEACONS || [] diff --git a/test/integration/relay-analytics/pages/index.js b/test/integration/relay-analytics/pages/index.js index c10829859fd1c..5cf09273d231b 100644 --- a/test/integration/relay-analytics/pages/index.js +++ b/test/integration/relay-analytics/pages/index.js @@ -1,6 +1,6 @@ /* global localStorage */ import { unstable_useWebVitalsReport } from 'next/vitals' -import { getBufferedVitalsMetrics } from 'next/dist/client/vitals' +import { getBufferedVitalsMetrics } from 'next/dist/client/streaming/vitals' if (typeof navigator !== 'undefined') { window.__BEACONS = window.__BEACONS || [] From 690ed065ffed5616203d73a8695b703180e111c7 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 1 Feb 2022 23:03:28 +0100 Subject: [PATCH 2/2] fix test --- test/integration/relay-analytics/pages/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/relay-analytics/pages/index.js b/test/integration/relay-analytics/pages/index.js index 5cf09273d231b..82b506fcc7bca 100644 --- a/test/integration/relay-analytics/pages/index.js +++ b/test/integration/relay-analytics/pages/index.js @@ -1,5 +1,5 @@ /* global localStorage */ -import { unstable_useWebVitalsReport } from 'next/vitals' +import { unstable_useWebVitalsReport } from 'next/streaming' import { getBufferedVitalsMetrics } from 'next/dist/client/streaming/vitals' if (typeof navigator !== 'undefined') {