1. check-export-map
Check if entries in an export map in package.json are valid and point to actual files/folders
check-export-map
Package: check-export-map
Created by: marvinhagemeister
Last modified: Fri, 24 Nov 2023 09:41:30 GMT
Version: 1.3.1
License: MIT
Downloads: 1,675
Repository: https://github.com/marvinhagemeister/check-export-map

Install

npm install check-export-map
yarn add check-export-map

Check export maps

A simple cli tool that checks if the export map defined in a package.json file is correct and that the referenced files/folders exist.

Rules:

  • Entries must start with a .
  • Must have the following entries:
    • . = main export when you do import * as foo from "my-package"
    • ./package.json = allow user to import the package's package.json file
  • Entry type import must end with .mjs
  • Entry file paths must be relative and start with a .
  • All referenced files/folders must exist on disk

Example of a valid export map in package.json:

 {
  "name": "preact",
  "exports": {
    ".": {
      "browser": "./dist/preact.module.js",
      "umd": "./dist/preact.umd.js",
      "import": "./dist/preact.mjs",
      "require": "./dist/preact.js"
    },
    "./compat": {
      "browser": "./compat/dist/compat.module.js",
      "umd": "./compat/dist/compat.umd.js",
      "import": "./compat/dist/compat.mjs",
      "require": "./compat/dist/compat.js"
    },
    "./compat/server": {
      "require": "./compat/server.js"
    },
    "./package.json": "./package.json"
  }
}

Usage

Add the package via:

 npm install -D check-export-map
# yarn
yarn add -D check-export-map

...and add an script to your package.json:

 {
	"name": "my-package",
	"scripts": {
		"test": "check-export-map"
	}
}

Global installation

You can install check-export-map globally to invoke it from any directory.

 npm install -g check-export-map

CLI documentation

 Check if the export map declared in package.json is valid.

Usage
  check-export-map [options] <...FILES>
	
Options
  -v, --version    Displays current version
  -h, --help       Displays this message

LICENSE

MIT, see the LICENSE file.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code