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

Programmatic API in version 3 does not work with Netlify Functions #3656

Open
philiprenich opened this issue Feb 11, 2025 · 0 comments
Open

Comments

@philiprenich
Copy link

Operating system

MacOS various

Eleventy

3.0.0

Describe the bug

Note: It's very possible that this issue could be solved on either end (11ty's or Netlify's). I understand I am asking about compatibility with a 3rd party and the resolution from 11ty's end may be "won't fix". Part of the reason of raising the issue here is to debug what is actually going wrong before deciding on a solution.

Netlify Functions do not work with the 11ty version 3 programmatic API. Due to the loss of the official serverless plugin, I am trying to recreate some functionality with Netlify Functions. However, it appears that new code in v3 is causing 11ty to not work with Netlify. In a simple reproduction, when calling new Eleventy() the module defaultConfig.js is not found.

Function demo has returned an error: Cannot find module '[path-to-repo]/11ty-netlify-function-mvp/.netlify/functions-serve/demo/node_modules/@11ty/eleventy/src/defaultConfig.js' imported from [path-to-repo]/11ty-netlify-function-mvp/.netlify/functions-serve/demo/node_modules/@11ty/eleventy/src/Util/Require.js

This may be due to how defaultConfig.js is loaded dynamically.

/* Used to import default Eleventy configuration file, raw means we don’t normalize away the `default` export */
async function dynamicImportRawFromEleventyPackage(file) {
// points to files relative to the top level Eleventy directory
let filePath = normalizeFilePathInEleventyPackage(file);
// Returns promise
return dynamicImportAbsolutePath(filePath, "esm", true);
}

It's notable that the file is not present in the node_modules folder that netlify dev (Netlify CLI) produces.

It seems like the newer esbuild method of bundling functions should solve this, but I haven't found that yet.

Reproduction steps

  1. Pull the linked repo
  2. Install Netlify CLI
  3. Install Node deps
  4. run netlify dev
  5. Click one of the links in the generated site when the browser launches to see the error

Expected behavior

All configuration and dependencies of 11ty should be available to Netlify Functions so that the programmatic API can work as intended.

Reproduction URL

https://git.philiprenich.com/philip/11ty-netlify-functions

Screenshots

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant