Node 端 CommonJS 规范增强版,支持运行时从 url 和 ts 文件加载模块...
[English doc] [中文文档]
- 从 url 加载一个 CommonJS 模块
const r = require("nedo");
const code = r(
"https://raw.githubusercontent.com/loatheb/nedo/master/__test/case/code.js"
);
console.log(code); // hello code.js
- 从 ts 文件加载一个 CommonJS 模块
const r = require("nedo");
const code = r("./code.ts");
console.log(code); // hello code.ts
- 顶层 await
// index.js
const r = require("nedo");
r("./code.js");
// code.js: 这里并不需要将 await 包裹在 async 函数中
await doSomeAsyncThings();
可以 review __test/index.js 来获取更多关于使用的信息.
MIT