diff --git a/lerna.json b/lerna.json index 994295d044d7a..9355fbe99c56e 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "10.1.4-canary.6" + "version": "10.1.4-canary.7" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index e09c00d1e5ea3..6f3d24e9dcfa2 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "keywords": [ "react", "next", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 2449d07db0661..91e89d1df88cd 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 4fa854d6ca1bb..59375fa4447a5 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 32dea4ee5931b..1ddaaee909f16 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index ca9b07b1290c4..f5959c1bea53f 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 0d52eb0480fc8..50570b0ecc1fb 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-google-analytics/package.json b/packages/next-plugin-google-analytics/package.json index 2316aa5c61126..dce3be8f167bd 100644 --- a/packages/next-plugin-google-analytics/package.json +++ b/packages/next-plugin-google-analytics/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-google-analytics", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-google-analytics" diff --git a/packages/next-plugin-sentry/package.json b/packages/next-plugin-sentry/package.json index 72f98e80c32da..f6834afceb634 100644 --- a/packages/next-plugin-sentry/package.json +++ b/packages/next-plugin-sentry/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-sentry", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-sentry" diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 3a11bded79e39..0eea3a00f0062 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 3f7a0747f68c7..febafe25e237d 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 9e2d3a7fcbc49..9ebbaa0abac38 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next/client/dev/amp-dev.js b/packages/next/client/dev/amp-dev.js index f7bf79cddc83b..c4c829a680f53 100644 --- a/packages/next/client/dev/amp-dev.js +++ b/packages/next/client/dev/amp-dev.js @@ -1,6 +1,6 @@ /* globals __webpack_hash__ */ import EventSourcePolyfill from './event-source-polyfill' -import { getEventSourceWrapper } from './error-overlay/eventsource' +import { addMessageListener } from './error-overlay/eventsource' import { setupPing } from './on-demand-entries-utils' import { displayContent } from './fouc' @@ -68,9 +68,7 @@ async function tryApplyUpdates() { } } -getEventSourceWrapper({ - path: `${assetPrefix}/_next/webpack-hmr`, -}).addMessageListener((event) => { +addMessageListener((event) => { if (event.data === '\uD83D\uDC93') { return } diff --git a/packages/next/client/dev/dev-build-watcher.js b/packages/next/client/dev/dev-build-watcher.js index 6b37a4f71a4f0..75e5f68cb423b 100644 --- a/packages/next/client/dev/dev-build-watcher.js +++ b/packages/next/client/dev/dev-build-watcher.js @@ -1,4 +1,4 @@ -import { getEventSourceWrapper } from './error-overlay/eventsource' +import { addMessageListener } from './error-overlay/eventsource' export default function initializeBuildWatcher(toggleCallback) { const shadowHost = document.createElement('div') @@ -39,8 +39,8 @@ export default function initializeBuildWatcher(toggleCallback) { let timeoutId = null // Handle events - const evtSource = getEventSourceWrapper({ path: '/_next/webpack-hmr' }) - evtSource.addMessageListener((event) => { + + addMessageListener((event) => { // This is the heartbeat event if (event.data === '\uD83D\uDC93') { return diff --git a/packages/next/client/dev/error-overlay/eventsource.js b/packages/next/client/dev/error-overlay/eventsource.js index 163cffc98e0b2..8d64509c600c0 100644 --- a/packages/next/client/dev/error-overlay/eventsource.js +++ b/packages/next/client/dev/error-overlay/eventsource.js @@ -57,13 +57,10 @@ function EventSourceWrapper(options) { } } +export function addMessageListener(cb) { + eventCallbacks.push(cb) +} + export function getEventSourceWrapper(options) { - if (!options.ondemand) { - return { - addMessageListener: (cb) => { - eventCallbacks.push(cb) - }, - } - } return EventSourceWrapper(options) } diff --git a/packages/next/client/dev/error-overlay/hot-dev-client.js b/packages/next/client/dev/error-overlay/hot-dev-client.js index c0854a3890840..6dc6547ce5842 100644 --- a/packages/next/client/dev/error-overlay/hot-dev-client.js +++ b/packages/next/client/dev/error-overlay/hot-dev-client.js @@ -28,7 +28,7 @@ import * as DevOverlay from '@next/react-dev-overlay/lib/client' import stripAnsi from 'next/dist/compiled/strip-ansi' -import { getEventSourceWrapper } from './eventsource' +import { addMessageListener } from './eventsource' import formatWebpackMessages from './format-webpack-messages' // This alternative WebpackDevServer combines the functionality of: @@ -42,10 +42,10 @@ import formatWebpackMessages from './format-webpack-messages' let hadRuntimeError = false let customHmrEventHandler -export default function connect(options) { +export default function connect() { DevOverlay.register() - getEventSourceWrapper(options).addMessageListener((event) => { + addMessageListener((event) => { // This is the heartbeat event if (event.data === '\uD83D\uDC93') { return diff --git a/packages/next/client/dev/on-demand-entries-utils.js b/packages/next/client/dev/on-demand-entries-utils.js index 1c926177970a5..43fc5858a6f34 100644 --- a/packages/next/client/dev/on-demand-entries-utils.js +++ b/packages/next/client/dev/on-demand-entries-utils.js @@ -18,8 +18,10 @@ export function setupPing(assetPrefix, pathnameFn, retry) { // close current EventSource connection closePing() - const url = `${assetPrefix}/_next/webpack-hmr?page=${currentPage}` - evtSource = getEventSourceWrapper({ path: url, timeout: 5000, ondemand: 1 }) + evtSource = getEventSourceWrapper({ + path: `${assetPrefix}/_next/webpack-hmr?page=${currentPage}`, + timeout: 5000, + }) evtSource.addMessageListener((event) => { if (event.data.indexOf('{') === -1) return diff --git a/packages/next/client/dev/webpack-hot-middleware-client.js b/packages/next/client/dev/webpack-hot-middleware-client.js index 42e072896048c..2a411b68833b5 100644 --- a/packages/next/client/dev/webpack-hot-middleware-client.js +++ b/packages/next/client/dev/webpack-hot-middleware-client.js @@ -1,11 +1,7 @@ import connect from './error-overlay/hot-dev-client' -export default ({ assetPrefix }) => { - const options = { - path: `${assetPrefix}/_next/webpack-hmr`, - } - - const devClient = connect(options) +export default () => { + const devClient = connect() devClient.subscribeToHmrEvent((obj) => { if (obj.action === 'reloadPage') { diff --git a/packages/next/client/next-dev.js b/packages/next/client/next-dev.js index dc5b3625b1824..bd7a59ebde543 100644 --- a/packages/next/client/next-dev.js +++ b/packages/next/client/next-dev.js @@ -5,7 +5,7 @@ import initOnDemandEntries from './dev/on-demand-entries-client' import initWebpackHMR from './dev/webpack-hot-middleware-client' import initializeBuildWatcher from './dev/dev-build-watcher' import { displayContent } from './dev/fouc' -import { getEventSourceWrapper } from './dev/error-overlay/eventsource' +import { addMessageListener } from './dev/error-overlay/eventsource' import * as querystring from '../next-server/lib/router/utils/querystring' // Temporary workaround for the issue described here: @@ -25,7 +25,7 @@ const { } = window const prefix = assetPrefix || '' -const webpackHMR = initWebpackHMR({ assetPrefix: prefix }) +const webpackHMR = initWebpackHMR() window.next = next initNext({ webpackHMR }) @@ -72,7 +72,7 @@ initNext({ webpackHMR }) } } devPagesManifestListener.unfiltered = true - getEventSourceWrapper({}).addMessageListener(devPagesManifestListener) + addMessageListener(devPagesManifestListener) if (process.env.__NEXT_BUILD_INDICATOR) { initializeBuildWatcher((handler) => { diff --git a/packages/next/package.json b/packages/next/package.json index c8e96027df4bd..428622d93ca86 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -62,10 +62,10 @@ "dependencies": { "@babel/runtime": "7.12.5", "@hapi/accept": "5.0.1", - "@next/env": "10.1.4-canary.6", - "@next/polyfill-module": "10.1.4-canary.6", - "@next/react-dev-overlay": "10.1.4-canary.6", - "@next/react-refresh-utils": "10.1.4-canary.6", + "@next/env": "10.1.4-canary.7", + "@next/polyfill-module": "10.1.4-canary.7", + "@next/react-dev-overlay": "10.1.4-canary.7", + "@next/react-refresh-utils": "10.1.4-canary.7", "@opentelemetry/api": "0.14.0", "assert": "2.0.0", "ast-types": "0.13.2", @@ -148,7 +148,7 @@ "@babel/preset-typescript": "7.12.7", "@babel/traverse": "^7.12.10", "@babel/types": "7.12.12", - "@next/polyfill-nomodule": "10.1.4-canary.6", + "@next/polyfill-nomodule": "10.1.4-canary.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", "@taskr/watch": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index f54a24f7293ba..61aed2c5e8580 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index f399ea40ac9ee..2d8961c2d5039 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "10.1.4-canary.6", + "version": "10.1.4-canary.7", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js",