netlify / edge-bundler

Intelligently prepare Netlify Edge Functions for deployment

Home Page:https://www.npmjs.com/package/@netlify/edge-bundler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run `deno` process with `--no-config` flag

deckchairlabs opened this issue · comments

Describe the bug

When trying to deploy an edge-function using the latest cli release v11.8.0 with an importMap defined, I get errors relating to modules not found, specifically in the edge-bundler/deno directory, since my importMap looks a little something like this. So I would have to add edge-bundler deno dependencies to my importMap, which doesn't seem right, and a maintenance burden.

{
  "imports": {
    ...
    "https://deno.land/": "./vendor/server/deno.land/",
    "https://esm.sh/": "./vendor/server/esm.sh/"
  }
}

I would think defining an importMap for edge-bundler/deno dependencies, and passing that as a flag on

const flags = ['--allow-all']
would solve this

Can you please share the error you're seeing?

So because I have a deno.json file in the directory I am running netlify deploy within, also pointing to my importMap, I believe the deno process started when bundling the eszip, is inheriting that importMap. So any imports within edge-bundler fail to resolve.

⠹ Bundling edge functions...
error: Module not found "file:///workspaces/ultrajs-netlify-edge/.ultra/vendor/server/deno.land/x/eszip@v0.18.0/mod.ts".
✖ Deploy aborted due to error while bundling edge functions

I think what's happening is that you're overriding the location of any modules from https://deno.land/, so when we try to import the modules we need to generate the bundle (namely https://deno.land/x/eszip@v0.28.0/mod.ts), it'll try to load them from your ./ultra/vendor/server directory.

Why are you adding that entry to the import map?

I'm vendoring my dependencies, which will produce that importMap https://deno.land/manual@v1.25.3/tools/vendor

Sorry, I misread your previous comment. By looking at the title of the issue, I thought your request was to be in control over the dependencies on the Netlify side, which sounds problematic.

But I think what you're asking is that the import map is only considered when processing your code, whereas right now it looks like it's also being inherited by the Netlify code due to your deno.json file.

I think we should address this by adding the --no-config flag here, so that we don't load any user-defined configuration at this point.

Does that align with what you're proposing?

Ah right! Sorry for any confusion caused, yes I believe that will solve it!

@deckchairlabs This has been rolled out. Could you let me know if this addresses your issue? Thanks!