luisanton-io / recoil-nexus

MIT License
163 stars 13 forks source link

"SyntaxError: Cannot use import statement outside a module" error when trying to use with nextjs #18

Closed abhinkrishna closed 2 years ago

abhinkrishna commented 2 years ago

I am getting this error when tried to use with Next.js.

image

Is this package compatibility issue or did I miss something?

Thank you

nextjs

javierfernandes commented 2 years ago

I'm also having this same problem when running my Jest tests. I believe it is the fact that the published bundled of this library is an ES module (having imports/exports) instead of a commonjs version (understood by nodejs).

I think that you would need to setup webpack to transform this library through babel or something. I'm trying to do that right now with my jest "transform" config, without much luck :(

luisanton-io commented 2 years ago

@javierfernandes Thanks for the heads up. I just changed module in the tsconfig.json from esnext to commonjs and recompiled.

Now with latest version v0.3.15 you shouldn't need anymore to configure Jest as currently described in the docs: could you please confirm this on your end too...?