-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[node-compat] deno seems to not import dependency specified in import map from esm package when using a npm:
import
#16013
Comments
Seems related to #15948. |
I looked into it and it seems plausible. The source of kysely-Planetscale is written in TS, but the compile configuration is extended from @tsconfig/node14/tsconfig.json Which extends to:
LinksI will try to use the typescript source directly instead of the compiled package. This should alleviate the problem for me for now. I'll report on the results! |
At the moment, I think packages resolving other packages won't consult the import map, so yeah, I think this is similar to #15948. Also, right now we don't support peer dependencies that well, so you won't get an error/warning here about anything wrong. Also, we've thought about maybe downloading the packages up front in an import_map, which would solve this problem #15823 (comment) |
npm:
Importnpm:
import
I don't think that downloading the packages in an import-map in advance would solve the problem completely. I can already cache an npm package locally in the deno cache. So this requires a fix to the "require" import in the npm dependency, how should downloading the packages in an import map in advance help with that problem? Also, this sounds like you want to introduce some kind of project local cache, but this sounds basically like node_modules 2.0 for me. |
import { cast, connect } from "@planetscale/database"; This is specified as a peer dependency in What I'm saying is that 1. we need peer dependency support, so it can know about this peer dependency, and 2. that maybe the import map might inform the resolution of what version of Overall, I'm not entirely sure if we should support import maps mapping specifiers in npm packages, but perhaps it would be useful for informing the npm package version resolver about what version to use. |
Ahh now I see. I didn't realize that the @planetscale/database was a peer dependency! Thank you for the explanation! So that I get it correct: My problem has nothing to do with require imports inside kysely-planetscale coming from the TS build as moduleFormat commonJS? But instead it comes from the fact that peerDependnecies are currently not resolved? |
Seems to be the same problem as #15823 |
@bjesuiter do you still have this problem with latest Deno version (1.29.1)? |
I'll check that, thanks for the ping! |
I was trying to connect to a planetscale mysql db via the following packages:
I provided all three via an import mapping:
Then I tried to run the following script by using:
The Error Message
The Temporary Fix
I can fix this for now for deno by adding the following import:
I think this works because it explicitely loads the @planetscale/database package identifier into the runtime
wich makes it resolvable to "kysely-planetscale"
My Expectation
My expectation would be that this simply works without needing my "fake" import.
In theory, deno could resolve all bare specifiers in a package loaded by "npm: " as also being npm packages and load them.
If that's not that easy, I would also be ok with adding them to my import_map, as I've already done for my example.
This may be enough to fix this, or do I miss something there?
The text was updated successfully, but these errors were encountered: