Userland module that implements the module path mapping that Node.js does with "exports" in package.json

Overview

exports-map

Userland module that implements the module path mapping that Node.js does with "exports" in package.json

npm install exports-map

Usage

const em = require('exports-map')

// Specify the runtimes you support
const runtimes = new Set(['import'])

// Get an export map somewhere, this one is from preact
const exportsMap = {
  ".": {
    "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",
    "require": "./compat/dist/compat.js",
    "import": "./compat/dist/compat.mjs"
  }
}

// And map a path

const main = em(exportsMap, runtimes, '.')
console.log(main) // prints ./dist/preact.mjs

const compact = em(exportsMap, runtimes, './compat')
console.log(compact) // prints ./compat/dist/compat.mjs

const unknown = em(exportsMap, runtimes, './foobarbaz')
console.log(unknown) // is null

License

MIT

You might also like...

Exports a JPDB deck to a Yomichan compatible frequency list.

Exports a JPDB deck to a Yomichan compatible frequency list.

JPDB Frequency List A frequency list generated using most of the jpdb corpus can be found in the releases. It is not exhaustive, as there is no deck a

Nov 16, 2022

PEARL (Planetary Computer Land Cover Mapping) Platform API and Infrastructure

PEARL (Planetary Computer Land Cover Mapping) Platform API and Infrastructure

PEARL API & Infrastructure PEARL is a landcover mapping platform that uses human in the loop machine learning approach. This repository contains the A

Dec 23, 2022

Mind Mapping to excel, or excel to .xmind file

Mind Mapping To Excel Project setup Prepare project npm install 1、Fetch data and generate excel Open the Mind Mapping like this Process On Mind Mappi

May 5, 2022

✂️ Find unused files, dependencies and exports in your TypeScript project

✂️ Knip Knip scans your JavaScript and TypeScript projects for unused files, dependencies and exports: things that can be removed! Less code means bet

Jan 1, 2023

This Photoshop script exports all top-level layers and groups to cropped PNG and JPEG files and creates a file usable in Tumult Hype 4 based on your Photoshop document.

This Photoshop script exports all top-level layers and groups to cropped PNG and JPEG files and creates a file usable in Tumult Hype 4 based on your Photoshop document.

Export To Hype (Photoshop Edition) This Photoshop script exports all top-level layers and groups to cropped PNG and JPEG files and creates a file usab

Nov 9, 2022

Visual scraper interface, exports to puppeteer script which you can run anywhere.

Jawa - Visual Scraper Visual scraper interface, exports to puppeteer script which you can run anywhere. You can try it out here https://jawa.kickass.c

Nov 16, 2022

Uncensorable, immutable microblogging platform that is completely decentralized and does not rely on any centralized systems.

Uncensorable, immutable microblogging platform that is completely decentralized and does not rely on any centralized systems.

Zooko Truly decentralized, immutable and uncensorable microblogging Zooko is a working-example, proof-of-concept proving that you can have a decentral

Apr 20, 2022

🤪 A linter, prettier, and test suite that does everything as-simple-as-possible.

🤪 A linter, prettier, and test suite that does everything as-simple-as-possible.

Features Fully Featured Code Grading Knowing if you need to work on your code is important- that's why we grade your code automatically. But, unlike o

Sep 25, 2022

A quick and easy to use security reconnaissance webapp tool, does OSINT, analysis and red-teaming in both passive and active mode. Written in nodeJS and Electron.

A quick and easy to use security reconnaissance webapp tool, does OSINT, analysis and red-teaming in both passive and active mode. Written in nodeJS and Electron.

ᵔᴥᵔ RedJoust A quick and easy to use security reconnaissance webapp tool, does OSINT, analysis and red-teaming in both passive and active mode. Writte

Oct 31, 2022
Owner
Mathias Buus
Rød grød med fløde
Mathias Buus
ROP userland execution for PS5 (4.03)

# Exploring the Playstation 5 Security - Userland Introduction The PlayStation 5 was released on November 12th 2020. While it's similar to the PS4 in

null 230 Dec 2, 2022
Get exports of an local npm package.

pkg-exports Get exports of an local npm package. Install npm i pkg-exports Usage getExportsRuntime Get the exports by evaluate the module in worker th

Anthony Fu 103 Nov 12, 2022
This module exports all the commands that Redis supports

This module exports all the commands that Redis supports

ioredis 5 Mar 24, 2022
Find and parse the tsconfig.json file from a directory path

get-tsconfig Find and parse tsconfig.json files. Features Zero dependencies (not even TypeScript) Tested against TypeScript for accuracy Supports comm

hiroki osame 66 Jan 2, 2023
This package enables you to mount your Remix app at a different path than root

Remix Mount Routes This package enables you to mount your Remix app at a different path than root. ?? Installation > npm install -D remix-mount-routes

Kiliman 26 Dec 17, 2022
An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Snyk Labs 57 Dec 28, 2022
Multi-platform node package bundle to a package.json.

dmpc Multi-platform node package bundle to a package.json. install ### npm mode npm i -g @kingsword/dmpc ### yarn mode yarn global add @kingsword/dmp

Kingsword 2 Oct 16, 2022
NoExGen is a node.js express application generator with modern folder structure, namespace/project mapping and much more! It contains preconfigured Settings and Routing files, ready to be used in any project.

Installation $ npm install -g noexgen Quick Start You can use Node Package Execution to create your node-express application as shown below: Create th

Souvik Sen 7 Oct 8, 2022
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (洪 民憙) 13 Sep 2, 2022
Collect and generate mapping from file-based routers

roullector: route collector Collect and generate route data from a file-based router such as svelte-kit's What this does: show / hide <!-- before -->

Quang Phan 4 Apr 9, 2022