1.0.0 • Published 1 year ago

esbuild-plugin-importmaps v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

esbuild-plugin-importmap

Esbuild plugin for utilizing import maps and url imports during bundling. This works in all modern runtimes, including browsers for use with esbuild-wasm.

Usage

Import the plugin from esbuild-plugin-importmap:

import { importmapPlugin } from "esbuild-plugin-importmap";

Define your importmap object:

const importmap = {
  imports: {
    "preact-progressive-enhancement":
      "https://esm.sh/preact-progressive-enhancement@1.0.5",
  },
};

Or read it from a file:

// Deno
const file = Deno.readTextFileSync("./importmap.json");

// Node
const file = fs.readFileSync("importmap.json", "utf8");

const importmap = JSON.parse(file);

And create your plugin for use with esbuild:

esbuild.build({
  bundle: true,
  minify: true,
  format: "esm",
  entryPoints: ["./mod.js"],
  plugins: [fileTreePlugin, importmapPlugin(importmap)],
  write: false,
});

Contributing

This package uses chompbuild for task management.

Run chomp test to test your code.

Run chomp package to package your code.

1.0.0

1 year ago