fix: nodenext moduleResolution for js peer (#271)

This commit is contained in:
Dima 2023-02-22 17:46:14 +07:00 committed by GitHub
parent 96fa90affe
commit 78d98f15c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 41 additions and 31 deletions

View File

@ -27,7 +27,7 @@
"@types/jest": "28.1.0",
"jest": "28.1.0",
"ts-jest": "28.0.2",
"js-base64": "3.7.2",
"js-base64": "3.7.5",
"@rollup/plugin-inject": "5.0.3",
"vite-plugin-replace": "0.1.1",
"vite": "4.0.4",

View File

@ -1,16 +1,17 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
testPathIgnorePatterns: ['dist'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
"useESM": true
}
]
}
};

View File

@ -38,7 +38,7 @@
"@libp2p/peer-id-factory": "2.0.1",
"@libp2p/interface-peer-id": "2.0.1",
"@libp2p/interface-keys": "1.0.7",
"js-base64": "3.7.2",
"js-base64": "3.7.5",
"it-length-prefixed": "8.0.4",
"it-pipe": "2.0.5",
"it-map": "2.0.0",
@ -60,6 +60,6 @@
"@types/uuid": "8.3.2",
"@types/jest": "29.4.0",
"jest": "29.4.1",
"ts-jest": "29.0.5"
"ts-jest": "next"
}
}

View File

@ -17,6 +17,7 @@
import type { PeerIdB58 } from '@fluencelabs/interfaces';
import type { JSONArray, JSONObject, LogLevel } from '@fluencelabs/marine-js/dist/types';
import type { RunParameters, CallResultsArray, InterpreterResult } from '@fluencelabs/avm';
// @ts-ignore
import type { WorkerImplementation } from 'threads/dist/types/master';
export type ParticleHandler = (particle: string) => void;

View File

