Generate importmap for node_modules
npm install @jsenv/importmap-node-module> Generate import maps for browser-based execution of code that relies on Node.js module resolution
- Overview
- How It Works
- Usage
- CLI
- API
- API Options
- Using Import Maps
- TypeScript Support
- See Also
This package generates import maps that implement Node.js ESM resolution algorithm. With these import maps, code dependent on Node.js module resolution becomes executable in browsers.
Example of code relying on Node.js module resolution:
``js`
import lodash from "lodash";
1. Use package.json and node_modules/**/package.json to generate mappings corresponding to node esm resolution algorithm
2. (Optional) Test importmap against all import found in js module files. This step allow to remove unused mappings to keep only thoose actually used in the codebase
3. Write mappings into a file
The simplest way to use this project is with npx:
`console`
npx @jsenv/importmap-node-module index.html
This writes mappings in index.html inside a