Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverless not working with Netlify esbuild #2235

Closed
5t3ph opened this issue Feb 19, 2022 · 3 comments
Closed

Serverless not working with Netlify esbuild #2235

5t3ph opened this issue Feb 19, 2022 · 3 comments
Assignees
Labels

Comments

@5t3ph
Copy link

5t3ph commented Feb 19, 2022

Describe the bug
Deploying an 11ty site on Netlify with the esbuild function bundling does not successfully retain the serverless functionality, so serverless pages are inaccessible.

To Reproduce

  1. Clone this repo with the reduced test case of a very basic serverless setup including the esbuild parts for Netlify: https://github.com/5t3ph/11ty-serverless-esbuild-test
  2. Deploy to Netlify
  3. Observe that the serverless page does not load, but displays an error similar to the following
{"errorType":"Error","errorMessage":"Cannot find module '/var/task/netlify/functions/possum/eleventy-serverless-map.json'\nRequire stack:\n- /var/task/node_modules/@11ty/eleventy/src/Serverless.js\n- /var/task/node_modules/@11ty/eleventy/src/Eleventy.js\n- /var/task/netlify/functions/possum/index.js\n- /var/task/possum.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Error: Cannot find module '/var/task/netlify/functions/possum/eleventy-serverless-map.json'","Require stack:","- /var/task/node_modules/@11ty/eleventy/src/Serverless.js","- /var/task/node_modules/@11ty/eleventy/src/Eleventy.js","- /var/task/netlify/functions/possum/index.js","- /var/task/possum.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js","    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)","    at Function.Module._load (internal/modules/cjs/loader.js:746:27)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Serverless.getContentMap (/var/task/node_modules/@11ty/eleventy/src/Serverless.js:102:22)","    at Serverless.isServerlessUrl (/var/task/node_modules/@11ty/eleventy/src/Serverless.js:117:27)","    at Runtime.handler (/var/task/netlify/functions/possum/index.js:45:14)"]}

live page link

Expected behavior
The serverless page loads successfully.

Environment:

  • New Netlify build (focal)
  • Eleventy Version: ^1.0.0

Additional context
Discovered esbuild was needed to deploy a site that was going to use the prismic plugin. Then the serverless component that allows live previewing from Prismic CMS wouldn't function on deploy. The same issue was repro'd in the demo repo with a basic serverless setup.

@zachleat
Copy link
Member

zachleat commented Apr 12, 2022

Agree that there is something to fix here but in the mean time here’s some netlify.toml addition that I’ve used to “make it work” now with esbuild:

[functions]
node_bundler = "esbuild"

[functions.possum]
included_files = [
  "./netlify/functions/possum/**/*",
  "./netlify/functions/possum/.cache/**/*"
]

@zachleat
Copy link
Member

zachleat commented Apr 12, 2022

@zachleat
Copy link
Member

zachleat commented Apr 9, 2024

Stale per project slipstream changes in #3074.

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

@zachleat zachleat closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants