swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.76k stars 73 forks source link

feat(register): support hook options #650

Closed Arwid closed 2 years ago

Arwid commented 2 years ago

This adds the opportunity to transpile files within node_modules.

I'm not that familiar with the swc-node library so feel free to close/reimplement as you see fit but decided to leave this PR here to at least share visibility into what we hacked together for our own needs.

const { register } = require('@swc-node/register/register')
register(/* use defaults */ undefined, {
  ignoreNodeModules: false,
  matcher: (filename) => {
    // Custom file matcher
    return !/node_modules\/(?!@someorg)/.test(filename)
  }
}

Side note: didn't mean to create this PR here, thought it would go to our own fork of swc-node when I ran gh pr create 😆

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.