Giter VIP home page Giter VIP logo

Comments (10)

piranna avatar piranna commented on July 1, 2024

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.

exarus avatar exarus commented on July 1, 2024

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.

yaakovfeldman avatar yaakovfeldman commented on July 1, 2024

Unfortunately, switching jest between node and jsdom did not change anything.

from jest-node-exports-resolver.

piranna avatar piranna commented on July 1, 2024
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.

exarus avatar exarus commented on July 1, 2024

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.

piranna avatar piranna commented on July 1, 2024

We could provide the node condition, but will fail for any other environment that's not Node.js.

from jest-node-exports-resolver.

exarus avatar exarus commented on July 1, 2024

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.

piranna avatar piranna commented on July 1, 2024

I'm open for ideas.

from jest-node-exports-resolver.

Nr9 avatar Nr9 commented on July 1, 2024

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.

prescottprue avatar prescottprue commented on July 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.