Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

This repo showcases a Next.js issue (version 10.1.3): Building the application for production fails with collocated tests when using webpack 5.

Notifications You must be signed in to change notification settings

edekadigital/nextjs-webpack5-collocated-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next.js - build fails with collocated-tests when using webpack 5

This repo showcases a Next.js issue (version 10.1.3): Building the application for production fails with collocated tests when using webpack 5.

  • Tests are collocated
  • webpack.IgnorePlugin is used to exclude test files from build
  • Webpack 5 usage is enabled

Both moving tests to a directory outside of /pages and disabling webpack 5 option will make it work.

Reproduce

1. Install dependencies

npm install

2. Start Next.js in development mode [passes]

npm run dev

3. Build the application for production [fails]

npm run build
> [email protected] build
> next build

info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types
info  - Creating an optimized production build
Failed to compile.

HookWebpackError: Cannot read property 'slice' of undefined

> Build error occurred
Error: > Build failed because of webpack errors
    at /Users/rschapka/Playground-Workspace/nextjs-webpack5/node_modules/next/dist/build/index.js:17:924
    at async Span.traceAsyncFn (/Users/rschapka/Playground-Workspace/nextjs-webpack5/node_modules/next/dist/telemetry/trace/trace.js:5:584)

About

This repo showcases a Next.js issue (version 10.1.3): Building the application for production fails with collocated tests when using webpack 5.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published