diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 235722e7d01c30..c710bd5c1712bc 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 5ad1874441ce0e..00000000000000 --- 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}"` - ) - } - ) - }) - } -}