#Testing Compatibility with CJS

9 messages · Page 1 of 1 (latest)

blazing jasper
#

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?

lilac jacinth
#

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

blazing jasper
#

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.

lilac jacinth
#

i didnt try, i dont think e.g. experimental decorator support or emit metadata has any dependency on the 'module type'

queen bramble
#

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

blazing jasper
#

@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.