Coder Social home page Coder Social logo

CJS files are missing in 1.2.0 about analytics HOT 10 OPEN

Mause avatar Mause commented on May 17, 2024 1
CJS files are missing in 1.2.0

from analytics.

Comments (10)

Mause avatar Mause commented on May 17, 2024 1

Looks good now, thanks for the quick fix!

from analytics.

SferaDev avatar SferaDev commented on May 17, 2024 1

Sure:

    "jest": "^29.7.0",
    "@vercel/analytics": "^1.2.1",
    "@types/jest": "^29.5.12",
    "@types/react": "^18.2.56",
    "react": "^18.2.0",
    "next": "^14.1.0",
    "@swc/core": "^1.4.2",
    "@swc/jest": "^0.2.36",

Error:

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Using @swc/jest as transform for ESM support.

Was working fine in 1.2.0 (and versions prior to that), tests stopped passing with automated workflow to update to 1.2.1

from analytics.

SferaDev avatar SferaDev commented on May 17, 2024 1

Hey @feugy, sure! Steps to repro in #134

# Install deps ignoring pnpm workspace and install ts-node to run `jest.config.ts`
pnpm --ignore-workspace install -D ts-node
pnpm test
# Tests will fail
pnpm --ignore-workspace install @vercel/[email protected]
pnpm test
# Tests will pass

from analytics.

feugy avatar feugy commented on May 17, 2024

Thanks for the bug report. I've published version 1.2.1

Would you mind trying it @Mause? :ty-green:

from analytics.

feugy avatar feugy commented on May 17, 2024

For posterity, would you mind telling me how to reproduce the error?
Including node/next versions, and whether you're using turbo.

Thanks a million.

from analytics.

SferaDev avatar SferaDev commented on May 17, 2024

Just updated to 1.2.1 and it seems that jest didn't like this change. Haven't checked out yet but felt as giving a warning here 😉

from analytics.

feugy avatar feugy commented on May 17, 2024

Thank you @SferaDev. Can you tell us more about your setup, including versions? :ty-green:

from analytics.

feugy avatar feugy commented on May 17, 2024

Thank you @SferaDev. I've enhanced our Next.js app and added tests, trying to reproduce this.
But no luck (jest/swc have no issue parsing files). Would you mind checking #134 and telling me how to reproduce it?

from analytics.

feugy avatar feugy commented on May 17, 2024

Thanks for the help @SferaDev.

I could reproduce and fix it, by exporting CJS code when running on Node. however it's a bit unfair, since the docs says that we could either use CJS or ESM. I guess it's a nasty combination of jest, ts-node and node.

I'm waiting for an approver, and I'll release this.

from analytics.

feugy avatar feugy commented on May 17, 2024

I've released 1.2.2, please try and let me know

from analytics.

Related Issues (20)

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.