denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: Statically analyzable dynamic imports says "module not found" in the Playground #525

Closed kentasaito closed 1 year ago

kentasaito commented 1 year ago

Problem description

I understand that "Dynamic imports that are not statically analyzable don't work.", but I'm talking about "statically analyzable dynamic imports".

I tried the example in the article below. https://deno.com/deploy/changelog#2023-07-03 - Statically analyzable dynamic imports

import { serve } from "https://deno.land/std@0.192.0/http/server.ts";

serve(async (req: Request) => {
  const uuid = "https://deno.land/std@0.192.0/uuid/mod.ts";
  const { version } = await import(uuid);
  const ver = version("109156be-c4fb-41ea-b1b4-efe1671c5836");
  return new Response(ver);
});

It works in the CLI, but in the playground the following error occurs.

gcp-asia-northeast1TypeError: module not found: 'https://deno.land/std@0.192.0/uuid/mod.ts'
    at async Server.<anonymous> (file:///src/main.ts:5:23)
    at async Server.#respond (https://deno.land/std@0.204.0/http/server.ts:305:18) {
  code: "ERR_MODULE_NOT_FOUND"
}

Steps to reproduce

Run the above code in the Playground.

Expected behavior

The module will be imported and then "4" will be shown.

Environment

Deno PlayGround (The error occurs.)

For your reference: deno 1.37.2 (It worked.)

Possible solution

No response

Additional context

When written as follows, the expected behavior will occur.

import { version } from "https://deno.land/std@0.192.0/uuid/mod.ts";
kentasaito commented 1 year ago

When I opened the same Playground again without making any changes, the expected behavior (a "4" was displayed) occurred.