Issue 1:
yarn run v1.3.2
$ rimraf node_modules/.cache/babel-loader && next
/project/next.config.js:9
config.entry = async () => {
^
SyntaxError: Unexpected token (
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at loadConfig (/project/node_modules/next/dist/server/config.js:57:28)
at getConfig (/project/node_modules/next/dist/server/config.js:40:20)
at new HotReloader (/project/node_modules/next/dist/server/hot-reloader.js:119:40)
at Server.getHotReloader (/project/node_modules/next/dist/server/index.js:157:14)
at new Server (/project/node_modules/next/dist/server/index.js:124:35)
at Object.<anonymous> (/project/node_modules/next/dist/bin/next-dev:63:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
error Command failed with exit code 1.

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

Expected Behavior

Current Behavior

Steps to Reproduce (for bugs)

Was on next 4

Upgrade to next 5

Error

Context

Followed this guide: https://github.com/zeit/next.js/blob/canary/examples/with-polyfills/next.config.js

My next.config.js:

// https://github.com/zeit/next.js/blob/master/examples/with-global-stylesheet

const path = require('path');
const glob = require('glob');

module.exports = {
webpack: (config, { dev }) => {
const originalEntry = config.entry
config.entry = async () => {
const entries = await originalEntry()

if (entries['main.js']) {
entries['main.js'].unshift('./client/polyfills.js')
}

return entries
}

// Set project root path as part of the resoler
config.resolve = {
modules: [
...config.resolve.modules,
path.resolve('./')
]
}

// Original Issue:
// https://github.com/zeit/next.js/issues/1877#issuecomment-299396974
if (config.resolve.alias) {
delete config.resolve.alias['react'];
delete config.resolve.alias['react-dom'];
}

// TODO: Remove this once nextjs issue has been resolved: https://github.com/zeit/next.js/issues/1582
config.plugins = config.plugins.filter(plugin => {
if (plugin.constructor.name === 'UglifyJsPlugin') {
return false;
} else {
return true;
}
});

config.module.rules.push(
// es6 transpilation in node_modules for object.assign
{
test: /\.(js|jsx)/,
loader: 'babel-loader',
exclude(file) {
return file.startsWith(__dirname + '/node_modules/subscriptions-transport-ws') ? false : true;
}
},

// yaml
{
test: /\.yaml$/,
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
'json-loader',
'yaml-loader'
]
},

// css|scss
{
test: /\.(css|scss)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},

{
test: /\.css$/,
use: ['babel-loader', 'raw-loader', 'postcss-loader']
},

{
test: /\.s(a|c)ss$/,
use: ['babel-loader', 'raw-loader', 'postcss-loader',
{ loader: 'sass-loader',
options: {
includePaths: ['styles', 'node_modules']
.map(d => path.join(__dirname, d))
.map(g => glob.sync(g))
.reduce((a, c) => a.concat(c), [])
}
}
]
},

{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
'babel-loader',
'graphql-tag/loader'
]
}
);

return config;
}
};

Your Environment

Tech
Version

next
5.0.0

node
6.9.1

OS
OSX 10.13.2

browser
chrome beta 65.0.3325.51

etc

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

Expected Behavior

The on-demand-entries-ping should include the current cookies in the request.

Current Behavior

The on-demand-entries-ping does not include the current cookies in the request.

Steps to Reproduce (for bugs)

If required, I can build an reproduction sample, but I think its obvious.

Context

I am running a nginx as proxy splitting the request between a website served with next, and multiple microservices. All running in docker. For development I am running the website with next in dev mode within the same docker context so that the api request are handled the same way as in prod, but on localhost. The nginx is also validating the session cookies against an authentication services and exchange them for an access_token if the request is forwarded to one of the backend services. The proxy is also blocking the access to the next app if there is no token.

Since the on-demand-entries-ping does not include the cookies, the request is blocked. As a workaround I could allow all _next/... requests with out cookies, but I think that there is no reason why the on-demand-entries-ping should not include the credentials.

Solution

Add { credentials: 'same-origin' } as parameter to the fetch requests, here: https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L14 and here: https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L19.

If this is an appropriate solution and you have no concerns I can send an PR, asap.

Your Environment

Next.js version: 3.0.1-beta.8

Environment name and version (e.g. Chrome 39, Node.js 5.4): node:8-alpine

Operating System (Linux, maxOS, Windows): docker on Linux