hayd / deno-udd

Update Deno Dependencies - update dependency urls to their latest published versions
MIT License
328 stars 18 forks source link

Extra suffix slash #58

Open Xeevis opened 2 years ago

Xeevis commented 2 years ago

When updating module from esm.sh

import confetti from "https://esm.sh/canvas-confetti@1.3.0";

UDD turns it into

import confetti from "https://esm.sh/canvas-confetti@1.4.0/";

It's a convention to not include extra slash and it's not just cosmetic, it actually invalidates the cache, as Deno will keep separate copies for both canvas-confetti@1.4.0 and canvas-confetti@1.4.0/

image

hayd commented 2 years ago

cc @takker99 .

Is this the case for all "scoped" urls?

Xeevis commented 2 years ago

I see in tests that suffix slash is always created for paths that don't end with extension. There shouldn't be any assumptions about the final string, only the version portion from original string needs to be changed (applies to all registries). For example this test needs to pass, but currently doesn't and even output may be different than expected because of missing pin (esm.sh engine version).

Deno.test("registryEsmShPinned", () => {
  const url = "https://esm.sh/foo@0.1.0?pin=63";
  const v = lookup(url, REGISTRIES);
  assert(v !== undefined);

  const vAt = v.at("0.2.0");
  assertEquals(vAt.url, "https://esm.sh/foo@0.2.0?pin=63");
});
    [Diff] Actual / Expected

-   "https://esm.sh/foo@0.2.0/"
+   "https://esm.sh/foo@0.2.0?pin=63"
omar2205 commented 2 years ago

@hayd any update on this? A slash is still being added, which results in errors.

{
  "imports": {
    "twind": "https://esm.sh/twind@0.16.17",
    "twind/": "https://esm.sh/twind@0.16.17/"
    // after
    "twind": "https://esm.sh/twind@1.0.0-next.38/",
    "twind/": "https://esm.sh/twind@1.0.0-next.38//"
  }
}