Skip to content

Commit 3d463e1

Browse files
committed
feat: revert "feat: skip run if @netlify/plugin-nextjs installed (#1536)"
This reverts commit 0b4cf8c.
1 parent 7132dab commit 3d463e1

File tree

3 files changed

+5
-68
lines changed

3 files changed

+5
-68
lines changed

packages/runtime/src/helpers/utils.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const findModuleFromBase = ({ paths, candidates }): string | null => {
179179

180180
export const isNextAuthInstalled = (): boolean => {
181181
try {
182-
// eslint-disable-next-line import/no-unassigned-import, n/no-extraneous-require, import/no-extraneous-dependencies
182+
// eslint-disable-next-line import/no-unassigned-import
183183
require('next-auth')
184184
return true
185185
} catch {
@@ -188,17 +188,6 @@ export const isNextAuthInstalled = (): boolean => {
188188
}
189189
}
190190

191-
export const isOldPluginInstalled = (): boolean => {
192-
try {
193-
// eslint-disable-next-line import/no-unassigned-import, n/no-missing-require, import/no-unresolved
194-
require('@netlify/plugin-nextjs')
195-
return true
196-
} catch {
197-
// Ignore the MODULE_NOT_FOUND error
198-
return false
199-
}
200-
}
201-
202191
export const getCustomImageResponseHeaders = (headers: Header[]): Record<string, string> | null => {
203192
const customImageResponseHeaders = headers.find((header) => header.for?.startsWith('/_next/image/'))
204193

packages/runtime/src/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { updateConfig, writeEdgeFunctions, loadMiddlewareManifest } from './help
1919
import { moveStaticPages, movePublicFiles, patchNextFiles } from './helpers/files'
2020
import { generateFunctions, setupImageFunction, generatePagesResolver } from './helpers/functions'
2121
import { generateRedirects, generateStaticRedirects } from './helpers/redirects'
22-
import { shouldSkip, isNextAuthInstalled, isOldPluginInstalled, getCustomImageResponseHeaders } from './helpers/utils'
22+
import { shouldSkip, isNextAuthInstalled, getCustomImageResponseHeaders } from './helpers/utils'
2323
import {
2424
verifyNetlifyBuildVersion,
2525
checkNextSiteHasBuilt,
@@ -39,10 +39,6 @@ const plugin: NetlifyPlugin = {
3939
cache,
4040
},
4141
}) {
42-
if (isOldPluginInstalled()) {
43-
return
44-
}
45-
4642
const { publish } = netlifyConfig.build
4743
if (shouldSkip()) {
4844
await restoreCache({ cache, publish })
@@ -69,7 +65,7 @@ const plugin: NetlifyPlugin = {
6965
build: { failBuild },
7066
},
7167
}) {
72-
if (isOldPluginInstalled() || shouldSkip()) {
68+
if (shouldSkip()) {
7369
return
7470
}
7571
const { publish } = netlifyConfig.build
@@ -182,14 +178,6 @@ const plugin: NetlifyPlugin = {
182178
}) {
183179
await saveCache({ cache, publish })
184180

185-
if (isOldPluginInstalled()) {
186-
status.show({
187-
summary:
188-
'Please remove @netlify/plugin-nextjs from your site. It is no longer required and will prevent you using new features. Learn more: https://ntl.fyi/3w85e2E',
189-
})
190-
return
191-
}
192-
193181
if (shouldSkip()) {
194182
status.show({
195183
title: 'Next Runtime did not run',

test/index.js

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ jest.mock('../packages/runtime/src/helpers/utils', () => {
22
return {
33
...jest.requireActual('../packages/runtime/src/helpers/utils'),
44
isNextAuthInstalled: jest.fn(),
5-
isOldPluginInstalled: jest.fn(),
65
}
76
})
87

@@ -34,6 +33,8 @@ const {
3433
} = require('../packages/runtime/src/helpers/config')
3534
const { dirname } = require('path')
3635
const { getProblematicUserRewrites } = require('../packages/runtime/src/helpers/verification')
36+
const { onPostBuild } = require('../packages/runtime/lib')
37+
const { basePath } = require('../demos/next-i18next/next.config')
3738

3839
const chance = new Chance()
3940
const FIXTURES_DIR = `${__dirname}/fixtures`
@@ -561,47 +562,6 @@ describe('onBuild()', () => {
561562
})
562563

563564
describe('onPostBuild', () => {
564-
const { isOldPluginInstalled } = require('../packages/runtime/src/helpers/utils')
565-
566-
test('show warning message to remove old plugin', async () => {
567-
isOldPluginInstalled.mockImplementation(() => {
568-
return true
569-
})
570-
const mockStatusFunc = jest.fn()
571-
572-
await nextRuntime.onPostBuild({
573-
...defaultArgs,
574-
utils: { ...utils, status: { show: mockStatusFunc } },
575-
})
576-
577-
expect(mockStatusFunc).toHaveBeenCalledWith({
578-
summary:
579-
'Please remove @netlify/plugin-nextjs from your site. It is no longer required and will prevent you using new features. Learn more: https://ntl.fyi/3w85e2E',
580-
})
581-
})
582-
583-
test('does not show warning message to remove old plugin', async () => {
584-
isOldPluginInstalled.mockImplementation(() => {
585-
return false
586-
})
587-
const mockStatusFunc = jest.fn()
588-
await moveNextDist()
589-
590-
await nextRuntime.onPostBuild({
591-
...defaultArgs,
592-
utils: {
593-
...utils,
594-
status: { show: mockStatusFunc },
595-
functions: { list: jest.fn().mockResolvedValue([]) },
596-
},
597-
})
598-
599-
expect(mockStatusFunc).not.toHaveBeenCalledWith({
600-
summary:
601-
'Please remove @netlify/plugin-nextjs from your site. It is no longer required and will prevent you using new features.',
602-
})
603-
})
604-
605565
test('saves cache with right paths', async () => {
606566
await moveNextDist()
607567

0 commit comments

Comments
 (0)