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

Require.context not working after installing sentry on Next.js project #6961

Closed
dorianw123 opened this issue Jan 27, 2023 · 5 comments · Fixed by #6979
Closed

Require.context not working after installing sentry on Next.js project #6961

dorianw123 opened this issue Jan 27, 2023 · 5 comments · Fixed by #6979
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@dorianw123
Copy link

Environment

SaaS (https://sentry.io/)

Version

No response

Link

No response

DSN

No response

Steps to Reproduce

I've installed sentry on my Next.js project. I'm trying to use require.context like so:

const flagImages = importAll(
  require.context("../../public/images/flags", false, /\.(png|jpe?g|svg)$/)
);

This was working fine before installing sentry, but doesn't work after installing sentry. I assume the reason it no longer works is because sentry changes the webpack configuration.

I tried using import.meta.webpackContext as the ESM alternative to require.context, but this didn't work either - I just get import.meta.webpackContext is undefined.

Expected Result

Should be able to use require.context or import.meta.webpackContext

Actual Result

image

@getsantry
Copy link

getsantry bot commented Jan 27, 2023

Assigning to @getsentry/support for routing, due by Monday, January 30th at 10:47 am (yyz). ⏲️

@getsantry
Copy link

getsantry bot commented Jan 27, 2023

Routing to @getsentry/team-web-sdk-frontend for triage, due by Tuesday, January 31st at 11:07 am (sfo). ⏲️

@AbhiPrasad AbhiPrasad transferred this issue from getsentry/sentry Jan 27, 2023
@lforst
Copy link
Member

lforst commented Jan 30, 2023

Thanks for reporting this. We'll look into it!

@lforst lforst added Package: nextjs Issues related to the Sentry Nextjs SDK and removed Status: Untriaged labels Jan 30, 2023
@joshuajaco
Copy link
Contributor

This can be traced back to the same underlying issue as #6943. rollup-plugin-commonjs trying to convert commonjs to esm

@lforst
Copy link
Member

lforst commented Feb 1, 2023

Hi, we just released an update that should fix this problem. https://github.com/getsentry/sentry-javascript/releases/tag/7.35.0

Let me know if upgrading the SDK fixes this issue for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants