Slide 157
Slide 157 text
Parsing CJS modules
© 2022 Wantedly, Inc.
const fs = require("node:fs");
const m = { exports: {} };
const f = new Function(
"exports", "require", "module", "__filename", "__dirname",
fs.readFileSync("lib.cjs", "utf-8"));
f(m.exports, null, m, "", "");
console.log(m.exports);
app.cjs