esbuild-plugin-importmaps
v1.0.0
Published
esbuild plugin for utilizing import maps and url imports during bundling
Downloads
2
Readme
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/[email protected]",
},
};
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.