Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with node v20.0.0 #513

Closed
3 tasks done
stixx200 opened this issue Apr 21, 2023 · 2 comments
Closed
3 tasks done

Incompatibility with node v20.0.0 #513

stixx200 opened this issue Apr 21, 2023 · 2 comments

Comments

@stixx200
Copy link

stixx200 commented Apr 21, 2023

Description

Issue

I wan't to get testdouble working on Node.js v20.0.0
Node.js v20.0.0 introduces a segregation of loader code and production code
In the changelog, they call it "Loader hooks are executed off the main thread" (https://nodejs.org/api/esm.html#modules-ecmascript-modules)

With this segregation, it is only possible to communicate via a messagePort with the loader. But this only allows to send copied values, no shared objects or modules.

Is there a way to run testdouble.js with Node v20.0.0?

Environment

  • node -v output: v20.0.0
  • npm -v (or yarn --version) output: npm 9.6.4
  • npm ls testdouble (or yarn list testdouble) version: testdouble@3.17.2

Failing Test

Example Repo

// test.js
import * as td from 'testdouble';

await td.replaceEsm('./foo.js', { foo: () => "foomocked" });

const { print } = await import("./other.js");
print();
// other.js
import { foo } from "./foo.js";

export function print() {
    console.log("imported", foo());
}
// foo.js
export const foo = () => "foo.js"
@stixx200
Copy link
Author

Relates to: testdouble/quibble#95

@giltayar
Copy link
Collaborator

giltayar commented May 5, 2023

Note that 20.0.0 will not work, even after quibble is fixed, because it broke loaders. Use 20.1.0 and above.

(PR to quibble to support Node 20 comin' right up!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants