denoland / denoland/deploy_feedback
[Bug]: Deploy cannot use `with` import assertions for JSON
- Dominant language
- No language data
- Stars
- 79
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
### Problem description
Deno Deploy cannot import JSON with `with` instead of `assert`. This is a bit of a footgun, because it may not be noticed with everything working locally.
### Steps to reproduce
1. Create Deno Deploy playground/project with the following content:
```ts
import { serve } from "https://deno.land/std@0.155.0/http/server.ts";
serve(async (req: Request) => {
const json = await import("https://raw.githubusercontent.com/denoland/deno/main/.dprint.json", {
with: { type: "json" }
});
return new Response(JSON.stringify(json, undefined, 2))
});
```
2. When running this endpoint there will be a runtime error:
```
TypeError: Expected a "JavaScriptOrWasm" module but loaded a "JSON" module.
at async Server. (file:///src/main.ts:4:18)
at async Server.#respond (https://deno.land/std@0.155.0/http/server.ts:298:18) {
code: "ERR_MODULE_NOT_FOUND"
```
Changing the `with` to `assert` makes the code work, but it's not really obvious why the above fails.
### Expected behavior
Deno Deploy should ideally be able to run the same code as the Deno runtime without errors.
### Environment
- Deno version 1.37.0
### Possible solution
_No response_
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure in a Deno Deploy playground using the `src/main.ts` example and compare it with the Deno runtime's handling of JSON imports. Trace how Deploy processes the dynamic import options; done means the example runs with `with: { type: "json" }` without the JavaScriptOrWasm module error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100