0.5.0 ā€¢ Published 10 months ago

esmurl v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Bound ESM URLs

šŸŽ Create a self-contained ESM blob: URL from a function

npm.io

Installation

npm install esmurl
import esmurl from "https://esm.sh/esmurl";

Usage

import esmurl from "esmurl";

const url = esmurl(import.meta, async () => {
  const url = await import("node:url");
  const { default: isOdd } = await import("is-odd");
  const { hello } = await import("./greetings.js");

  console.log("/ as a file: URL => %s", url.pathToFileURL("/").href);
  console.log(hello("George"));
  console.log("Is 100 odd? %s", isOdd(100));

  return 42;
});

const m = await import(url);
console.log("Return value is exposed as default export: %s", m.default);
0.5.0

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago