0.1.0 ā€¢ Published 11 months ago

@jcbhmr/esmurl v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

šŸš§ Under construction šŸ‘·ā€ā™‚ļø

Bound ESM URLs

šŸŽ Create a self-contained ESM blob: URL using a function & local import.meta

npm.io

Installation

npm install @jcbhmr/esmurl

šŸ›‘ Currently only Node.js is supported. Check #5 for more details.

Usage

import esmurl from "@jcbhmr/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);