Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load next.config.mjs as ESM #22153

Closed
wants to merge 25 commits into from
Closed

Conversation

Janpot
Copy link
Contributor

@Janpot Janpot commented Feb 13, 2021

An Implementation of #22381

The async config loading (for now) is implemented as a wrapper around Server/DevServer. This is done for two reasons. First, it is as non-invasive to existing code as possible, so it's easier to keep the PR up to date while the code base evolves. Secondly, it makes sure all properties of Server can be initialized in the constructor, making the implementation easier to handle and typecheck than if all properties had to be asynchronously initialized. In my opinion, this is an elegant solution to solve the problem of loading config asynchronously, but it can be done differently, and certainly can be iterated on to make it a bit more DRY.

To Do:

  • wait for feat: automatically enable webpack 5 #22323 and merge the changes
  • add a warning that we detected ESM config and must therefore force enable webpack 5
  • figure out: ESM module cache is completely isolated from require cache. Find out what will be the implication of loading seprate instances of webpack

@ijjk
Copy link
Member

ijjk commented Feb 13, 2021

Failing test suites

Commit: f487c3d

test/integration/app-document-style-fragment/test/index.test.js

Expand output

● Test suite failed to run

TypeError: server.__app.close is not a function

  317 | export async function stopApp(server) {
  318 |   if (server.__app) {
> 319 |     await server.__app.close()
      |                        ^
  320 |   }
  321 |   await promiseCall(server, 'close')
  322 | }

  at stopApp (lib/next-test-utils.js:319:24)
  at integration/app-document-style-fragment/test/index.test.js:31:18

@ijjk
Copy link
Member

ijjk commented Feb 13, 2021

Failing test suites

Commit: f487c3d

test/integration/amphtml-fragment-style/test/index.test.js

Expand output

● Test suite failed to run

TypeError: server.__app.close is not a function

  317 | export async function stopApp(server) {
  318 |   if (server.__app) {
> 319 |     await server.__app.close()
      |                        ^
  320 |   }
  321 |   await promiseCall(server, 'close')
  322 | }

  at stopApp (lib/next-test-utils.js:319:24)
  at integration/amphtml-fragment-style/test/index.test.js:32:18

test/integration/app-document-import-order/test/index.test.js

Expand output

● Test suite failed to run

TypeError: server.__app.close is not a function

  317 | export async function stopApp(server) {
  318 |   if (server.__app) {
> 319 |     await server.__app.close()
      |                        ^
  320 |   }
  321 |   await promiseCall(server, 'close')
  322 | }

  at stopApp (lib/next-test-utils.js:319:24)
  at integration/app-document-import-order/test/index.test.js:34:18

test/integration/disable-js-preload/test/index.test.js

Expand output

● Test suite failed to run

TypeError: server.__app.close is not a function

  317 | export async function stopApp(server) {
  318 |   if (server.__app) {
> 319 |     await server.__app.close()
      |                        ^
  320 |   }
  321 |   await promiseCall(server, 'close')
  322 | }

  at stopApp (lib/next-test-utils.js:319:24)
  at integration/disable-js-preload/test/index.test.js:37:20

test/integration/future/test/index.test.js

Expand output

● Test suite failed to run

TypeError: server.__app.close is not a function

  317 | export async function stopApp(server) {
  318 |   if (server.__app) {
> 319 |     await server.__app.close()
      |                        ^
  320 |   }
  321 |   await promiseCall(server, 'close')
  322 | }

  at stopApp (lib/next-test-utils.js:319:24)
  at integration/future/test/index.test.js:32:18

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Feb 13, 2021

Failing test suites

Commit: 9054885

test/integration/cli/test/index.test.js

  • CLI Usage > dev > should exit when SIGTERM is signalled
Expand output

● CLI Usage › dev › should exit when SIGTERM is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  320 |       const expectedExitCode = process.platform === `win32` ? null : 0
  321 |       const expectedExitSignal = process.platform === `win32` ? 'SIGTERM' : null
> 322 |       expect(code).toBe(expectedExitCode)
      |                    ^
  323 |       expect(signal).toBe(expectedExitSignal)
  324 |     })
  325 |   })

  at Object.<anonymous> (integration/cli/test/index.test.js:322:20)

