0.3.0 • Published 3 years ago

require-overrides v0.3.0

Weekly downloads
16
License
ISC
Repository
github
Last release
3 years ago

require-overrides

A hacky CommonJS way to alias modules with SSR counterparts.

Example

const overrides = require('require-overrides');

// use 'uhtml-ssr' instead of 'uhtml' when components
// are loaded through the server, not the client
overrides.set('uhtml', 'uhtml-ssr');

// now every
const {render, html, svg} = require('uhtml');
// will point instead at require('uhtml-ssr')

The default export is a callback with attached all Map methods and properties, and it is possible to bootstrap multiple overrides at once.

const overrides = require('require-overrides');
overrides({
  uhtml: 'uhtml-ssr',
  // overrides, as callback, will receive all the module details
  uland: (name, ...rest) => 'uland-ssr',
});

How to do this via ESM

Until import-maps is officially supported, it is possible to use @node-loader/import-maps, example:

IMPORT_MAP_PATH=test-esm/node.importmap node --experimental-loader @node-loader/import-maps test-esm/index.js
0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.0

3 years ago

0.0.0

3 years ago