wpengine / faustjs

Faust.js™ - The Headless WordPress Framework

Home Page:https://faustjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App router example fails to compile on build

mdrayer opened this issue · comments

Description

Node: v20.11.0 (also tested on v18)
npm: 10.2.4

The current app router example (https://github.com/wpengine/faustjs/tree/canary/examples/next/app-router) results in a Failed to compile error after running npm run build:

$ npm run build

> build
> faust build

info - Found NEXT_PUBLIC_WORDPRESS_URL using wpengine.com TLD.
info - It is recommended to use the wpenginepowered.com TLD instead.
info - Ex: https://example.wpengine.com -> https://example.wpenginepowered.com
info - This will leverage WP Engine's Advanced Network CDN. See: https://wpengine.com/support/network/
warn - Could not find FAUST_SECRET_KEY environment variable.
warn - Some functionality may be limited.
   ▲ Next.js 14.1.2
   - Environments: .env.local

   Creating an optimized production build ...
Failed to compile.

./node_modules/@faustwp/experimental-app-router/dist/server/routeHandler/index.js + 2 modules
Cannot get final name for export 'NextResponse' of ./node_modules/next/dist/api/server.js


> Build failed because of webpack errors

I would expect this to build without any errors.

Steps to reproduce

  1. Copy files from the app-router example (https://github.com/wpengine/faustjs/tree/canary/examples/next/app-router) to your local. Double check to make sure you are on the right node and npm versions.
  2. Copy .env.local.sample file to .env.local.
  3. Run npm i to install packages.
  4. Run npm run dev and open the dev server to double check that your dev app is working (e.g. go to page http://localhost:3000/sample-page).
  5. Stop the dev server and instead run npm run build to build the app. You will get a Failed to compile error.

Additional context

I get the same error if I point to another WordPress site, so it doesn't seem like WP is the issue here.

@faustwp/core Version

3.0.0

@faustwp/cli Version

3.0.0

FaustWP Plugin Version

N/A

WordPress Version

N/A

Additional environment details

This is using the app-router example, so the following experimental packages are currently being used:

  • @apollo/experimental-nextjs-app-support
  • @faustwp/experimental-app-router

Please confirm that you have searched existing issues in the repo.

  • Yes

I did some further troubleshooting and found that the issue was introduced in next v14.1.1. Using v14.1.0 results in no error in npm run build. v14.1.1+ results in an error.

EDIT: On the other hand, I have my own app-router Faust app and I had to downgrade to next v14.0.4 in order for npm run build to be successful.