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

Values that startsWith("jsr:") in the valueToUrl() should also be returned as is #404

Open
Gumball12 opened this issue Apr 27, 2024 · 2 comments

Comments

@Gumball12
Copy link

Deno can use modules that exist in the JSR registry as follows:

import { camelCase } from "jsr:@luca/cases";

camelCase("hello word"); // "helloWord"

For this purpose, dnt should return paths starting with jsr: as the are.

// lib/utils.ts

export function valueToUrl(value: string) {
  const lowerCaseValue = value.toLowerCase();
  if (
    lowerCaseValue.startsWith("http:") ||
    lowerCaseValue.startsWith("https:") ||
    lowerCaseValue.startsWith("npm:") ||
    lowerCaseValue.startsWith("node:") ||
-    lowerCaseValue.startsWith("file:")
+    lowerCaseValue.startsWith("file:") ||
+    lowerCaseValue.startsWith("jsr::")
  ) {
    return value;
  } else {
    return path.toFileUrl(path.resolve(value)).toString();
  }
}

This allows mappings to also handle the jsr module.

await build({
  mappings: {
    "jsr:@luca/cases": {
      // If add `@jsr:registry=https://npm.jsr.io` to .npmrc,
      // it can import module `@luca/cases` as shown below
      // https://jsr.io/docs/npm-compatibility#advanced-setup
      name: "@jsr/luca__cases",
    },
  },
});
@Gumball12
Copy link
Author

I just saw a PR from a month ago about this. I'll close this issue, but it seems like this open source is dead because it hasn't been resolved yet 😢

@dsherret dsherret reopened this Apr 27, 2024
@UrielCh
Copy link
Contributor

UrielCh commented May 22, 2024

Hi,

I have start moving to JSR, and I confime that the current dnt is not JSR frendly.

I migrate a first package named deno-logger to JSR so the package is available using:

for this one have no issue.

But now that I want to migrate my midjourney client that use x/logger, I have to hot replace my dependency to keep my dnt script working so the package is available using:

My deployement script for dnt is now overcomplicated to let me use a JSR package:

  const depsts = Deno.readTextFileSync("deps.ts");
  const depstsPatch = depsts.replaceAll(
    "jsr:@deno-lib/[email protected]",
    "https://deno.land/x/[email protected]/logger.ts",
  );

  Deno.writeTextFileSync("deps.ts", depstsPatch);

then I rollback the dep.ts

so I can keep the original mapping:

"https://deno.land/x/[email protected]/logger.ts": {
        name: "@denodnt/logger",
        version: "1.1.5",
        peerDependency: false,
      },

so @dsherret can you give us an hint ?

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

No branches or pull requests

3 participants