test/integration/required-server-files/test/index.test.js

  • Required Server Files > should output required-server-files manifest correctly
  • Required Server Files > should render SSR page correctly
  • Required Server Files > should render dynamic SSR page correctly
  • Required Server Files > should render fallback page correctly
  • Required Server Files > should render SSR page correctly with x-matched-path
  • Required Server Files > should render dynamic SSR page correctly with x-matched-path
  • Required Server Files > should render fallback page correctly with x-matched-path and routes-matches
  • Required Server Files > should return data correctly with x-matched-path
  • Required Server Files > should render fallback optional catch-all route correctly with x-matched-path and routes-matches
  • Required Server Files > should return data correctly with x-matched-path for optional catch-all route
  • Required Server Files > should not apply trailingSlash redirect
  • Required Server Files > should normalize catch-all rewrite query values correctly
  • Required Server Files > should bubble error correctly for gip page
  • Required Server Files > should bubble error correctly for gssp page
  • Required Server Files > should bubble error correctly for gsp page
Expand output

● Required Server Files › should output required-server-files manifest correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render SSR page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render dynamic SSR page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render SSR page correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render dynamic SSR page correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback page correctly with x-matched-path and routes-matches

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should return data correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback optional catch-all route correctly with x-matched-path and routes-matches

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should return data correctly with x-matched-path for optional catch-all route

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should not apply trailingSlash redirect

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should normalize catch-all rewrite query values correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gip page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gssp page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gsp page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Feb 13, 2021

Failing test suites

Commit: f66ec7a

test/integration/required-server-files/test/index.test.js

  • Required Server Files > should output required-server-files manifest correctly
  • Required Server Files > should render SSR page correctly
  • Required Server Files > should render dynamic SSR page correctly
  • Required Server Files > should render fallback page correctly
  • Required Server Files > should render SSR page correctly with x-matched-path
  • Required Server Files > should render dynamic SSR page correctly with x-matched-path
  • Required Server Files > should render fallback page correctly with x-matched-path and routes-matches
  • Required Server Files > should return data correctly with x-matched-path
  • Required Server Files > should render fallback optional catch-all route correctly with x-matched-path and routes-matches
  • Required Server Files > should return data correctly with x-matched-path for optional catch-all route
  • Required Server Files > should not apply trailingSlash redirect
  • Required Server Files > should normalize catch-all rewrite query values correctly
  • Required Server Files > should bubble error correctly for gip page
  • Required Server Files > should bubble error correctly for gssp page
  • Required Server Files > should bubble error correctly for gsp page
Expand output

● Required Server Files › should output required-server-files manifest correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render SSR page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render dynamic SSR page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback page correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render SSR page correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render dynamic SSR page correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback page correctly with x-matched-path and routes-matches

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should return data correctly with x-matched-path

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should render fallback optional catch-all route correctly with x-matched-path and routes-matches

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should return data correctly with x-matched-path for optional catch-all route

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should not apply trailingSlash redirect

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should normalize catch-all rewrite query values correctly

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gip page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gssp page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

● Required Server Files › should bubble error correctly for gsp page

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

  178 | 
  179 |     this.nextConfig = conf
> 180 |     this.distDir = join(this.dir, this.nextConfig.distDir)
      |                    ^
  181 |     this.publicDir = join(this.dir, CLIENT_PUBLIC_FILES_PATH)
  182 |     this.hasStaticDir = !minimalMode && fs.existsSync(join(this.dir, 'static'))
  183 | 

  at new Server (../packages/next/next-server/server/next-server.ts:180:20)
  at integration/required-server-files/test/index.test.js:50:15

test/integration/cli/test/index.test.js

  • CLI Usage > dev > should exit when SIGINT is signalled
  • CLI Usage > dev > should exit when SIGTERM is signalled
Expand output

● CLI Usage › dev › should exit when SIGINT is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  305 |       const expectedExitCode = process.platform === `win32` ? null : 0
  306 |       const expectedExitSignal = process.platform === `win32` ? 'SIGINT' : null
> 307 |       expect(code).toBe(expectedExitCode)
      |                    ^
  308 |       expect(signal).toBe(expectedExitSignal)
  309 |     })
  310 |     test('should exit when SIGTERM is signalled', async () => {

  at Object.<anonymous> (integration/cli/test/index.test.js:307:20)

● CLI Usage › dev › should exit when SIGTERM is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  320 |       const expectedExitCode = process.platform === `win32` ? null : 0
  321 |       const expectedExitSignal = process.platform === `win32` ? 'SIGTERM' : null
> 322 |       expect(code).toBe(expectedExitCode)
      |                    ^
  323 |       expect(signal).toBe(expectedExitSignal)
  324 |     })
  325 |   })

  at Object.<anonymous> (integration/cli/test/index.test.js:322:20)

@ijjk
Copy link
Member

ijjk commented Feb 14, 2021

Failing test suites

Commit: 8b63836

test/integration/production-start-no-build/test/index.test.js

  • Production Usage without production build > should show error when there is no production build
Expand output

● Production Usage without production build › should show error when there is no production build

expect(received).toThrow(expected)

Expected pattern: /Could not find a production build in the/

Received function did not throw

  13 |         quiet: true,
  14 |       })
> 15 |     }).toThrow(/Could not find a production build in the/)
     |        ^
  16 |   })
  17 | })
  18 | 

  at Object.<anonymous> (integration/production-start-no-build/test/index.test.js:15:8)

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Feb 14, 2021

Failing test suites

Commit: 6d42d50

test/integration/cli/test/index.test.js

  • CLI Usage > dev > should exit when SIGTERM is signalled
Expand output

● CLI Usage › dev › should exit when SIGTERM is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  320 |       const expectedExitCode = process.platform === `win32` ? null : 0
  321 |       const expectedExitSignal = process.platform === `win32` ? 'SIGTERM' : null
> 322 |       expect(code).toBe(expectedExitCode)
      |                    ^
  323 |       expect(signal).toBe(expectedExitSignal)
  324 |     })
  325 |   })

  at Object.<anonymous> (integration/cli/test/index.test.js:322:20)

@ijjk
Copy link
Member

ijjk commented Feb 14, 2021

Failing test suites

Commit: 70ca3c5

test/isolated/config.unit.test.js

  • config > Should get the configuration
  • config > Should pass the phase correctly
  • config > Should pass the defaultConfig correctly
  • config > Should assign object defaults deeply to user config
  • config > Should pass the customConfig correctly
  • config > Should not pass the customConfig when it is null
  • config > Should assign object defaults deeply to customConfig
  • config > Should allow setting objects which do not have defaults
  • config > Should override defaults for arrays from user arrays
  • config > Should throw when an invalid target is provided
  • config > Should pass when a valid target is provided
  • config > Should throw an error when next.config.js is not present
  • config > Should not throw an error when two versions of next.config.js are present
  • config > Should ignore configs set to undefined
  • config > Should ignore configs set to null
Expand output

● config › Should get the configuration

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: undefined

  11 |   it('Should get the configuration', () => {
  12 |     const config = loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfig)
> 13 |     expect(config.customConfig).toBe(true)
     |                                 ^
  14 |   })
  15 | 
  16 |   it('Should pass the phase correctly', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:13:33)

● config › Should pass the phase correctly

expect(received).toBe(expected) // Object.is equality

Expected: "phase-development-server"
Received: undefined

  16 |   it('Should pass the phase correctly', () => {
  17 |     const config = loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfigFn)
> 18 |     expect(config.phase).toBe(PHASE_DEVELOPMENT_SERVER)
     |                          ^
  19 |   })
  20 | 
  21 |   it('Should pass the defaultConfig correctly', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:18:26)

● config › Should pass the defaultConfig correctly

expect(received).toBeDefined()

Received: undefined

  21 |   it('Should pass the defaultConfig correctly', () => {
  22 |     const config = loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfigFn)
> 23 |     expect(config.defaultConfig).toBeDefined()
     |                                  ^
  24 |   })
  25 | 
  26 |   it('Should assign object defaults deeply to user config', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:23:34)

● config › Should assign object defaults deeply to user config

expect(received).toEqual(expected) // deep equality

Expected: ".next"
Received: undefined

  26 |   it('Should assign object defaults deeply to user config', () => {
  27 |     const config = loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfigFn)
> 28 |     expect(config.distDir).toEqual('.next')
     |                            ^
  29 |     expect(config.onDemandEntries.maxInactiveAge).toBeDefined()
  30 |   })
  31 | 

  at Object.<anonymous> (isolated/config.unit.test.js:28:28)

● config › Should pass the customConfig correctly

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: undefined

  34 |       customConfig: true,
  35 |     })
> 36 |     expect(config.customConfig).toBe(true)
     |                                 ^
  37 |   })
  38 | 
  39 |   it('Should not pass the customConfig when it is null', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:36:33)

● config › Should not pass the customConfig when it is null

expect(received).toBe(expected) // Object.is equality

Expected: null
Received: undefined

  39 |   it('Should not pass the customConfig when it is null', () => {
  40 |     const config = loadConfig(PHASE_DEVELOPMENT_SERVER, null, null)
> 41 |     expect(config.webpack).toBe(null)
     |                            ^
  42 |   })
  43 | 
  44 |   it('Should assign object defaults deeply to customConfig', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:41:28)

● config › Should assign object defaults deeply to customConfig

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: undefined

  47 |       onDemandEntries: { custom: true },
  48 |     })
> 49 |     expect(config.customConfig).toBe(true)
     |                                 ^
  50 |     expect(config.onDemandEntries.maxInactiveAge).toBeDefined()
  51 |   })
  52 | 

  at Object.<anonymous> (isolated/config.unit.test.js:49:33)

● config › Should allow setting objects which do not have defaults

expect(received).toBeDefined()

Received: undefined

  55 |       bogusSetting: { custom: true },
  56 |     })
> 57 |     expect(config.bogusSetting).toBeDefined()
     |                                 ^
  58 |     expect(config.bogusSetting.custom).toBe(true)
  59 |   })
  60 | 

  at Object.<anonymous> (isolated/config.unit.test.js:57:33)

● config › Should override defaults for arrays from user arrays

expect(received).toEqual(expected) // deep equality

Expected: [".bogus"]
Received: undefined

  63 |       pageExtensions: ['.bogus'],
  64 |     })
> 65 |     expect(config.pageExtensions).toEqual(['.bogus'])
     |                                   ^
  66 |   })
  67 | 
  68 |   it('Should throw when an invalid target is provided', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:65:35)

● config › Should throw when an invalid target is provided

expect(received).toThrow(expected)

Expected pattern: /Specified target is invalid/

Received function did not throw

  72 |         join(__dirname, '_resolvedata', 'invalid-target')
  73 |       )
> 74 |     }).toThrow(/Specified target is invalid/)
     |        ^
  75 |   })
  76 | 
  77 |   it('Should pass when a valid target is provided', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:74:8)

● config › Should pass when a valid target is provided

expect(received).toBe(expected) // Object.is equality

Expected: "serverless"
Received: undefined

  80 |       join(__dirname, '_resolvedata', 'valid-target')
  81 |     )
> 82 |     expect(config.target).toBe('serverless')
     |                           ^
  83 |   })
  84 | 
  85 |   it('Should throw an error when next.config.js is not present', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:82:27)

● config › Should throw an error when next.config.js is not present

expect(received).toThrow(expected)

Expected pattern: /Configuring Next.js via .+ is not supported. Please replace the file with 'next.config.js'/

Received function did not throw

  89 |         join(__dirname, '_resolvedata', 'typescript-config')
  90 |       )
> 91 |     ).toThrow(
     |       ^
  92 |       /Configuring Next.js via .+ is not supported. Please replace the file with 'next.config.js'/
  93 |     )
  94 |   })

  at Object.<anonymous> (isolated/config.unit.test.js:91:7)

● config › Should not throw an error when two versions of next.config.js are present

expect(received).toBe(expected) // Object.is equality

Expected: "js"
Received: undefined

   99 |       join(__dirname, '_resolvedata', 'js-ts-config')
  100 |     )
> 101 |     expect(config.__test__ext).toBe('js')
      |                                ^
  102 |   })
  103 | 
  104 |   it('Should ignore configs set to `undefined`', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:101:32)

● config › Should ignore configs set to undefined

expect(received).toBe(expected) // Object.is equality

Expected: "server"
Received: undefined

  106 |       target: undefined,
  107 |     })
> 108 |     expect(config.target).toBe('server')
      |                           ^
  109 |   })
  110 | 
  111 |   it('Should ignore configs set to `null`', () => {

  at Object.<anonymous> (isolated/config.unit.test.js:108:27)

● config › Should ignore configs set to null

expect(received).toBe(expected) // Object.is equality

Expected: "server"
Received: undefined

  113 |       target: null,
  114 |     })
