Unverified Commit cad2a756 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Make sure to handle "next" import gracefully (#11733)

* Make sure to handle "next" import gracefully

* Update test file
parent 44b7b3c9
...@@ -473,10 +473,17 @@ export default async function getBaseWebpackConfig( ...@@ -473,10 +473,17 @@ export default async function getBaseWebpackConfig(
) )
let webpackConfig: webpack.Configuration = { let webpackConfig: webpack.Configuration = {
externals: !isServer externals: !isServer
? undefined ? // make sure importing "next" is handled gracefully for client
// bundles in case a user imported types and it wasn't removed
// TODO: should we warn/error for this instead?
['next']
: !isServerless : !isServerless
? [ ? [
(context, request, callback) => { (context, request, callback) => {
if (request === 'next') {
return callback(undefined, `commonjs ${request}`)
}
const notExternalModules = [ const notExternalModules = [
'next/app', 'next/app',
'next/document', 'next/document',
......
import Link from 'next/link'
// Leave below import, testing that importing "next"
// doesn't stall the build
// eslint-disable-next-line no-unused-vars
import next from 'next'
export default () => (
<div>
<Link href="/about">
<a>About Page</a>
</Link>
<p className="index-page">Hello World</p>
</div>
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment