chenyc
2026-04-21 8632fbd73fdb15f22fae9cd36b9ed3e0635360f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env node
 
const fs = require('fs');
const path = require('path');
const Module = require('module');
 
const bundlePath = path.join(__dirname, 'bundle', 'index.cjs');
const source = fs.readFileSync(bundlePath, 'utf8');
const bundledModule = new Module(bundlePath);
 
bundledModule.filename = bundlePath;
bundledModule.id = '.';
bundledModule.paths = Module._nodeModulePaths(path.dirname(bundlePath));
Module._cache[bundlePath] = bundledModule;
process.mainModule = bundledModule;
require.main = bundledModule;
 
bundledModule._compile(source, bundlePath);