This repository provides an import map JSON file that simplifies importing modules from the @butility
package family directly from node_modules
without requiring the exact directory names.
In typical JavaScript, in browser, when importing modules from node_modules
, you often need to know the precise directory structure. This can be hard, especially when working with scoped packages like @butility
.
The import map defined in this repository eliminates the need for perfect directory names, allowing you to easily map module names to their corresponding paths in node_modules
for @butility pkgs.
- Simplifies module imports for
@butility
packages for browsers. - Eliminates the need to reference exact directory structures within
node_modules
. - Provides a cleaner and more intuitive way to import modules.
- Clone this repository or copy the provided
importmap.json
file into your project. - Add a reference to the
importmap.json
in your project configuration (e.g., for browsers that support import maps inside script tag or using a bundler that supports import maps). - Now, when you import
@butility
modules, they will be correctly resolved fromnode_modules
without worrying about exact directory names.
import { body } from './node_modules/@butility/dom/html.js';
import { body } from '@butility/html';
To use this import map in your project:
- Ensure that your project supports import maps (e.g., using a compatible bundler or runtime).
- Add the
importmap.json
file to your project. - Reference the import map in your application entry point or configuration.
{
"imports": {
"@butility/dom": "./node_modules/@butility/dom/dom.js"
}
}
Now, the specified modules will be resolved from the correct paths within node_modules
without the need for perfect directory names.
This repository is open source and available under the MIT License.