Create wrapper index.js for Node.js library

This commit is contained in:
Wilson Lin 2022-03-28 10:09:50 +11:00
parent a38b0ac078
commit f3a3299d02
2 changed files with 5 additions and 2 deletions

3
nodejs/index.js Normal file
View File

@ -0,0 +1,3 @@
// This wrapper file exists to allow importing from ESM contexts, as Node.js does not allow importing ".node" modules directly from ESM.
module.exports = require("./index.node");

View File

@ -2,9 +2,9 @@ const fs = require("fs");
const common = {
version: "0.8.0",
main: "index.node",
main: "index.js",
types: "index.d.ts",
files: ["cli.js", "postinstall.js", "index.d.ts"],
files: ["cli.js", "postinstall.js", "index.d.ts", "index.js"],
scripts: {
build: "node-gyp build && shx mv build/Release/index.node index.node",
clean: