Skip to content

Instantly share code, notes, and snippets.

@aduth
Created August 8, 2020 18:28
Show Gist options
  • Save aduth/bbd9030d29c25f338c1294d04495c7d3 to your computer and use it in GitHub Desktop.
Save aduth/bbd9030d29c25f338c1294d04495c7d3 to your computer and use it in GitHub Desktop.
Alternative Node Main Entrypoint with Babel (babel-plugin-module-resolver)
const { join } = require('path');
module.exports = {
plugins: [
[
'module-resolver',
{
root: ['./packages'],
alias: {
'^@my-scope\\/([^/]+)$': (match) => {
const [original, pkg] = match;
const manifest = require(`./packages/${pkg}/package.json`);
const src = manifest['main:src'];
return join(original, src);
},
},
},
],
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment