Skip to content

SoonIter/alias-register

Repository files navigation

alias-register

Version

Get Started

say bye to webpack multi-instances ~

// alias.config.cjs
const path = require('path');

const config = {
  resolve: {
    alias: {
      lib: path.join(__dirname, 'lib'),
    },
  },
};

module.exports = config;
node --loader alias-register ./main.js
# or
NODE_OPTIONS="--loader alias-register" node ./main.js

# if Node.js v20.6.0 and above
node --import alias-register ./main.js
NODE_OPTIONS="--import alias-register" node ./main.js

Other Usages

ESM only loader

If you only need to add TypeScript support in a Module context, you can use the ESM loader:

Node.js v20.6.0 and above
node --import alias-register/esm ./main.js
Node.js v20.5.1 and below
node --loader alias-register/esm ./main.js

CommonJS only loader

If you only need to add TypeScript & ESM support in a CommonJS context, you can use the CJS loader:

node --require alias-register/cjs ./main.js