W4G1 / multithreading

⚡ Multithreading functions in JavaScript to speedup heavy workloads, designed to feel like writing vanilla functions.
https://multithreading.io
MIT License
317 stars 10 forks source link

Using imports from external packages #5

Open aurelien-boubennec opened 2 months ago

aurelien-boubennec commented 2 months ago

Hi,

When I test this code in a React web app:

import { threaded } from "multithreading";

const getId = threaded(async function* () {
  const { v4 } = yield "uuid"; // Import other package

  return v4();
}

console.log(await getId()); // 1a107623-3052-4f61-aca9-9d9388fb2d81

I get the following error:

TypeError: Failed to execute 'resolve' on 'import.meta': Failed to resolve module specifier uuid: Relative references must start with either "/", "./", or "../".

The uuid package is installed and I use Vite as the dev server.

I tried yield "./uuid" but it returns undefined.

Any idea what path is expected? Thank you 🙏

aurelien-boubennec commented 2 months ago

Seems like the is the only way that works in my project: const { v4 } = yield "https://esm.sh/uuid"

Though I tried const { _ } = yield "https://esm.sh/lodash"; but _ is returned as undefined.