@ -1,10 +1,10 @@
import { CallParams } from '@fluencelabs/interfaces';
import { toUint8Array } from 'js-base64';
import { CallServiceData } from '../../../interfaces/commonTypes.js';
import { builtInServices } from '../../builtins/common.js';
import { KeyPair } from '../../../keypair/index.js';
import { Sig, defaultSigGuard } from '../../builtins/Sig.js';
import { allowServiceFn } from '../../builtins/securityGuard.js';
import { builtInServices } from '../../builtins/common.js';
const a10b20 = `{
"a": 10,

View File

@ -3,9 +3,9 @@ import { FluenceConnection, ParticleHandler } from '../interfaces/index.js';
import { fromBase64Sk } from '../keypair/index.js';
import { FluencePeer } from './FluencePeer.js';
import { MarineBackgroundRunner } from '../marine/worker/index.js';
import { avmModuleLoader, controlModuleLoader } from './utilsForNode';
import { marineLogFunction } from './utils';
import { MarineBasedAvmRunner } from './avm';
import { avmModuleLoader, controlModuleLoader } from './utilsForNode.js';
import { marineLogFunction } from './utils.js';
import { MarineBasedAvmRunner } from './avm.js';
import log from 'loglevel';
import { WorkerLoaderFromFs } from '../marine/deps-loader/node.js';

View File

@ -1,5 +1,7 @@
// @ts-ignore
import { BlobWorker } from 'threads';
import { fromBase64, toUint8Array } from 'js-base64';
// @ts-ignore
import type { WorkerImplementation } from 'threads/dist/types/master';
import { LazyLoader } from '../../interfaces/index.js';
import { Buffer } from 'buffer';

View File

@ -1,7 +1,9 @@
import { createRequire } from 'module';
import { LazyLoader } from '../../interfaces/index.js';
// @ts-ignore
import type { WorkerImplementation } from 'threads/dist/types/master';
// @ts-ignore
import { Worker } from 'threads';
import { Buffer } from 'buffer';
import * as fs from 'fs';

View File

@ -17,7 +17,9 @@
import { MarineService } from '@fluencelabs/marine-js/dist/MarineService';
import type { Env, MarineServiceConfig } from '@fluencelabs/marine-js/dist/config';
import type { JSONArray, JSONObject, LogMessage } from '@fluencelabs/marine-js/dist/types';
// @ts-ignore
import { Observable, Subject } from 'threads/observable';
// @ts-ignore
import { expose } from 'threads/worker';
let marineServices = new Map<string, MarineService>();

View File

@ -1,6 +1,8 @@
import { LazyLoader } from '../../interfaces/index.js';
// @ts-ignore
import type { WorkerImplementation } from 'threads/dist/types/master';
// @ts-ignore
import { Worker } from 'threads';
export class WorkerLoader extends LazyLoader<WorkerImplementation> {

View File

@ -18,7 +18,9 @@ import type { JSONArray, JSONObject, LogLevel } from '@fluencelabs/marine-js/dis
import { LogFunction, logLevelToEnv } from '@fluencelabs/marine-js/dist/types';
import type { IMarine, IWorkerLoader, IWasmLoader } from '../../interfaces/index.js';
import type { MarineBackgroundInterface } from '../worker-script/index.js';
// @ts-ignore
import { spawn, Thread } from 'threads';
// @ts-ignore
import type { ModuleThread } from 'threads';
export class MarineBackgroundRunner implements IMarine {

View File

@ -2,8 +2,9 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"moduleResolution": "node"
"moduleResolution": "nodenext"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
"exclude": ["node_modules", "dist"],
"esModuleInterop": true
}

20
pnpm-lock.yaml generated
View File

@ -123,7 +123,7 @@ importers:
'@types/node': 16.11.59
buffer: 6.0.3
jest: 28.1.0
js-base64: 3.7.2
js-base64: 3.7.5
process: 0.11.10
ts-jest: 28.0.2
vite: 4.0.4
@ -140,7 +140,7 @@ importers:
'@types/jest': 28.1.0
'@types/node': 16.11.59
jest: 28.1.0_@types+node@16.11.59
js-base64: 3.7.2
js-base64: 3.7.5
ts-jest: 28.0.2_byf75w6xilfwy3ncjzlldwxox4
vite: 4.0.4_@types+node@16.11.59
vite-plugin-replace: 0.1.1_vite@4.0.4
@ -192,13 +192,13 @@ importers:
it-map: 2.0.0
it-pipe: 2.0.5
jest: 29.4.1
js-base64: 3.7.2
js-base64: 3.7.5
libp2p: 0.42.2
loglevel: 1.8.1
multiformats: 11.0.1
rxjs: 7.5.5
threads: 1.7.0
ts-jest: 29.0.5
ts-jest: next
ts-pattern: 3.3.3
uint8arrays: 4.0.3
uuid: 8.3.2
@ -223,7 +223,7 @@ importers:
it-length-prefixed: 8.0.4
it-map: 2.0.0
it-pipe: 2.0.5
js-base64: 3.7.2
js-base64: 3.7.5
libp2p: 0.42.2
loglevel: 1.8.1
multiformats: 11.0.1
@ -241,7 +241,7 @@ importers:
'@types/jest': 29.4.0
'@types/uuid': 8.3.2
jest: 29.4.1
ts-jest: 29.0.5_knhdxpg4pvwuf6vrybjt5d2q5i
ts-jest: 29.0.0-next.1_knhdxpg4pvwuf6vrybjt5d2q5i
packages:
@ -10331,12 +10331,8 @@ packages:
- ts-node
dev: true
/js-base64/3.7.2:
resolution: {integrity: sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==}
/js-base64/3.7.5:
resolution: {integrity: sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA==}
dev: true
/js-sdsl/4.3.0:
resolution: {integrity: sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==}
@ -14497,8 +14493,8 @@ packages:
yargs-parser: 20.2.9
dev: true
/ts-jest/29.0.5_knhdxpg4pvwuf6vrybjt5d2q5i:
resolution: {integrity: sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==}
/ts-jest/29.0.0-next.1_knhdxpg4pvwuf6vrybjt5d2q5i:
resolution: {integrity: sha512-bVo2GDuJiV+cWEYB72tdz2Ips4JDKa04bcKikPULxxUHT4fsoY1zB2zvsrJym18qrFpXyVrIdgJFLfEx2YTkbg==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
peerDependencies:

View File

@ -8,6 +8,7 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"esModuleInterop": true,
"declaration": true,
"moduleResolution": "nodenext"
}