build: allow node package depends on workspace packages (#11892)

This commit is contained in:
forehalo
2025-04-23 10:04:58 +00:00
parent 64997d4a0e
commit c00671dd84
28 changed files with 326 additions and 325 deletions

View File

@@ -1,15 +1,21 @@
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
/** @type {import('.')} */
const binding = require('./server-native.node');
let binding;
try {
binding = require('./server-native.node');
} catch {
binding =
process.arch === 'arm64'
? require('./server-native.arm64.node')
: process.arch === 'arm'
? require('./server-native.armv7.node')
: require('./server-native.x64.node');
}
export const mergeUpdatesInApplyWay = binding.mergeUpdatesInApplyWay;
export const verifyChallengeResponse = binding.verifyChallengeResponse;
export const mintChallengeResponse = binding.mintChallengeResponse;
export const getMime = binding.getMime;
export const Tokenizer = binding.Tokenizer;
export const fromModelName = binding.fromModelName;
export const htmlSanitize = binding.htmlSanitize;
export const parseDoc = binding.parseDoc;
module.exports.mergeUpdatesInApplyWay = binding.mergeUpdatesInApplyWay;
module.exports.verifyChallengeResponse = binding.verifyChallengeResponse;
module.exports.mintChallengeResponse = binding.mintChallengeResponse;
module.exports.getMime = binding.getMime;
module.exports.Tokenizer = binding.Tokenizer;
module.exports.fromModelName = binding.fromModelName;
module.exports.htmlSanitize = binding.htmlSanitize;
module.exports.parseDoc = binding.parseDoc;

View File

@@ -4,7 +4,6 @@
"engines": {
"node": ">= 10.16.0 < 11 || >= 11.8.0"
},
"type": "module",
"main": "./index.js",
"module": "./index.js",
"types": "index.d.ts",