> 115 |     expect(config.target).toBe('server')
      |                           ^
  116 |   })
  117 | })
  118 | 

  at Object.<anonymous> (isolated/config.unit.test.js:115:27)

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Feb 14, 2021

Failing test suites

Commit: 2be9940

test/integration/cli/test/index.test.js

  • CLI Usage > dev > should exit when SIGINT is signalled
  • CLI Usage > dev > should exit when SIGTERM is signalled
Expand output

● CLI Usage › dev › should exit when SIGINT is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  305 |       const expectedExitCode = process.platform === `win32` ? null : 0
  306 |       const expectedExitSignal = process.platform === `win32` ? 'SIGINT' : null
> 307 |       expect(code).toBe(expectedExitCode)
      |                    ^
  308 |       expect(signal).toBe(expectedExitSignal)
  309 |     })
  310 |     test('should exit when SIGTERM is signalled', async () => {

  at Object.<anonymous> (integration/cli/test/index.test.js:307:20)

● CLI Usage › dev › should exit when SIGTERM is signalled

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  320 |       const expectedExitCode = process.platform === `win32` ? null : 0
  321 |       const expectedExitSignal = process.platform === `win32` ? 'SIGTERM' : null
> 322 |       expect(code).toBe(expectedExitCode)
      |                    ^
  323 |       expect(signal).toBe(expectedExitSignal)
  324 |     })
  325 |   })

  at Object.<anonymous> (integration/cli/test/index.test.js:322:20)

@natemoo-re
Copy link
Contributor

natemoo-re commented Feb 21, 2021

@Janpot Rather than determining ESM support by checking the node version, this technique might be a bit cleaner and make it easier to introduce other loaders in the future. Node users can also set "type": "module" in their package.json files to treat plain js files as ESM, so the try require/catch import technique will handle that as well as the mjs case.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@natemoo-re
Copy link
Contributor

One more thought—next.config.cjs should be detected as well. The current require/import logic should continue to work, but there should probably be some tests for next.config.cjs just in case.

Reason
Users may wish to use an existing CJS config file inside of a type: module project and would need to use the .cjs extension to do so. It's valid to mix .js, .cjs, and .mjs in any project.

@Janpot
Copy link
Contributor Author

Janpot commented Feb 25, 2021

@natemoo-re I didn't really consider type: module in scope of the RFC. Adding support for it will require more changes to Next.js than just config loading (e.g. preventing ./.next folder from being interpreted as ESM, but probably other things as well).
Nonetheless, adding .cjs extension will be trivial.

@natemoo-re
Copy link
Contributor

That makes sense! That can be tackled later. This is a great step in the right direction.

@timneutkens
Copy link
Member

This PR will likely conflict with #22323. Potentially we'll have to enable webpack 5 by default for projects using the ESM config file. Given that we're planning to have everyone adopt webpack 5 eventually (without breaking existing apps) this would be reasonable given that currently you can only use commonjs

@Janpot
Copy link
Contributor Author

Janpot commented Feb 26, 2021

@timneutkens Yep, that PR is on my radar, I already reviewed it a few days ago and at first sight I didn't see anything that will be difficult to merge in this PR, it didn't seem to introduce extra sync config loading. I'll put it as a To Do (unless the team wants to do this the other way around ofcourse). Makes sense to mandate webpack 5 here.

@timneutkens
Copy link
Member

The main problem is that you can't delete the require cache to re-execute the import for ESM in this case.

kodiakhq bot pushed a commit that referenced this pull request Feb 27, 2021
Just the conversion of config loading from sync to async from #22153

cc @Timer
@ijjk
Copy link
Member

ijjk commented Feb 27, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 11.2s 10.8s -437ms
nodeModulesSize 42.7 MB 42.7 MB ⚠️ +2.42 kB
Page Load Tests Overall increase ✓
vercel/next.js canary Janpot/next.js async-config-loading Change
/ failed reqs 0 0
/ total time (seconds) 2.205 2.054 -0.15
/ avg req/sec 1133.87 1216.94 +83.07
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.539 1.381 -0.16
/error-in-render avg req/sec 1624.93 1810.27 +185.34
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
677f882d2ed8..e7a0.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.7 kB 59.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Rendered Page Sizes
vercel/next.js canary Janpot/next.js async-config-loading Change
index.html gzip 613 B 613 B
link.html gzip 620 B 620 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 12.9s 12.8s -77ms
nodeModulesSize 42.7 MB 42.7 MB ⚠️ +2.42 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
677f882d2ed8..e7a0.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.7 kB 59.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Serverless bundles
vercel/next.js canary Janpot/next.js async-config-loading Change
_error.js 1.01 MB 1.01 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.4 kB 10.4 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.01 MB 1.01 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.06 MB 1.06 MB
withRouter.js 1.06 MB 1.06 MB
Overall change 5.21 MB 5.21 MB

