Require in ESM mode in nodejs


Here's the way to get the old require back in nodejs when you are in ESM mode.

At some point later you can use import.meta.resolve to resolve paths and what not but for now if you need require.resolve or even just a blocking import function, this is the way.

// Waiting for import.meta.resolve to be supported but meanwhile we can hack around it
import { createRequire } from 'module';
const require = createRequire(import.meta.url); // This is the old `require`