private incrementalCache: IncrementalCache
protected router: Router
protected dynamicRoutes?: DynamicRoutes
@@ -252,18 +251,6 @@ export default class Server {
this.router = new Router(this.generateRoutes())
this.setAssetPrefix(assetPrefix)
- // call init-server middleware, this is also handled
- // individually in serverless bundles when deployed
- if (!dev && this.nextConfig.experimental.plugins) {
- const initServer = require(join(this.serverBuildDir, 'init-server.js'))
- .default
- this.onErrorMiddleware = require(join(
- this.serverBuildDir,
- 'on-error-server.js'
- )).default
- initServer()
- }
-
this.incrementalCache = new IncrementalCache({
dev,
distDir: this.distDir,
@@ -294,9 +281,6 @@ export default class Server {
}
public logError(err: Error): void {
- if (this.onErrorMiddleware) {
- this.onErrorMiddleware({ err })
- }
if (this.quiet) return
console.error(err)
}
@@ -1157,8 +1141,7 @@ export default class Server {
query,
pageModule,
this.renderOpts.previewProps,
- false,
- this.onErrorMiddleware
+ false
)
return true
}
diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx
index df83949222c9a..246b4a3e8f4ae 100644
--- a/packages/next/pages/_document.tsx
+++ b/packages/next/pages/_document.tsx
@@ -56,13 +56,6 @@ function getDocumentFiles(
* Commonly used for implementing server side rendering for `css-in-js` libraries.
*/
export default class Document extends Component {
- static headTagsMiddleware = process.env.__NEXT_PLUGINS
- ? import(
- // @ts-ignore loader syntax
- 'next-plugin-loader?middleware=document-head-tags-server!'
- )
- : () => []
-
/**
* `getInitialProps` hook returns the context object with the addition of `renderPage`.
* `renderPage` callback executes `React` rendering logic synchronously to support server-rendering wrappers
diff --git a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/package.json b/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/package.json
deleted file mode 100644
index 3cbd5ff9ae55c..0000000000000
--- a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/package.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "@next/plugin-google-analytics",
- "version": "0.0.1",
- "nextjs": {
- "name": "Google Analytics",
- "required-env": [
- "GA_TRACKING_ID"
- ]
- },
- "peerDependencies": {
- "next": "*"
- }
-}
diff --git a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/babel-preset-build.js b/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/babel-preset-build.js
deleted file mode 100644
index d63f2c18e8949..0000000000000
--- a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/babel-preset-build.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = function babelPresetBuild(ctx, config) {
- // options.plugins
- // options.presets
-}
diff --git a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/document-head-tags-server.js b/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/document-head-tags-server.js
deleted file mode 100644
index f50cef9bc9b64..0000000000000
--- a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/document-head-tags-server.js
+++ /dev/null
@@ -1,22 +0,0 @@
-export default async function headTags () {
- return (
- <>
-
-
- >
- )
-}
diff --git a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-client.js b/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-client.js
deleted file mode 100644
index d3667fac71cca..0000000000000
--- a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-client.js
+++ /dev/null
@@ -1,4 +0,0 @@
-export default async function initClient(ctx, config) {
- window.didClientInit = true
- window.initClientConfig = config.hello
-}
diff --git a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-server.js b/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-server.js
deleted file mode 100644
index 1bed8b9fced33..0000000000000
--- a/test/integration/next-plugins/app/node_modules/@next/plugin-google-analytics/src/on-init-server.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default async function initServer() {
- console.log('hi from init server')
-}
\ No newline at end of file
diff --git a/test/integration/next-plugins/app/package.json b/test/integration/next-plugins/app/package.json
deleted file mode 100644
index ae559b125d822..0000000000000
--- a/test/integration/next-plugins/app/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "dependencies": {
- "@next/plugin-google-analytics": "latest"
- }
-}
diff --git a/test/integration/next-plugins/app/pages/another.js b/test/integration/next-plugins/app/pages/another.js
deleted file mode 100644
index 1539408539e1c..0000000000000
--- a/test/integration/next-plugins/app/pages/another.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import Link from 'next/link'
-import Head from 'next/head'
-
-export default () => (
- <>
-
- Another | next-plugins
-
- Another
-
- home
-
-
- something
-
- >
-)
diff --git a/test/integration/next-plugins/app/pages/index.js b/test/integration/next-plugins/app/pages/index.js
deleted file mode 100644
index a5542ff3b3194..0000000000000
--- a/test/integration/next-plugins/app/pages/index.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import Link from 'next/link'
-import Head from 'next/head'
-
-const Page = () => (
- <>
-
- Home | next-plugins
-
- Home
-
- another
-
-
- something
-
- >
-)
-Page.getInitialProps = () => ({})
-
-export default Page
diff --git a/test/integration/next-plugins/app/pages/something.js b/test/integration/next-plugins/app/pages/something.js
deleted file mode 100644
index 6f336b47ae341..0000000000000
--- a/test/integration/next-plugins/app/pages/something.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import Link from 'next/link'
-import Head from 'next/head'
-
-export default () => (
- <>
-
- Something | next-plugins
-
- something
-
- home
-
-
- another
-
- >
-)
diff --git a/test/integration/next-plugins/test/index.test.js b/test/integration/next-plugins/test/index.test.js
deleted file mode 100644
index b4746535997e2..0000000000000
--- a/test/integration/next-plugins/test/index.test.js
+++ /dev/null
@@ -1,216 +0,0 @@
-/* eslint-env jest */
-
-import fs from 'fs-extra'
-import { join } from 'path'
-import cheerio from 'cheerio'
-import webdriver from 'next-webdriver'
-import { version } from 'next/package.json'
-import {
- findPort,
- launchApp,
- killApp,
- nextBuild,
- nextStart,
- renderViaHTTP,
- File,
- check,
-} from 'next-test-utils'
-
-jest.setTimeout(1000 * 60 * 2)
-
-let app
-let appPort
-let stdout
-let stderr
-const appDir = join(__dirname, '../app')
-const nextConfigPath = join(appDir, 'next.config.js')
-
-function runTests() {
- it('should render tha page without error', async () => {
- const html = await renderViaHTTP(appPort, '/')
- expect(html).toMatch(/home/)
- })
-
- it('should apply headTags from plugin correctly', async () => {
- const html = await renderViaHTTP(appPort, '/')
- const $ = cheerio.load(html)
- const found = Array.from($('head').children()).find((el) => {
- return (el.attribs.src || '').match(/googletagmanager.*?my-tracking-id/)
- })
- expect(found).toBeTruthy()
- })
-
- it('should call clientInit from plugin correctly', async () => {
- const browser = await webdriver(appPort, '/')
- expect(await browser.eval('window.didClientInit')).toBe(true)
- })
-
- it('should list loaded plugins', async () => {
- expect(stdout).toMatch(/loaded plugin: @next\/plugin-google-analytics/i)
- })
-
- it('should ignore directories in plugins', async () => {
- expect(stderr).not.toMatch(/listed invalid middleware/i)
- })
-}
-
-const pluginPkgJson = new File(
- join(appDir, 'node_modules/@next/plugin-google-analytics/package.json')
-)
-
-describe('Next.js plugins', () => {
- beforeAll(async () => {
- pluginPkgJson.replace('0.0.1', version)
- })
- afterAll(() => pluginPkgJson.restore())
-
- describe('version mismatch error', () => {
- beforeAll(async () => {
- await fs.writeFile(
- nextConfigPath,
- `module.exports = { env: { GA_TRACKING_ID: 'my-tracking-id' }, experimental: { plugins: true } }`
- )
- pluginPkgJson.replace(version, '0.0.1')
- })
- afterAll(async () => {
- pluginPkgJson.restore()
- pluginPkgJson.replace('0.0.1', version)
- await fs.remove(nextConfigPath)
- })
- it('should show error when plugin version mismatches', async () => {
- let output = ''
- const handleOutput = (msg) => {
- output += msg || ''
- }
-
- app = await launchApp(appDir, await findPort(), {
- onStdout: handleOutput,
- onStderr: handleOutput,
- })
-
- try {
- await check(
- () => output,
- /Next\.js plugin versions must match the Next\.js version being used/
- )
- } finally {
- if (app) {
- await killApp(app)
- }
- }
- })
- })
-
- describe('dev mode', () => {
- beforeAll(async () => {
- await fs.writeFile(
- nextConfigPath,
- `module.exports = { env: { GA_TRACKING_ID: 'my-tracking-id' }, experimental: { plugins: true } }`
- )
- appPort = await findPort()
- app = await launchApp(appDir, appPort, {
- onStdout(msg) {
- stdout += msg
- },
- onStderr(msg) {
- stderr += msg
- },
- })
- })
- afterAll(() => killApp(app))
-
- runTests(true)
-
- describe('with plugin config', () => {
- beforeAll(async () => {
- await killApp(app)
- await fs.writeFile(
- nextConfigPath,
- `
- module.exports = {
- experimental: {
- plugins: true
- },
- plugins: [
- {
- name: '@next/plugin-google-analytics',
- config: { hello: 'world' }
- }
- ],
- env: {
- GA_TRACKING_ID: 'my-tracking-id'
- }
- }`
- )
- appPort = await findPort()
- stdout = ''
- stderr = ''
- app = await launchApp(appDir, appPort, {
- onStdout(msg) {
- stdout += msg
- },
- onStderr(msg) {
- stderr += msg
- },
- })
- })
- afterAll(() => killApp(app))
-
- it('should disable auto detecting plugins when plugin config is used', async () => {
- expect(stdout).toMatch(/loaded plugin: @next\/plugin-google-analytics/i)
- })
-
- // TODO: investigate why this fails. Potentially build cache related.
- it.skip('should expose a plugins config', async () => {
- const browser = await webdriver(appPort, '/')
- expect(await browser.eval('window.initClientConfig')).toBe('world')
- })
- })
- })
-
- describe('production mode', () => {
- beforeAll(async () => {
- await fs.writeFile(
- nextConfigPath,
- `module.exports = { env: { GA_TRACKING_ID: 'my-tracking-id' }, experimental: { plugins: true } }`
- )
- const results = await nextBuild(appDir, undefined, {
- stdout: true,
- stderr: true,
- })
- stdout = results.stdout
- stderr = results.stderr
- appPort = await findPort()
- app = await nextStart(appDir, appPort)
- })
- afterAll(async () => {
- await killApp(app)
- await fs.remove(nextConfigPath)
- })
-
- runTests()
- })
-
- describe('serverless mode', () => {
- beforeAll(async () => {
- await fs.writeFile(
- nextConfigPath,
- `module.exports = { target: 'serverless', env: { GA_TRACKING_ID: 'my-tracking-id' }, experimental: { plugins: true } }`
- )
- const results = await nextBuild(appDir, undefined, {
- stdout: true,
- stderr: true,
- })
- stdout = results.stdout
- stderr = results.stderr
- appPort = await findPort()
- app = await nextStart(appDir, appPort)
- })
- afterAll(async () => {
- await killApp(app)
- await fs.remove(nextConfigPath)
- })
-
- runTests()
- })
-})
diff --git a/test/unit/next-babel-loader.unit.test.js b/test/unit/next-babel-loader.unit.test.js
index f0f5d0d252ff6..be25684bfe2fa 100644
--- a/test/unit/next-babel-loader.unit.test.js
+++ b/test/unit/next-babel-loader.unit.test.js
@@ -49,7 +49,6 @@ const babel = async (
distDir: path.resolve(dir, '.next'),
pagesDir: path.resolve(dir, 'pages'),
cache: false,
- babelPresetPlugins: [],
development,
hasReactRefresh: Boolean(!isServer && development),
},
diff --git a/yarn.lock b/yarn.lock
index 41597619c5190..4ec21ba7d1e6a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2662,65 +2662,6 @@
dependencies:
any-observable "^0.3.0"
-"@sentry/browser@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.7.1.tgz#1f8435e2a325d7a09f830065ebce40a2b3c708a4"
- dependencies:
- "@sentry/core" "5.7.1"
- "@sentry/types" "5.7.1"
- "@sentry/utils" "5.7.1"
- tslib "^1.9.3"
-
-"@sentry/core@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.7.1.tgz#3eb2b7662cac68245931ee939ec809bf7a639d0e"
- dependencies:
- "@sentry/hub" "5.7.1"
- "@sentry/minimal" "5.7.1"
- "@sentry/types" "5.7.1"
- "@sentry/utils" "5.7.1"
- tslib "^1.9.3"
-
-"@sentry/hub@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.7.1.tgz#a52acd9fead7f3779d96e9965c6978aecc8b9cad"
- dependencies:
- "@sentry/types" "5.7.1"
- "@sentry/utils" "5.7.1"
- tslib "^1.9.3"
-
-"@sentry/minimal@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.7.1.tgz#56afc537737586929e25349765e37a367958c1e1"
- dependencies:
- "@sentry/hub" "5.7.1"
- "@sentry/types" "5.7.1"
- tslib "^1.9.3"
-
-"@sentry/node@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.7.1.tgz#94e2fbac94f6cc061be3bc14b22813536c59698d"
- dependencies:
- "@sentry/core" "5.7.1"
- "@sentry/hub" "5.7.1"
- "@sentry/types" "5.7.1"
- "@sentry/utils" "5.7.1"
- cookie "^0.3.1"
- https-proxy-agent "^3.0.0"
- lru_map "^0.3.3"
- tslib "^1.9.3"
-
-"@sentry/types@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.7.1.tgz#4c4c1d4d891b6b8c2c3c7b367d306a8b1350f090"
-
-"@sentry/utils@5.7.1":
- version "5.7.1"
- resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.7.1.tgz#cf37ad55f78e317665cd8680f202d307fa77f1d0"
- dependencies:
- "@sentry/types" "5.7.1"
- tslib "^1.9.3"
-
"@sindresorhus/is@^2.0.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-2.1.0.tgz#6ad4ca610f696098e92954ab431ff83bea0ce13f"
@@ -5574,10 +5515,6 @@ cookie@0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
-cookie@^0.3.1:
- version "0.3.1"
- resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
-
cookiejar@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c"
@@ -8458,13 +8395,6 @@ https-proxy-agent@^2.2.0, https-proxy-agent@^2.2.1:
agent-base "^4.3.0"
debug "^3.1.0"
-https-proxy-agent@^3.0.0:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81"
- dependencies:
- agent-base "^4.3.0"
- debug "^3.1.0"
-
human-signals@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
@@ -10460,10 +10390,6 @@ lru-cache@^4.0.0, lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"
-lru_map@^0.3.3:
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
-
lz-string@^1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
@@ -15736,7 +15662,7 @@ ts-pnp@^1.1.6:
version "1.2.0"
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
-tslib@1.11.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
+tslib@1.11.1, tslib@^1.8.1, tslib@^1.9.0:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==