Webpack 5 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 13.2s 13.4s ⚠️ +195ms
nodeModulesSize 42.7 MB 42.7 MB ⚠️ +2.42 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
/ failed reqs 0 0
/ total time (seconds) 1.982 2.095 ⚠️ +0.11
/ avg req/sec 1261.43 1193.35 ⚠️ -68.08
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.417 1.494 ⚠️ +0.08
/error-in-render avg req/sec 1764.89 1673.17 ⚠️ -91.72
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
597-74632e79..1d47.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 954 B 954 B
Overall change 60.1 kB 60.1 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-aedc815..1421.js gzip 1.26 kB 1.26 kB
_error-71ec2..1a96.js gzip 3.38 kB 3.38 kB
amp-33a09cb0..6745.js gzip 536 B 536 B
hooks-4e968a..f870.js gzip 902 B 902 B
index-5c6845..f75c.js gzip 230 B 230 B
link-99f0c6c..b84a.js gzip 1.65 kB 1.65 kB
routerDirect..bb56.js gzip 306 B 306 B
withRouter-7..2133.js gzip 302 B 302 B
Overall change 8.57 kB 8.57 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 326 B 326 B
Overall change 326 B 326 B
Rendered Page Sizes
vercel/next.js canary Janpot/next.js async-config-loading Change
index.html gzip 586 B 586 B
link.html gzip 593 B 593 B
withRouter.html gzip 581 B 581 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "4kpBMiH54B-Aev2GIJHp-",
+        "buildId": "UCPF48yR0d5woA4VFaNyG",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_buildManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_ssgManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "4kpBMiH54B-Aev2GIJHp-",
+        "buildId": "UCPF48yR0d5woA4VFaNyG",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_buildManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_ssgManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "4kpBMiH54B-Aev2GIJHp-",
+        "buildId": "UCPF48yR0d5woA4VFaNyG",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_buildManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4kpBMiH54B-Aev2GIJHp-/_ssgManifest.js"
+      src="/_next/static/UCPF48yR0d5woA4VFaNyG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 1eb7fd6

@JacobLey
Copy link
Contributor

JacobLey commented Mar 22, 2021

I think a similar findConfigFile/importCjsOrEsm needs to be added in config-utils https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-utils.ts#L30-L46

Or rather, that helpers should probably move to config-utils and be imported by config

Also https://github.com/vercel/next.js/blob/canary/packages/next/telemetry/events/version.ts#L65-L78 which is a bit trickier, since that is currently all synchronous...
But it looks like async could bubble up to eventCliSession, of which all callers already appear to be async.

Very excited to see more ESM support

@JacobLey
Copy link
Contributor

This logic is now totally unblocked right? Because webpack 5 is enabled by default?

@Janpot Janpot requested a review from shuding as a code owner June 18, 2021 10:30
@Janpot Janpot marked this pull request as draft June 18, 2021 10:31
@Janpot
Copy link
Contributor Author

Janpot commented Jun 18, 2021

Converted back to draft as all I did was merge canary to see the tests run, none of the open todos were solved

@ijjk
Copy link
Member

