diff --git a/package.json b/package.json index 3c6f502..e757f5e 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "jest-each": "^30.0.0-alpha.1", "jest-mock": "^30.0.0-alpha.1", "jest-snapshot": "^30.0.0-alpha.1", - "piscina": "^3.1.0", - "supports-color": "^9.2.1" + "supports-color": "^9.2.1", + "tinypool": "^0.8.1" }, "devDependencies": { "prettier": "^2.6.2" diff --git a/src/index.js b/src/index.js index 909d42c..e68458b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import { Piscina } from "piscina"; +import Tinypool from "tinypool"; import supportsColor from "supports-color"; import { MessageChannel } from "worker_threads"; @@ -7,7 +7,7 @@ import { MessageChannel } from "worker_threads"; export default class LightRunner { // TODO: Use real private fields when we drop support for Node.js v12 _config; - _piscina; + _pool; constructor(config) { this._config = config; @@ -24,7 +24,7 @@ export default class LightRunner { const { maxWorkers } = config; const runInBand = maxWorkers === 1; - this._piscina = new (runInBand ? InBandPiscina : Piscina)({ + this._pool = new (runInBand ? InBandTinypool : Tinypool)({ filename: new URL("./worker-runner.js", import.meta.url).href, maxThreads: maxWorkers, env: { @@ -52,7 +52,7 @@ export default class LightRunner { mc.port2.onmessage = () => onStart(test); mc.port2.unref(); - return this._piscina + return this._pool .run( { test, updateSnapshot, testNamePattern, port: mc.port1 }, { transferList: [mc.port1] } @@ -66,9 +66,9 @@ export default class LightRunner { } } -// Exposes an API similar to Piscina, but it uses dynamic import() +// Exposes an API similar to Tinypool, but it uses dynamic import() // rather than worker_threads. -class InBandPiscina { +class InBandTinypool { _moduleP; _moduleDefault; diff --git a/src/worker-runner.js b/src/worker-runner.js index 6bd90fe..1fddac3 100644 --- a/src/worker-runner.js +++ b/src/worker-runner.js @@ -4,7 +4,7 @@ import { performance } from "perf_hooks"; import * as snapshot from "jest-snapshot"; import { jestExpect as expect } from "@jest/expect"; import * as circus from "jest-circus"; -import { isWorkerThread } from "piscina"; +import Tinypool from "tinypool"; /** @typedef {{ failures: number, passes: number, pending: number, start: number, end: number }} Stats */ /** @typedef {{ ancestors: string[], title: string, duration: number, errors: Error[], skipped: boolean }} InternalTestResult */ @@ -14,7 +14,7 @@ const initialSetup = once(async projectConfig => { // process.chdir, that we use multiple times in our tests. // We can "polyfill" it for process.cwd() usage, but it // won't affect path.* and fs.* functions. - if (isWorkerThread) { + if (Tinypool.isWorkerThread) { const startCwd = process.cwd(); let cwd = startCwd; process.cwd = () => cwd; diff --git a/yarn.lock b/yarn.lock index 0effc27..577f78f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14,13 +14,6 @@ __metadata: languageName: node linkType: hard -"@assemblyscript/loader@npm:^0.10.1": - version: 0.10.1 - resolution: "@assemblyscript/loader@npm:0.10.1" - checksum: 62f3a070052f578c28bdb860b046c6a079f03755fd5b1c97cc4dd17869c1f292fd50cbafc5fb804073d71ba6b6a50b8bce976724d8a0ce402ffe8957e9a5b9ec - languageName: node - linkType: hard - "@babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.16.7": version: 7.16.7 resolution: "@babel/code-frame@npm:7.16.7" @@ -887,13 +880,6 @@ __metadata: languageName: node linkType: hard -"base64-js@npm:^1.2.0": - version: 1.5.1 - resolution: "base64-js@npm:1.5.1" - checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 - languageName: node - linkType: hard - "big-integer@npm:^1.6.44": version: 1.6.51 resolution: "big-integer@npm:1.6.51" @@ -1303,13 +1289,6 @@ __metadata: languageName: node linkType: hard -"eventemitter-asyncresource@npm:^1.0.0": - version: 1.0.0 - resolution: "eventemitter-asyncresource@npm:1.0.0" - checksum: 3cfbbc3490bd429a165bff6336289ff810f7df214796f25000d2097a5a0883eae51542a78674916ff99bbd4c66811911b310df1cb4fc96dfc9546ba9dfc89f8f - languageName: node - linkType: hard - "execa@npm:^5.0.0": version: 5.1.1 resolution: "execa@npm:5.1.1" @@ -1560,24 +1539,6 @@ __metadata: languageName: node linkType: hard -"hdr-histogram-js@npm:^2.0.1": - version: 2.0.3 - resolution: "hdr-histogram-js@npm:2.0.3" - dependencies: - "@assemblyscript/loader": "npm:^0.10.1" - base64-js: "npm:^1.2.0" - pako: "npm:^1.0.3" - checksum: c88970b2df733daad3eb30adfbe44517dc03bb816c49ed3e85d03dc40df38a0a25109a20d0620baf968048ae57720dac3958c35081a056f264f33c22368690d3 - languageName: node - linkType: hard - -"hdr-histogram-percentiles-obj@npm:^3.0.0": - version: 3.0.0 - resolution: "hdr-histogram-percentiles-obj@npm:3.0.0" - checksum: 8fb15ab608997faf7716b641c032c538320f2479aee99af89d40aa5b9215f15b879d096e32745b552f7c50081acced7182bf58133d53dc61230aede5ac255d53 - languageName: node - linkType: hard - "http-cache-semantics@npm:^4.1.0": version: 4.1.0 resolution: "http-cache-semantics@npm:4.1.0" @@ -1907,9 +1868,9 @@ __metadata: jest-each: "npm:^30.0.0-alpha.1" jest-mock: "npm:^30.0.0-alpha.1" jest-snapshot: "npm:^30.0.0-alpha.1" - piscina: "npm:^3.1.0" prettier: "npm:^2.6.2" supports-color: "npm:^9.2.1" + tinypool: "npm:^0.8.1" peerDependencies: jest: ^27.5.0 || ^28.0.0 || ^29.0.0|| ^30.0.0-0 languageName: unknown @@ -2346,37 +2307,6 @@ __metadata: languageName: node linkType: hard -"nice-napi@npm:^1.0.2": - version: 1.0.2 - resolution: "nice-napi@npm:1.0.2" - dependencies: - node-addon-api: "npm:^3.0.0" - node-gyp: "npm:latest" - node-gyp-build: "npm:^4.2.2" - conditions: "!os=win32" - languageName: node - linkType: hard - -"node-addon-api@npm:^3.0.0": - version: 3.2.1 - resolution: "node-addon-api@npm:3.2.1" - dependencies: - node-gyp: "npm:latest" - checksum: 681b52dfa3e15b0a8e5cf283cc0d8cd5fd2a57c559ae670fcfd20544cbb32f75de7648674110defcd17ab2c76ebef630aa7d2d2f930bc7a8cc439b20fe233518 - languageName: node - linkType: hard - -"node-gyp-build@npm:^4.2.2": - version: 4.3.0 - resolution: "node-gyp-build@npm:4.3.0" - bin: - node-gyp-build: bin.js - node-gyp-build-optional: optional.js - node-gyp-build-test: build-test.js - checksum: 673bd8f12694cc226747333fc181a7288e32dc96e88067bccb9ae3969ed1459fe461f85ad76d0ec8566ec1ae75c179e7a6667b0094cc78c9431ecfc95b5c24aa - languageName: node - linkType: hard - "node-gyp@npm:latest": version: 9.0.0 resolution: "node-gyp@npm:9.0.0" @@ -2541,13 +2471,6 @@ __metadata: languageName: node linkType: hard -"pako@npm:^1.0.3": - version: 1.0.11 - resolution: "pako@npm:1.0.11" - checksum: 1ad07210e894472685564c4d39a08717e84c2a68a70d3c1d9e657d32394ef1670e22972a433cbfe48976cb98b154ba06855dcd3fcfba77f60f1777634bec48c0 - languageName: node - linkType: hard - "path-exists@npm:^4.0.0": version: 4.0.0 resolution: "path-exists@npm:4.0.0" @@ -2604,21 +2527,6 @@ __metadata: languageName: node linkType: hard -"piscina@npm:^3.1.0": - version: 3.2.0 - resolution: "piscina@npm:3.2.0" - dependencies: - eventemitter-asyncresource: "npm:^1.0.0" - hdr-histogram-js: "npm:^2.0.1" - hdr-histogram-percentiles-obj: "npm:^3.0.0" - nice-napi: "npm:^1.0.2" - dependenciesMeta: - nice-napi: - optional: true - checksum: 46838c513c2f6bef2c838d25a0b4da7760805a111dc70333aecfa30165c4eb693989d6f481150819c1377f029a22d70df4066c8d071d832745dc00458386dfce - languageName: node - linkType: hard - "prettier@npm:^2.6.2": version: 2.6.2 resolution: "prettier@npm:2.6.2" @@ -3035,6 +2943,13 @@ __metadata: languageName: node linkType: hard +"tinypool@npm:^0.8.1": + version: 0.8.1 + resolution: "tinypool@npm:0.8.1" + checksum: 3fae8acc22b7d0364eb202b64f61f0d8b10dcead6bef9b8fab1836857dcecd0e34fadc47ab309754ead2cb29bfa4b3467a9fc0daae23669b19ff403ae1364b5c + languageName: node + linkType: hard + "titleize@npm:^3.0.0": version: 3.0.0 resolution: "titleize@npm:3.0.0"