Comments (10)
Interesting, https://github.com/yaakovfeldman/jest-issue/blob/939832187ba12d058ffdb347c29643af40786eb7/app.js#L2 is using require()
, so according to https://github.com/firebase/firebase-js-sdk/blob/4bd3a888353c26854142b1861f12e0222151af96/packages/firebase/package.json#L33-L39, it should be getting the CommonJS version, but it's getting the default one, although it's a node.js project... Since you are using Jest at https://github.com/yaakovfeldman/jest-issue/blob/939832187ba12d058ffdb347c29643af40786eb7/package.json#L10 without configuring it, I think it's an issue of Jest itself. It used by default a JsDom environment, but seems now it uses of a Node.js one instead. Can you be able to confirm it? Also, you are using Jest 27.3, can you upgrade it to latest 27.4 version?
from jest-node-exports-resolver.
I'm facing the same issue on latest Jest
27.4.7
, gonna downgrade to 1.1.2
SyntaxError: Unexpected token 'export'
from jest-node-exports-resolver.
Unfortunately, switching jest between node and jsdom did not change anything.
from jest-node-exports-resolver.
node { require: './app/dist/index.cjs.js', import: './app/dist/index.mjs' } [] [ 'require', 'default' ]
default ./app/dist/index.esm.js [] [ 'require', 'default' ]
Ok, for some reason, Jest is not providing the node
condition, so it can't match. I think it's related to jestjs/jest#11924, once it gets merged this should be automatically fixed.
from jest-node-exports-resolver.
So this workaround intended to fix jest issue is blocked by another issue of jest. Hilarious 😂. Let's workaround both these
from jest-node-exports-resolver.
We could provide the node
condition, but will fail for any other environment that's not Node.js.
from jest-node-exports-resolver.
Maybe let's have the temporary option just for node. Maybe name it with nodeResolutionType or something like that. It's much better than support old version or abandon everyone including node
from jest-node-exports-resolver.
I'm open for ideas.
from jest-node-exports-resolver.
I have the same error when I upgrade from 1.1.4 to 1.1.5
/node_modules/@faker-js/faker/dist/esm/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import{eb as a,fb as b,gb as c,hb as d}from"./chunk-KDUTDRUH.js";import"./chunk-7AHD6BL4.js";import"./chunk-JU2V5CFS.js";import"./chunk-3PZV6T5Z.js";d();export{a as Faker,c as default,b as faker};
^^^^^^
SyntaxError: Cannot use import statement outside a module
3 | import { any, mock } from 'jest-mock-extended'
4 | import { z } from 'zod'
> 5 | import { faker } from '@faker-js/faker'
| ^
6 |
at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1728:14)
from jest-node-exports-resolver.
I'm also seeing this when upgrading form 1.1.4 to 1.1.5 when using firebase-admin
from jest-node-exports-resolver.
Related Issues (11)
- Don't require export of `package.json` file HOT 13
- Doesn't Appear to work with Top level node Exports HOT 6
- "setupFiles" and "setupFilesAfterEnv" Jest options do not work properly when using jest-node-exports-resolver HOT 2
- Doesn't seem to work with @firebase/auth
- Doesn't work for older versions of Jest HOT 3
- findMainPackageJson() doesn't work properly on Windows HOT 1
- Get `Cannot find module` error after upgrade to Jest 29.0.0+ HOT 3
- Not working accessing files in scoped packages HOT 3
- Don't work with `exports` as string HOT 1
- Doesn't work with `ws` module HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-node-exports-resolver.