ijjk commented Jun 18, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 14.2s 14.4s ⚠️ +174ms
buildDurationCached 3.4s 3.3s -121ms
nodeModulesSize 49.2 MB 49.2 MB ⚠️ +2.42 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
/ failed reqs 0 0
/ total time (seconds) 2.626 2.676 ⚠️ +0.05
/ avg req/sec 952.12 934.23 ⚠️ -17.89
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.629 1.615 -0.01
/error-in-render avg req/sec 1534.57 1548.06 +13.49
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 20.2 kB 20.2 kB
webpack-HASH.js gzip 804 B 804 B
Overall change 63 kB 63 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-HASH.js gzip 801 B 801 B
_error-HASH.js gzip 3.17 kB 3.17 kB
amp-HASH.js gzip 527 B 527 B
css-HASH.js gzip 330 B 330 B
hooks-HASH.js gzip 903 B 903 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.65 kB 1.65 kB
routerDirect..HASH.js gzip 322 B 322 B
withRouter-HASH.js gzip 320 B 320 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 8.41 kB 8.41 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 392 B 392 B
Overall change 392 B 392 B
Rendered Page Sizes
vercel/next.js canary Janpot/next.js async-config-loading Change
index.html gzip 522 B 522 B
link.html gzip 535 B 535 B
withRouter.html gzip 516 B 516 B
Overall change 1.57 kB 1.57 kB

Serverless Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 16.3s 15.8s -446ms
buildDurationCached 4.5s 4.6s ⚠️ +41ms
nodeModulesSize 49.2 MB 49.2 MB ⚠️ +2.42 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 20.2 kB 20.2 kB
webpack-HASH.js gzip 804 B 804 B
Overall change 63 kB 63 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-HASH.js gzip 801 B 801 B
_error-HASH.js gzip 3.17 kB 3.17 kB
amp-HASH.js gzip 527 B 527 B
css-HASH.js gzip 330 B 330 B
hooks-HASH.js gzip 903 B 903 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.65 kB 1.65 kB
routerDirect..HASH.js gzip 322 B 322 B
withRouter-HASH.js gzip 320 B 320 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 8.41 kB 8.41 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 392 B 392 B
Overall change 392 B 392 B
Serverless bundles Overall decrease ✓
vercel/next.js canary Janpot/next.js async-config-loading Change
_error.js 16.9 kB 16.9 kB ⚠️ +2 B
404.html 1.98 kB 1.98 kB
500.html 1.96 kB 1.96 kB
amp.amp.html 10.8 kB 10.8 kB
amp.html 1.17 kB 1.17 kB
css.html 1.35 kB 1.35 kB
hooks.html 1.23 kB 1.23 kB
index.js 17.2 kB 17.2 kB
link.js 17.5 kB 17.5 kB -2 B
routerDirect.js 17.3 kB 17.3 kB
withRouter.js 17.3 kB 17.3 kB -4 B
Overall change 105 kB 105 kB -4 B

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Janpot/next.js async-config-loading Change
buildDuration 12.4s 12.5s ⚠️ +28ms
buildDurationCached 5s 5s -5ms
nodeModulesSize 49.2 MB 49.2 MB ⚠️ +2.42 kB
Page Load Tests Overall increase ✓
vercel/next.js canary Janpot/next.js async-config-loading Change
/ failed reqs 0 0
/ total time (seconds) 2.599 2.615 ⚠️ +0.02
/ avg req/sec 961.75 956.02 ⚠️ -5.73
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.68 1.664 -0.02
/error-in-render avg req/sec 1487.98 1502.49 +14.51
Client Bundles (main, webpack, commons)
vercel/next.js canary Janpot/next.js async-config-loading Change
677f882d2ed8..HASH.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 41.8 kB 41.8 kB
main-HASH.js gzip 7.99 kB 7.99 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 63.8 kB 63.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js async-config-loading Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary Janpot/next.js async-config-loading Change
_app-HASH.js gzip 1.07 kB 1.07 kB
_error-HASH.js gzip 3.84 kB 3.84 kB
amp-HASH.js gzip 536 B 536 B
css-HASH.js gzip 333 B 333 B
hooks-HASH.js gzip 910 B 910 B
index-HASH.js gzip 227 B 227 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 295 B 295 B
withRouter-HASH.js gzip 292 B 292 B
e025d2764813..52f.css gzip 125 B 125 B
Overall change 9.28 kB 9.28 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js async-config-loading Change
_buildManifest.js gzip 420 B 420 B
Overall change 420 B 420 B
Rendered Page Sizes
vercel/next.js canary Janpot/next.js async-config-loading Change
index.html gzip 566 B 566 B
link.html gzip 579 B 579 B
withRouter.html gzip 558 B 558 B
Overall change 1.7 kB 1.7 kB
Commit: 2831fff

@Janpot Janpot closed this Aug 5, 2021
@Janpot Janpot deleted the async-config-loading branch October 15, 2021 12:30
@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants