Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import map embedded in deno.json not supported #344

Closed
uriva opened this issue Mar 13, 2023 · 13 comments
Closed

import map embedded in deno.json not supported #344

uriva opened this issue Mar 13, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@uriva
Copy link

uriva commented Mar 13, 2023

Error The deployment failed: Module not found "npm:@noble/hashes/sha256".

this is what I got, but locally deno does find the target

@uriva
Copy link
Author

uriva commented Mar 14, 2023

@jupegarnica
Copy link

@uriva deno deploy doesn`t support npm specifiers yet
https://deno.com/blog/npm-and-deno-anywhere

@uriva
Copy link
Author

uriva commented Mar 14, 2023

Ok but is there some simple recipe to do it in this case?

@jupegarnica
Copy link

jupegarnica commented Mar 14, 2023

try cdns, it could work
https://deno.land/manual@v1.31.2/node/cdns

@uriva
Copy link
Author

uriva commented Mar 14, 2023

someone helped me (can see answer) - this was really not obvious to me as a beginner...

thanks!

@uriva uriva closed this as completed Mar 14, 2023
@uriva uriva reopened this Mar 14, 2023
@uriva
Copy link
Author

uriva commented Mar 14, 2023

actually, still doesn't work.

maybe because deno deploy doesn't understand where my deno.json is?

repo is uriva/portal
the file i'm linking is hub/src/index.ts

@uriva
Copy link
Author

uriva commented Mar 14, 2023

I tried placing the deno.json near the index.ts and also in the root on both attempts I got

Error The deployment failed: Relative import path "crypto" not prefixed with / or ./ or ../

@magurotuna
Copy link
Member

Thanks for reporting the issue. Unfortunately Deno Deploy doesn't currently support import map embedded in deno.json although it's been supported since Deno v1.30. We will be working on adding the support to Deploy.

@magurotuna magurotuna added the bug Something isn't working label Mar 29, 2023
@magurotuna magurotuna self-assigned this Mar 30, 2023
@piscisaureus
Copy link
Member

Duplicate of #314.

@magurotuna
Copy link
Member

No this issue is now not a duplicate of #314. The topic has changed to the lack of support for import map embedded in deno.json. I'm going to reopen it and to change the title to make it clear.

@magurotuna magurotuna reopened this Mar 31, 2023
@magurotuna magurotuna changed the title Can't link due to error - module not found import map embedded in deno.json not supported Mar 31, 2023
@wesbos
Copy link

wesbos commented Apr 18, 2023

Also hit this - using "import" in deno.json. Works great locally, but fails on deno deploy.

The fix is to create a separate import_map.json, and reference it via "importMap" key in deno.json.

Deno Deploy should work 1:1 with my local dev, especially with something that is recommended in the deno docs. small thing, but it's one of those tripping hazards that makes people go back to node

@magurotuna
Copy link
Member

We're aware that the inconsistency between CLI and Deploy is so annoying, and we're working on resolving it.

magurotuna added a commit to denoland/eszip that referenced this issue May 24, 2023
This commit allows JSONC to be embedded in an eszip as an import map.
This is primarily for deno's config file, which can be JSONC (e.g.
`deno.jsonc`).

Embedded JSONC data can then be retrieved by calling `get_import_map`
method, which is a new method. Keep in mind that the existing similar
method, `get_module`, will not return JSONC. This separation ensures
that whatever returned from `get_module` is definitely a valid module,
which may be useful when implementing support for dynamic import.

Ideally eszip's serialization format should have a dedicated optional
section for an import map so that we can treat import maps and modules
differently. We can't do this while keeping v2 since this would break
backward compatibility.

ref denoland/deploy_feedback#344
ref denoland/fresh#1188
@magurotuna
Copy link
Member

Import maps embedded in deno.json(c) is now supported. It's auto-discovered and serves as if it were a separate import_map.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants