slash-node-modules-loader

1.0.3 • Public • Published

Slash Node Modules Loader

This module rewrites paths during require() so that if it sees a prefix of '/node_modules/' it is removed.

Example usage:

node -r slash-node-modules-loader ./index.js
// in index.js
 
const path = require('/node_modules/path');
const express = require('/node_modules/express');
const request = require('express');

It also works with esm for ES Modules.

node -r esm -r slash-node-modules-loader ./index.js
// in index.js
 
import HTMLElementPlus from '/node_modules/HTMLElementPlus';

The purpose of this is to allow ES Modules to be used isomorphicly by exposing '/node_modules/' as a route on the server. So any packages from npm can be used on the client and server without needing to use proxy modules.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i slash-node-modules-loader

      Weekly Downloads

      8

      Version

      1.0.3

      License

      ISC

      Unpacked Size

      1.47 kB

      Total Files

      3

      Last publish

      Collaborators

      • adarosecannon