akita
akita copied to clipboard
Akita 7 fails in jest because we are missing type:module from package.json
Is this a regression?
Yes
Description
The akita package.json does not include "type": "module"
https://unpkg.com/browse/@datorama/[email protected]/package.json
and node will treat "main" field as commonjs if not specified. https://nodejs.org/api/esm.html#esm_enabling
I'm not sure if this is the only thing that needs doing for it to work, but I'm guessing someone else knows :)
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
SyntaxError: Unexpected token 'export'
Please provide the environment you discovered this bug in
jest 27.4.3
akita 7.0.1
Anything else?
No response
Do you want to create a pull request?
No
+1 Same here with
jest 27.4.3 akita 7.0.1
any workarounds? Adding "type": "module"
to node_modules/@datorama/akita/package.json
doesn't help.
I am also getting this.
Diff: https://github.com/tony/cv/commit/bf4d4a1b0a1a31dad15354dba41d3cffdc2ae1ba CI run w/ error: https://github.com/tony/cv/runs/4826668166?check_suite_focus=true
@NetanelBasal Any details on this?
https://stackoverflow.com/questions/49263429/jest-gives-an-error-syntaxerror-unexpected-token-export
@NathanAlcantara I appreciate the link! Thank you.
Hm, I still don't have an idea what's going on.
Any idea on what's changed in Akita between 6 and 7 that could be causing this issue?
Regarding the the type: module
in package.json
, what would be the impact on that? (I assume there are structural / build reasons not to do that?)
I'm not sure. I didn't change anything. I think it is something with Jest.
@NetanelBasal if I downgrade Akita to vrs 6.2.0, it works fine with same version of jest.
@NetanelBasal And at https://github.com/datorama/akita/issues/778#issuecomment-1013750863 I have a diff and CI runs shows specifically that updating 6 -> 7
However, that still doesn't preclude the issue being rooted our own project's environmental / config issues rather than akita's build/packaging/etc. It could still be our environment's were / have become incorrect and something underneath the hood, e.g. an inner dependency, brought it to the forefront
We are not doing anything special. We're using Nx to build the package. Is there any issue in Nx regarding what you describe?
Maybe this will help you https://github.com/datorama/akita/issues/781#issuecomment-1018856090
@NetanelBasal I consulted the NX docs and could not find any mentions on how to build multiple module types. Pre nx13 akita had many module systems bundled and referenced in the package.json, now only the ESModule version is bundled. My personal preference would be to try to continue to support multiple module types. Maybe building with @nrwl/angular:package
would support more module types out of the box?