This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 458
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
Lambda@Edge Builder fails on ESM modules #2391
Copy link
Copy link
Open
Description
Issue Summary
I've tried building Lambda@Edge using the latest Next.js v12.1.0 release with "type": "module"
setting in package.json
, which got recent support. The builder fails with an error suggesting that next.config.js
is treated as ESM and needs to be renamed to .cjs
. Renaming it confusingly produces the same error.
Actual behavior
Error: Command failed with exit code 1: ./node_modules/.bin/next build
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
> Build error occurred
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '.../package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
Expected behavior
Lambda@edge builds without errors.
Steps to reproduce
- Create new Next.js project
- Add
@sls-next/lambda-at-edge
dependency - Set
"type": "module"
setting inpackage.json
- Run
yarn build
- Run
yarn exec exec build-lambda-at-edge .
Screenshots/Code/Configuration/Logs
See above.
Versions
- OS/Environment: MacOS
- @sls-next/serverless-component version: 3.7.0
- Next.js version: 12.1.0
Additional context
Checklist
- You have reviewed the README and FAQs, which answers several common questions.
- You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
- You have first tried using the most recent
latest
oralpha
@sls-next/serverless-component
release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the oldserverless-next.js
component and theserverless-next.js
plugin are deprecated and no longer maintained.
florianbepunktRafcin
Metadata
Metadata
Assignees
Labels
No labels