https://github.com/node-loader/node-loader-import-maps
A nodejs loader for import maps
https://github.com/node-loader/node-loader-import-maps
Last synced: 4 days ago
JSON representation
A nodejs loader for import maps
- Host: GitHub
- URL: https://github.com/node-loader/node-loader-import-maps
- Owner: node-loader
- License: mit
- Created: 2020-04-13T23:34:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-03T06:14:22.000Z (over 1 year ago)
- Last Synced: 2025-02-02T23:47:28.636Z (19 days ago)
- Language: JavaScript
- Size: 173 KB
- Stars: 57
- Watchers: 7
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @node-loader/import-maps
A [nodejs loader](https://nodejs.org/dist/latest-v13.x/docs/api/esm.html#esm_experimental_loaders) for [import maps](https://github.com/WICG/import-maps). This allows you to customize module resolution by creating a `node.importmap` file.
## Installation
```sh
npm install --save @node-loader/import-maps# Or, if you prefer Yarn
yarn add --save @node-loader/import-maps
```## Usage
Create a file `node.importmap` in the current working directory:
```json
{
"imports": {
"my-module": "file:///Users/name/code/my-module.js"
}
}
```Now create a file that imports the mapped module:
```js
import "my-module";
```Now run node with the `--experimental-loader` flag:
```sh
node --experimental-loader @node-loader/import-maps file.js
```## Configuration
By default, node-loader import maps looks for a configuration file called `node.importmap` in the current working directory. To specify the file path to the configuration file, provide the `IMPORT_MAP_PATH` environment variable:
```sh
IMPORT_MAP_PATH=/Users/name/some/dir/node.importmap node --experimental-loader @node-loader/import-maps file.js
```## Composition
If you wish to combine import maps with other NodeJS loaders, you may do so by using [node-loader-core](https://github.com/node-loader/node-loader-core).