aleph.js
aleph.js copied to clipboard
Bundler attemps incorrect download link when running in production
❯ aleph start
INFO Download https://deno.land/x/[email protected]/index.ts/external.ts
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
WARN Download https://deno.land/x/[email protected]/index.ts/external.ts failed, retrying...
error: Uncaught (in promise) Error: Can't compile module '/pages/index.tsx': Can't compile module '/components/deployContent.tsx': Can't compile module '/components/deployable.tsx': Can't compile module '/lib/runInfo.ts': Can't compile module '/api/deploy/runs.ts': Can't compile module 'https://deno.land/x/[email protected]/mod.ts': Not Found
/** create bundle chunk. */
^
at Bundler.compile (https://deno.land/x/[email protected]/bundler/mod.ts:245:3)
at async https://deno.land/x/[email protected]/bundler/mod.ts:301:23
at async Promise.all (index 0)
at async Bundler.bundleChunk (https://deno.land/x/[email protected]/bundler/mod.ts:292:26)
at async Bundler.bundle (https://deno.land/x/[email protected]/bundler/mod.ts:136:11)
at async Aleph.#bundle (https://deno.land/x/[email protected]/server/aleph.ts:1488:5)
at async Aleph.#init (https://deno.land/x/[email protected]/server/aleph.ts:262:7)
at async serve (https://deno.land/x/[email protected]/server/server.ts:355:3)
at async https://deno.land/x/[email protected]/commands/start.ts:45:2
This is an error in my current project.
This only happens when running in production mode, not when using aleph dev. It seems like it incorrectly generated the URL to download, because if you look at the index.ts it is simply importing external.ts, there is no such thing as a index.ts directory in the module.
I'm quite sure my imports are fine:
runs.ts:
import { z } from 'zod'
import_map.json
{
"imports": {
"~/": "./",
"aleph/": "https://deno.land/x/[email protected]/",
"aleph/types": "https://deno.land/x/[email protected]/types.d.ts",
"aleph/web": "https://deno.land/x/[email protected]/framework/core/mod.ts",
"aleph/react": "https://deno.land/x/[email protected]/framework/react/mod.ts",
"react": "https://esm.sh/[email protected]",
"react-dom": "https://esm.sh/[email protected]",
"base64url": "https://deno.land/[email protected]/encoding/base64url.ts",
"path": "https://deno.land/[email protected]/path/mod.ts",
"octokitRequest": "https://cdn.skypack.dev/@octokit/[email protected]",
"zod": "https://deno.land/x/[email protected]/mod.ts"
},
"scopes": {}
}
I've done some more digging, it seems to be caused by the following part in the [index.ts](https://deno.land/x/[email protected]/index.ts) of zod:
import * as z from "./external.ts";
export * from "./external.ts";
export { z };
Probably the double export (which in a way export the same thing) confuses Aleph.js's bundler. I made a test repo with a working refactor of the zod contents here to illustrate the issue.
@tiptenbrink thanks, i will look into it
I was concerned about the same issue, so I tried to find the cause. And I think these lines are suspicious (although I'm not sure): https://github.com/alephjs/aleph.js/blob/93ff6f078e3c5f54db6082452e1da12cf7b02026/bundler/mod.ts#L173-L181 I will do further investigations.
P.S. In my case, the path of dependencies in https://deno.land/[email protected]/path/mod.ts was somehow transformed to something like https://deno.land/[email protected]/path/mod.ts/common.ts, which is wrong.