Skip to content

Commit

Permalink
stress: remove custom loader and use esbuild to build (#581)
Browse files Browse the repository at this point in the history
Closes #542

---------

Co-authored-by: texuf <[email protected]>
  • Loading branch information
miguel-nascimento and texuf authored Jul 31, 2024
1 parent 5fd3f8a commit 44fce31
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 138 deletions.
105 changes: 0 additions & 105 deletions packages/stress/custom-loader.mjs

This file was deleted.

23 changes: 23 additions & 0 deletions packages/stress/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { build } from "esbuild";
import { wasmLoader } from "esbuild-plugin-wasm";

build({
entryPoints: ["./src/start.ts", "./src/demo.ts"],
bundle: true,
sourcemap: "inline",
platform: "node",
target: "node20",
format: "cjs",
outdir: "dist",
outExtension: { ".js": ".cjs" },
plugins: [wasmLoader()],
ignoreAnnotations: true,
assetNames: "[name]",
loader: {
".ts": "ts",
".wasm": "file",
},
}).catch((e) => {
console.error(e);
process.exit(1);
});
14 changes: 7 additions & 7 deletions packages/stress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
"version": "0.0.1",
"private": true,
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"build": "yarn typecheck && yarn build-esbuild",
"typecheck": "tsc --noEmit",
"build-esbuild": "node esbuild.config.mjs",
"lint": "eslint . --ext .ts",
"my-jest": "NODE_TLS_REJECT_UNAUTHORIZED=0 yarn node -r ../../scripts/node-no-warn.js --experimental-vm-modules $(yarn bin jest)",
"my-node": "node -r ../../scripts/node-no-warn.js --experimental-loader ./custom-loader.mjs",
"start": "yarn my-node ./dist/start.js",
"demo": "yarn my-node ./dist/demo.js",
"start": "node ./dist/start.cjs",
"demo": "node ./dist/demo.cjs",
"test:ci:with-entitlements": "RIVER_ENV=local_single PROCESS_INDEX=0 DEBUG='stress:*,csb:enc*,csb:dec*' DEBUG_DEPTH='10' yarn my-jest"
},
"dependencies": {
Expand All @@ -37,6 +35,8 @@
"@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^7.14.1",
"esbuild": "^0.21.5",
"esbuild-plugin-wasm": "^1.1.0",
"eslint": "^8.53.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
Expand Down
21 changes: 13 additions & 8 deletions packages/stress/src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ async function encryptDecrypt() {

printSystemInfo(logger)

logger.log('==========================spamInfo==========================')
await spamInfo(1)
logger.log('=======================encryptDecrypt=======================')
await encryptDecrypt()
logger.log('========================sendAMessage========================')
await sendAMessage()

process.exit(0)
const run = async () => {
logger.log('==========================spamInfo==========================')
await spamInfo(1)
logger.log('=======================encryptDecrypt=======================')
await encryptDecrypt()
logger.log('========================sendAMessage========================')
await sendAMessage()
process.exit(0)
}

run().catch(() => {
process.exit(1)
})
Empty file removed packages/stress/src/index.ts
Empty file.
38 changes: 20 additions & 18 deletions packages/stress/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,24 @@ function getStressMode(): string {
return process.env.STRESS_MODE
}

switch (getStressMode()) {
case 'chat':
await startStressChat({
config,
processIndex,
rootWallet: getRootWallet().wallet,
})
break
case 'setup_chat':
await setupChat({
config,
rootWallet: getRootWallet().wallet,
})
break
default:
throw new Error('unknown stress mode')
const run = async () => {
switch (getStressMode()) {
case 'chat':
await startStressChat({
config,
processIndex,
rootWallet: getRootWallet().wallet,
})
break
case 'setup_chat':
await setupChat({
config,
rootWallet: getRootWallet().wallet,
})
break
default:
throw new Error('unknown stress mode')
}
exit(0)
}

exit(0)
run().catch(() => exit(1))
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3784,6 +3784,8 @@ __metadata:
"@types/node": ^20.5.0
"@typescript-eslint/eslint-plugin": ^6.10.0
"@typescript-eslint/parser": ^7.14.1
esbuild: ^0.21.5
esbuild-plugin-wasm: ^1.1.0
eslint: ^8.53.0
eslint-import-resolver-typescript: ^3.5.5
eslint-plugin-import: ^2.27.5
Expand Down Expand Up @@ -8952,6 +8954,13 @@ __metadata:
languageName: node
linkType: hard

"esbuild-plugin-wasm@npm:^1.1.0":
version: 1.1.0
resolution: "esbuild-plugin-wasm@npm:1.1.0"
checksum: 382df12ecb92634d0f526cad4792b0ac5dc8016cdf63e23d9ee099f0f2c530855463cc45045c4a6ec10a6a1bd2ff59b5c4b24e6314a361fa70cc57645caf602b
languageName: node
linkType: hard

"esbuild@npm:^0.21.3, esbuild@npm:^0.21.5":
version: 0.21.5
resolution: "esbuild@npm:0.21.5"
Expand Down

0 comments on commit 44fce31

Please sign in to comment.