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

Deno imports compatibility? #1267

Closed
2 of 3 tasks
shinebayar-g opened this issue Feb 8, 2023 · 10 comments
Closed
2 of 3 tasks

Deno imports compatibility? #1267

shinebayar-g opened this issue Feb 8, 2023 · 10 comments

Comments

@shinebayar-g
Copy link

shinebayar-g commented Feb 8, 2023

  • I have searched for similar issues
  • I am using the latest version of npm-check-updates
  • I am using node >= 14.14

Hi, I'm a long time ncu user, love it. Recently I started working on a new project with Deno. Looks like Deno supports npm modules via imports configuration. Example deno.json file.

{
    "imports": {
        "cdk8s": "npm:cdk8s@^2.6.43",
    },
}

With this defined, deno will support npm modules without any other changes. Following works as expected.

import { App, Chart, ChartProps } from 'cdk8s';

Would you consider making ncu compatible with Deno with above workflow?

@raineorshine
Copy link
Owner

raineorshine commented Feb 9, 2023

Hi, thanks for the suggestion.

I added basic support and published to v16.7.0. ncu will now autodetect deno.json so it should "just work". Or you can do ncu --packageManager deno --packageFile customDenoConfig.json if you have a custom deno config file location.

Please try it out at your convenience and let me know how it works :).

@shinebayar-g
Copy link
Author

shinebayar-g commented Feb 9, 2023

Just tried version 16.7.0. It worked well.

❯ ncu
Using deno
Checking /Users/me/cdk8s-demo/deno.json
[====================] 2/2 100%

 constructs  npm:constructs@10.1.243  →  10.1.245

Run ncu -u to upgrade deno.json

Couple of items.

  1. Looks like deno config file is going to be either deno.json or deno.jsonc. Doc

The configuration file supports .json and .jsonc extensions.

  1. Not sure if deno install command is the correct one to use.
❯ ncu
Using deno
Upgrading /Users/me/cdk8s-demo/deno.json
[====================] 2/2 100%

 constructs  npm:constructs@10.1.243  →  10.1.245

Run deno install to install new versions.

❯ deno install
error: The following required arguments were not provided:
    <cmd>...

USAGE:
    deno install [OPTIONS] <cmd>...

For more information try --help

❯ deno install --help
deno-install
Installs a script as an executable in the installation root's bin directory.

I think correct usage is maybe this.

❯ deno cache npm:constructs@10.1.245 # worked
❯ deno cache npm:constructs # didn't work

@shinebayar-g
Copy link
Author

Just tried multiple package upgrade.

❯ ncu
Using deno
Checking /Users/me/cdk8s-demo/deno.json
[====================] 2/2 100%

 cdk8s              npm:cdk8s@2.6.43  →    2.6.44
 constructs  npm:constructs@10.1.243  →  10.1.245

Run ncu -u to upgrade deno.json
❯ ncu -u
Using deno
Upgrading /Users/me/cdk8s-demo/deno.json
[====================] 2/2 100%

 cdk8s              npm:cdk8s@2.6.43  →    2.6.44
 constructs  npm:constructs@10.1.243  →  10.1.245

Run deno install to install new versions.

Multiple package upgrade worked as expected.

deno cache npm:constructs@10.1.245 npm:cdk8s@2.6.44

@raineorshine
Copy link
Owner

raineorshine commented Feb 9, 2023

Is deno cache necessary? I got the impression that adding a package to the import map was enough. I may simply omit the install hint unless you think it's useful.

@shinebayar-g
Copy link
Author

shinebayar-g commented Feb 9, 2023

I mean it's equivalent of npm install. So instead of saying Run deno install to install new versions. after ncu -u, let's say deno cache npm:constructs@10.1.245 npm:cdk8s@2.6.44

deno cache alone is also not a complete command.

❯ deno cache
error: The following required arguments were not provided:
    <file>...

USAGE:
    deno cache [OPTIONS] <file>...

For more information try --help

I got the impression that adding a package to the import map was enough.

This doesn't download the dependencies automatically. But Deno will download necessary dependencies on the next deno run something.ts.

Suggesting deno cache ... is just for the sake of consistency if you want to recommend equivalent of npm install

@raineorshine
Copy link
Owner

I mean it's equivalent of npm install. So instead of saying Run deno install to install new versions. after ncu -u, let's say deno cache npm:constructs@10.1.245 npm:cdk8s@2.6.44

The cheat sheet says that it's not necessary:

the runtime downloads and caches the code on first use

npm cache alone is also not a complete command.

Yes, thanks, I meant npm cache X.

@raineorshine
Copy link
Owner

raineorshine commented Feb 9, 2023

Suggesting deno cache ... is just for the sake of consistency if you want to recommend equivalent of npm install

Sure, makes sense. I tend to prefer the most minimal output possible, so if it's not strictly necessary I think I will omit it. Plus that's one less command that the user needs to enter.

@shinebayar-g
Copy link
Author

I meant npm cache X.

Oops I edited my message 😆

Yeah I agree with you. :)

@raineorshine
Copy link
Owner

raineorshine commented Feb 10, 2023

Added jsonc support in v16.7.3

Edit: And removed the erroneous install hint in v16.7.4 :)

@shinebayar-g
Copy link
Author

Just tested out the latest release, looks like you nailed it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants