Closed Nkmol closed 1 year ago
This is, as far as I can see, fixed in the new "support-off-thread-loaders" branch. Where the global identifier is defined by one of the loader hooks: https://github.com/testdouble/quibble/blob/support-off-thread-loaders/lib/quibble.mjs#L129
I was able to confirm that the following minimal implementation fixed this:
export function globalPreload(context) {
return `\
global.__quibble = { stubModuleGeneration: 1 }
`;
}
Hey @giltayar could you remind me of the status of that branch?
I'm waiting on a major change on loader architecture (which moves loaders to a worker thread). Once that lands in Node.js, I will land that branch.
But! Theoretically, I can spend an hour or so making sure that the PR works in the existing Node.js versions (it should) and just push the PR without checking that the fix works when the loader architecture change lands in Node.js.
I think that's the way to go. With your permissions @searls, I'll go ahead and do it (and thus also close this issue)
(Sorry about the delay. It's holiday season in Israel ☺️)
Go for it!
Sent from my Apple Watch
So... I tried creating a PR for that branch and it seems that it doesn't work on Node 14. I mentioned this to the relevant Node developers (https://github.com/nodejs/node/pull/44710#issuecomment-1323213166) but for now it seems I can't land that branch.
@giltayar yeah that seems tricky. What do you think we should do in the meantime for quibble/tdjs?
I can try and fix the above bug. Or maybe get a PR from @Nkmol? ☺️
A very minor bug, but still wanted to document this :)
What happened I am trying to use
quibble
as a standalone pure ESM mock framework, even though this is mainly targeted at TestDoudble. While looking at usage in TD (https://github.com/testdouble/testdouble.js/blob/main/src/replace/index.js#L16), I see the check to see if the loader is actually activated. The function ofisLoaderLoaded
, however, always return true.What I expect When I do not use the quibble loader (
--loader/--experimental-loader quibble
) I expect the function ofisLoaderLoaded()
to returnfalse
.Playground https://stackblitz.com/edit/node-ej1hze?file=index.js&view=editor
It seems that
quibble.mjs
, and thus the global quibble object identifier, is always loaded when importing the package (with and without loaders).