A hacky CommonJS way to alias modules with SSR counterparts.
constoverrides=require('require-overrides');// use 'uhtml-ssr' instead of 'uhtml' when components// are loaded through the server, not the clientoverrides.set('uhtml','uhtml-ssr');// now everyconst{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.
constoverrides=require('require-overrides');overrides({uhtml: 'uhtml-ssr',// overrides, as callback, will receive all the module detailsuland: (name, ...rest)=>'uland-ssr',});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