Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

Next5 causes some subtle breakage when developing in code that worked correctly in Next4, for a site that uses express. In particular, two things are observed in dev mode:

There is a flash of unstyled site before all <styled jsx> CSS loads on first load. (Client side navs are still fine.)

401s on HMR, when using express-basic-auth.

Steps to Reproduce (for bugs)

I created a minimal folder structure to demo the second behaviour: https://www.dropbox.com/s/ulazf3kutnsve2v/simple.tgz?dl=0

Unzip, run yarn install, yarn dev (this uses Next 4.2.3.)

Visit localhost:3000, enter "something", "secure"

Open console.

Edit index.js

In the Network tab, observe that on-demand-entries-ping?page=/ returns a 200.

Stop the server

yarn add next@latest, yarn dev.

Visit localhost:3000, enter "something", "secure" (new incognito window if you like)

Edit index.js

In the Network tab, observe that on-demand-entries-ping?page=/ returns a 401.

Issue 2:
Bug report

Describe the bug

In the case using target: 'serverless' flag in next.config.js, the with-ant-design-less sample code build failed.

$ yarn build
yarn run v1.17.3
$ next build
Creating an optimized production build ...

> Using external babel configuration
> Location: "/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.babelrc"
Compiled with warnings.

./node_modules/component-classes/index.js
Module not found: Can't resolve 'indexof' in '/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/node_modules/component-classes'

> Build error occurred
TypeError: (0 , _styleChecker.default) is not a function
at Object.g5iu (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:37583:55)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Object.3PeW (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:3977:36)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Object.lbd2 (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:42120:36)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Module.ILaR (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:15153:18)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at /Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:91:18
at Object.<anonymous> (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:94:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce

Go to 'https://github.com/bokuo-okubo/next-with-ant-design-less-failed'

yarn

next => working fine

next build => Error

(also in the case remove target: 'serverless' flag, build works fine.)

Expected behavior

I tried to build with the check condition also options.dev flag, it works fine.

https://github.com/bokuo-okubo/next-with-ant-design-less-failed/blob/4ceee6c40d3a3e52ef52407715b3a056c03f9605/next.config.js#L34

In the case of using target: 'serverless' mode, config.externals contain the amp-toolbox-optimizer, so the something wrong around there.

Screenshots

dump the option in the build time

System information

OS: macOS, Mojave, Version 10.14.5

Browser (if applies) [e.g. chrome, safari]

next version: "9.0.2"

package.json

{
"name": "next-with-ant-design-less-failed",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "cross-env NODE_ENV=production node server.js"
},
"dependencies": {
"antd": "^3.20.7",
"babel-plugin-import": "^1.12.0",
"cross-env": "^5.2.0",
"css-animation": "^1.6.0",
"express": "^4.17.1",
"less": "^3.9.0",
"less-vars-to-js": "^1.3.0",
"next": "9.0.2",
"react": "16.8.6",
"react-dom": "16.8.6"
},
"resolutions": {
"css-animation": "1.5.0"
},
"devDependencies": {
"@zeit/next-less": "^1.0.1",
"null-loader": "^3.0.0",
"style-loader": "^0.23.1"
}
}

Additional context

Add any other context about the problem here.