From 451dfa14f145d0499f39d932eddad39f66328f54 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 8 Feb 2022 16:20:00 +0100 Subject: [PATCH] remove unneeded and broken plugin (#34087) fixes #25484 fixes #34064 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` --- packages/next/build/webpack-config.ts | 2 -- .../webpack/plugins/nextjs-ssr-import.ts | 35 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 packages/next/build/webpack/plugins/nextjs-ssr-import.ts diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 235722e7d01c3..c710bd5c1712b 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -38,7 +38,6 @@ import BuildManifestPlugin from './webpack/plugins/build-manifest-plugin' import { JsConfigPathsPlugin } from './webpack/plugins/jsconfig-paths-plugin' import { DropClientPage } from './webpack/plugins/next-drop-client-page-plugin' import { TraceEntryPointsPlugin } from './webpack/plugins/next-trace-entrypoints-plugin' -import NextJsSsrImportPlugin from './webpack/plugins/nextjs-ssr-import' import PagesManifestPlugin from './webpack/plugins/pages-manifest-plugin' import { ProfilingPlugin } from './webpack/plugins/profiling-plugin' import { ReactLoadablePlugin } from './webpack/plugins/react-loadable-plugin' @@ -1475,7 +1474,6 @@ export default async function getBaseWebpackConfig( isEdgeRuntime, pageExtensions: config.pageExtensions, }), - isServer && new NextJsSsrImportPlugin(), !isServer && new BuildManifestPlugin({ buildId, diff --git a/packages/next/build/webpack/plugins/nextjs-ssr-import.ts b/packages/next/build/webpack/plugins/nextjs-ssr-import.ts deleted file mode 100644 index 5ad1874441ce0..0000000000000 --- a/packages/next/build/webpack/plugins/nextjs-ssr-import.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { join, resolve, relative, dirname } from 'path' -import { webpack } from 'next/dist/compiled/webpack/webpack' - -// This plugin modifies the require-ensure code generated by Webpack -// to work with Next.js SSR -export default class NextJsSsrImportPlugin { - apply(compiler: webpack.Compiler) { - compiler.hooks.compilation.tap('NextJsSSRImport', (compilation: any) => { - compilation.mainTemplate.hooks.requireEnsure.tap( - 'NextJsSSRImport', - (code: string, chunk: any) => { - // Update to load chunks from our custom chunks directory - const outputPath = resolve('/') - const pagePath = join('/', dirname(chunk.name)) - const relativePathToBaseDir = relative(pagePath, outputPath) - // Make sure even in windows, the path looks like in unix - // Node.js require system will convert it accordingly - const relativePathToBaseDirNormalized = relativePathToBaseDir.replace( - /\\/g, - '/' - ) - return code - .replace( - 'require("./"', - `require("${relativePathToBaseDirNormalized}/"` - ) - .replace( - 'readFile(join(__dirname', - `readFile(join(__dirname, "${relativePathToBaseDirNormalized}"` - ) - } - ) - }) - } -}