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

Next.js plugin is treating the entire projectRoot as pages #513

@larrifax

Description

@larrifax

I was trying the Next.js integration the other day, and came across this problem:

Error: Webpack Compilation Error
./src/@ui/form/index.ts
Module build failed (from ./node_modules/next/dist/build/webpack/loaders/next-babel-loader.js):
SyntaxError: /workspaces/greenstockv2-webclient/src/@ui/form/index.ts: Using `export * from '...'` in a page is disallowed. Please use `export { default } from '...'` instead.
Read more: https://err.sh/next.js/export-all-in-page
 @ ./src/features/landing-page/components/login-form/login-form.tsx 158:0-79 167:41-58 175:15-19 179:11-16 181:11-16 184:13-18 186:11-16 189:13-25
 @ ./src/features/landing-page/components/login-form/login-form.spec.tsx

It turns out that Next.js disallows the use of export * from ... in pages. My code in question is not part of a page at all, but the following line of code in the next plugin configures the entire project root as a page directory. In my case that's ./, while my real pages directory lies in ./src/pages.

https://github.com/bahmutov/cypress-react-unit-test/blob/d65d2fb8b2e0f1e28c76e8697929270247959b09/plugins/next/file-preprocessor.js#L23

Patching the above line to be pagesDir: config.componentFolder + '/pages', fixes the problem (I've set "componentFolder": "src" in cypress.json).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions