next.js
42b1c400 - Turbopack build: Fix type: module with output: standalone (#79292)

Commit
255 days ago
Turbopack build: Fix type: module with output: standalone (#79292) ## What? This PR ensures we first clean the `.next/standalone` folder before writing into it. Currently the order is: 1. Write package.json to `.next/standalone/package.json` 1. Delete `.next/standalone` 1. Check `.nft.json` files and write the files listed there to `.next/standalone` Which in turn causes the package.json to not exist. So why does this not fail with webpack? Well, what I found is that the `_app` `.nft.json` file somehow lists the project root `package.json` even though it does not use it. This means that after we delete `.next/standalone` the `package.json` will still end up in the eventual directory regardless. It fails with Turbopack because Turbopack correctly does not include the package.json (as it's not used) and then the `package.json` is missing at runtime, causing the `server.js` which uses ESM to fail (because the detection for ESM is still valid regardless of deleting the folder). New order is: 1. Delete `.next/standalone` 1. Write package.json to `.next/standalone/package.json` 1. Check `.nft.json` files and write the files listed there to `.next/standalone`
Author
Parents
Loading