netlify/netlify-plugin-edge-handlers

Fail build if an external dependency is not installed

calavera opened this issue · 0 comments

Given this example:

import { formatDistance, subDays } from "date-fns";

export async function onRequest(event) {
  const timePassed = formatDistance(subDays(new Date(), 3), new Date());
  await event.respondWith(200, `<html>
  <head>
      <title>New content</title>
  </head>
  <body>
    <h1>Content updated: ${timePassed} ago</h1>
  </body></html>`)
}

If I don't have date-fns installed, the plugin bundles the handle correctly, but it doesn't add the dependency, it prints a message saying that it's considered an external dependency.

We do not allow external dependencies, we need to fail so people understand that they must have all dependencies installed.