Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJS files are missing in 1.2.0 #132

Closed
Mause opened this issue Feb 19, 2024 · 10 comments · Fixed by #133
Closed

CJS files are missing in 1.2.0 #132

Mause opened this issue Feb 19, 2024 · 10 comments · Fixed by #133
Labels
bug Something isn't working

Comments

@Mause
Copy link

Mause commented Feb 19, 2024

It's unclear if this was an intentional change?

You can see the files being missing here: https://app.renovatebot.com/package-diff?name=@vercel%2fanalytics&from=1.1.3&to=1.2.0

They are still referenced in the package.json file as well:

[WebServer] Error: Cannot find module '.../node_modules/@vercel/analytics/dist/react/index.cjs'
@feugy feugy added the bug Something isn't working label Feb 19, 2024
@feugy
Copy link
Member

feugy commented Feb 19, 2024

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

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

@feugy feugy reopened this Feb 19, 2024
@Mause
Copy link
Author

Mause commented Feb 19, 2024

Looks good now, thanks for the quick fix!

@Mause Mause closed this as completed Feb 19, 2024
@feugy
Copy link
Member

feugy commented Feb 19, 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.

@SferaDev
Copy link

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 😉

@feugy
Copy link
Member

feugy commented Feb 19, 2024

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

@SferaDev
Copy link

SferaDev commented Feb 19, 2024

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

@feugy feugy reopened this Feb 19, 2024
@feugy
Copy link
Member

feugy commented Feb 19, 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?

@SferaDev
Copy link

SferaDev commented Feb 20, 2024

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/analytics@1.2.0
pnpm test
# Tests will pass

@feugy
Copy link
Member

feugy commented Feb 20, 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.

@feugy
Copy link
Member

feugy commented Feb 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants