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

fix: support npm modules + edge functions in monorepos #6130

Merged
merged 4 commits into from
Nov 8, 2023

Conversation

eduardoboucas
Copy link
Member

Summary

To make npm modules work in edge functions when in a monorepo setup, we need to use the repository root (and not the package root) as the base directory where we look for modules.

Closes https://linear.app/netlify/issue/COM-114/npm-modules-in-edge-functions-not-working-in-monorepo-setups.

@eduardoboucas eduardoboucas requested a review from a team as a code owner November 7, 2023 17:45
#logAddedFunction(func) {
log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} edge function ${chalk.yellow(this.#getDisplayName(func.name))}`)
}
#logEvent(event, { buildError, functionName, warnings = [] }) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have centralised all log messages in this method, similar to what we're doing with the serverless functions registry.

Copy link

github-actions bot commented Nov 7, 2023

📊 Benchmark results

Comparing with f0338d1

  • Dependency count: 1,339 (no change)
  • Package size: 402 MB ⬆️ 0.18% increase vs. f0338d1

}

/**
* @param {string} urlPath
* @param {string} method
*/
matchURLPath(urlPath, method) {
const declarations = this.#bundler.mergeDeclarations(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of generating a manifest and routes on each request, we generate it every time we build the functions and then cache it in this.#manifest and this.#routes.

Copy link
Contributor

@sarahetter sarahetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eduardoboucas eduardoboucas enabled auto-merge (squash) November 8, 2023 16:03
@eduardoboucas eduardoboucas merged commit e19c049 into main Nov 8, 2023
35 checks passed
@eduardoboucas eduardoboucas deleted the feat/edge-function-warnings branch November 8, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants