I am trying to incorporate my snarkyJS package into a nodeJS server which is already configured with some database models and tests. The jest config in the server is set to use common JS, and it uses functionality such as jest.spyOn which doesn't appear to work with ESM. But I can't import my snarkyJS package (built off of the zkapp-cli defaults) into those tests without setting the behavior to use ESM. Is is possible to make these compatible?
#Testing Compatibility with CJS
9 messages · Page 1 of 1 (latest)
yeah, you need a different build target for your snarkyjs project, your project is more likely of type: module, and your tsconfig is set a certain way too
you can try this: https://gist.github.com/jayphelps/51bafb4505558736fdba0aaf8bfe69d3
Interesting! Is it actually possible to build a snarkyjs project into something other than esm? Have you had success with something like this? I thought that some of the features were only compatible with ESM.
i didnt try, i dont think e.g. experimental decorator support or emit metadata has any dependency on the 'module type'
snarkyjs definitely works with cjs, there is a separate build output for that
and this separate output should get automatically picked up in a CJS project
@queen bramble , to be clear I'm talking about packages created with the zkapp-cli. I'm planning on dropping it for now since there's just higher priority things to do before the end of the cohort.