Trouble with import maps
mashaal opened this issue · comments
When trying to run the oak example with an import map, I keep running into the following error:
vercel dev
error: Uncaught (in promise) TypeError: Relative import path "oak" not prefixed with / or ./ or ../
api/index.js
#!/usr/bin/env deno run --import-map importmap.json
import { Application } from "oak";
const app = new Application();
app.use((ctx) => {
ctx.response.body = "Hello World!";
console.log(ctx);
});
export default app.handle;
importmap.json
{
"imports": {
"oak": "https://deno.land/x/oak/mod.ts"
}
}
I tried a few different invocations of --import-map, but couldn't get any to work. If I remove the import map and use the full http import, the example works.
I tried deploying this app and it does work. This issue seems to only effect my vercel dev
environment. I'm guessing the shebang is being ignored?
OS: Linux / Elementary 6
Vercel CLI: 23.1.2
Deno: 1.14.3
I got this working locally by editing the following file in my vercel runtime cache:
https://github.com/vercel-community/deno/blob/master/src/index.ts#L514
const argv = [
"run",
"--allow-all",
...args,
"--import-map=api/importmap.json",
(0, path_1.join)(__dirname, "dev-server.ts"),
];
Note: When I log the args
on https://github.com/vercel-community/deno/blob/master/src/index.ts#L485 -- I get...
{ args: { _: [], env: {} } }
I'll try to wrap my head around how the args are being passed and parsed, and see if I can open a PR