add support to node <18

This commit is contained in:
Aleksander Wilczyński 2024-06-24 02:37:39 +02:00
parent 1a7f49a784
commit 11c34ac72c
Signed by: alekswilc
GPG Key ID: D4464A248E5F27FE
5 changed files with 22 additions and 8 deletions

11
package-lock.json generated
View File

@ -1,16 +1,17 @@
{ {
"name": "@alekswilc/ray", "name": "@alekswilc/ray",
"version": "1.0.28", "version": "1.1.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@alekswilc/ray", "name": "@alekswilc/ray",
"version": "1.0.28", "version": "1.1.2",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@permafrost-dev/pretty-format": "^1.1.5", "@permafrost-dev/pretty-format": "^1.1.5",
"stacktrace-js": "^2.0.2" "stacktrace-js": "^2.0.2",
"uuid": "^10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.2", "@types/node": "^20.14.2",
@ -18,8 +19,7 @@
"dts-bundle-generator": "^9.5.1", "dts-bundle-generator": "^9.5.1",
"esbuild": "^0.21.5", "esbuild": "^0.21.5",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"typescript": "^5.4.5", "typescript": "^5.4.5"
"uuid": "^10.0.0"
} }
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
@ -886,7 +886,6 @@
"version": "10.0.0", "version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
"integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
"dev": true,
"funding": [ "funding": [
"https://github.com/sponsors/broofa", "https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan" "https://github.com/sponsors/ctavan"

View File

@ -13,7 +13,7 @@
"typescript": "^5.4.5" "typescript": "^5.4.5"
}, },
"name": "@alekswilc/ray", "name": "@alekswilc/ray",
"version": "1.1.1", "version": "1.1.3",
"main": "./build/aleksray.cjs", "main": "./build/aleksray.cjs",
"module": "./build/aleksray.mjs", "module": "./build/aleksray.mjs",
"typings": "./build/aleksray.d.ts", "typings": "./build/aleksray.d.ts",

View File

@ -26,6 +26,7 @@ const _ = async () => {
platform: "node", platform: "node",
outExtension: { '.js': '.cjs', }, outExtension: { '.js': '.cjs', },
bundle: true, bundle: true,
target: [ 'node12', ],
external: ['@permafrost-dev/pretty-format', 'uuid', 'stacktrace-js'] external: ['@permafrost-dev/pretty-format', 'uuid', 'stacktrace-js']
}); });
@ -36,6 +37,7 @@ const _ = async () => {
sourcemap: "external", sourcemap: "external",
platform: "node", platform: "node",
outExtension: { '.js': '.cjs', }, outExtension: { '.js': '.cjs', },
target: [ 'node12', ],
bundle: true, bundle: true,
// external: ['@permafrost-dev/pretty-format', 'p-queue', 'stacktrace-js'] // external: ['@permafrost-dev/pretty-format', 'p-queue', 'stacktrace-js']
}); });
@ -52,6 +54,7 @@ const _ = async () => {
platform: "node", platform: "node",
outExtension: { '.js': '.mjs', }, outExtension: { '.js': '.mjs', },
bundle: true, bundle: true,
target: [ 'node12', ],
external: ['@permafrost-dev/pretty-format', 'uuid', 'stacktrace-js'] external: ['@permafrost-dev/pretty-format', 'uuid', 'stacktrace-js']
}); });
@ -62,6 +65,7 @@ const _ = async () => {
format: "esm", format: "esm",
sourcemap: "external", sourcemap: "external",
platform: "node", platform: "node",
target: [ 'node12', ],
outExtension: { '.js': '.mjs', }, outExtension: { '.js': '.mjs', },
bundle: true, bundle: true,
// external: ['@permafrost-dev/pretty-format', 'p-queue', 'stacktrace-js'] // external: ['@permafrost-dev/pretty-format', 'p-queue', 'stacktrace-js']

View File

@ -13,7 +13,7 @@ export interface IPayload {
} }
} }
const LIB_STACK_SOURCES = () => [...(process.env.ALEKSRAY_LIB_STACK_SOURCES?.split(';') || []), '@alekswilc/ray', '@alekswilc\\ray', 'standalone-aleksray-bundle.js', 'standalone-aleksray-bundle.mjs', 'aleksray.js', 'aleksray.mjs'] const LIB_STACK_SOURCES = () => [...(process.env.ALEKSRAY_LIB_STACK_SOURCES?.split(';') || []), '@alekswilc/ray', '@alekswilc\\ray', 'standalone-aleksray-bundle.cjs', 'standalone-aleksray-bundle.mjs', 'aleksray.cjs', 'aleksray.mjs']
export class Payload { export class Payload {
public static create(data: Omit<IPayload, 'origin'> & Partial<IPayload>) { public static create(data: Omit<IPayload, 'origin'> & Partial<IPayload>) {

View File

@ -1,2 +1,13 @@
if (!global.fetch) {
try {
global.fetch = require('node-fetch');
} catch (e) {
if (e instanceof Error && e.message.includes('Cannot find module')) {
throw new Error('@alekswilc/ray -> Please install node-fetch (npm i node-fetch@2) for compatibility')
}
}
}
export { ray, Ray, IOptions } from './Ray'; export { ray, Ray, IOptions } from './Ray';
export { Request, Payload, IRequest, IPayload } from './Payload'; export { Request, Payload, IRequest, IPayload } from './Payload';