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

Next.js auto wrappers are creating wildcard exports and crashing builds #6085

Closed
dhavalveera opened this issue Oct 28, 2022 · 9 comments · Fixed by #6101
Closed

Next.js auto wrappers are creating wildcard exports and crashing builds #6085

dhavalveera opened this issue Oct 28, 2022 · 9 comments · Fixed by #6101

Comments

@dhavalveera
Copy link

Environment

SaaS (https://sentry.io/)

Version

7.17.1

Steps to Reproduce

sentry.client.config.js & sentry.server.config.js => code:

import * as Sentry from '@sentry/nextjs'

if (process.env.SENTRY_DSN) {
  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    //   enabled: process.env.NODE_ENV !== 'test',
    environment: 'production',
    // release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE, // Uses the environment variable `SENTRY_RELEASE`, which is also attached to the source maps
    //   debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js
    tracesSampleRate: 1.0,
  })
}

next.config.js => Code:

/** @type {import('next').NextConfig} */

const { withSentryConfig } = require('@sentry/nextjs')

const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,

  env: {
    SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
  },

  sentry: {
    // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
    // for client-side builds. (This will be the default starting in
    // `@sentry/nextjs` version 8.0.0.) See
    // https://webpack.js.org/configuration/devtool/ and
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
    // for more information.
    hideSourceMaps: true,
  },
}
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(nextConfig, {
  // Additional config options for the Sentry Webpack plugin. Keep in mind that
  // the following options are set automatically, and overriding them is not
  // recommended:
  //   release, url, org, project, authToken, configFile, stripPrefix,
  //   urlPrefix, include, ignore
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
})

Expected Result

no error should throw if the App is working properly

Actual Result

image

I am getting this error when I am normally running npm run dev. also I've some eslintrc.json

please help me where I'm doing wrong.

@AbhiPrasad AbhiPrasad transferred this issue from getsentry/sentry Oct 28, 2022
@lforst
Copy link
Member

lforst commented Oct 28, 2022

Hi, can you share what your _app.js looks like?

@dhavalveera
Copy link
Author

Hello @lforst, Sure, here is the _app.js code:

import '../styles/globals.css'

// react
import React from 'react'

// Nextjs
import Head from 'next/head'
import Router from 'next/router'

// react-hot-toast
import { Toaster } from 'react-hot-toast'

// NProgress Package & CSS
import NProgress from 'nprogress'
import '../styles/nprogress/nprogress.css'

// react-bootstrap
import 'bootstrap/dist/css/bootstrap.min.css'
import SSRProvider from 'react-bootstrap/SSRProvider'

// Error Boundary Component - to show custom Error Message if App is crashed on Client-Side
// eslint-disable-next-line import/extensions
import ErrorBoundary from '@/components/Error_Boundary'

Router.events.on('routeChangeStart', NProgress.start)
Router.events.on('routeChangeError', NProgress.done)
Router.events.on('routeChangeComplete', NProgress.done)

const MyApp = props => {
  const { Component, pageProps } = props

  return (
    <>
      <Head>
        <title>Title</title>
      </Head>
      <ErrorBoundary>
        <SSRProvider>
          <Component {...pageProps} />

          <Toaster position="top-right" reverseOrder={false} />
        </SSRProvider>
      </ErrorBoundary>
    </>
  )
}

export default MyApp

@tronglongphung
Copy link

I am getting the same error using Windows, macOS works fine

@kb5220
Copy link

kb5220 commented Oct 30, 2022

I am getting the same error at _app.tsx, _document.jsx, _error.tsx, and index.tsx files.
The only export there is in the files is the export default at the bottom.

Using Windows 11 and Node v16.13.1.
Nextjs: 12.2.5
@sentry/nextjs: 7.17.2

@lforst lforst changed the title Sentry is throwing error when using with Nextjs Next.js auto wrappers are creating wildcard exports and crashing builds Oct 31, 2022
@lforst
Copy link
Member

lforst commented Oct 31, 2022

Another example of this being a problem on Windows: #6074 (comment)

@chrisweb
Copy link

chrisweb commented Oct 31, 2022

I'm an windows too and can reproduce the problem by using the regular nextjs example: https://github.com/vercel/next.js/tree/deprecated-main/examples/with-sentry

npx create-next-app --example with-sentry with-sentry-app

which will install these versions of the packages (npm list @sentry):

├── @sentry/nextjs@7.17.3
├── next@13.0.0
├── react-dom@18.2.0
└── react@18.2.0

after that if I run npm run dev I immediatly see the error:

Error:
  x Using `export * from '...'` in a page is disallowed. Please use `export { default } from '...'` instead.
  | Read more: https://nextjs.org/docs/messages/export-all-in-page
   ,----
 2 | export * from './_app.js?__sentry_wrapped__';
   : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   `----

When reverting back to @sentry/nextjs 7.16.0 and the error is no more (same as what is decribed in this ticket: #6074 (comment))

@dhavalveera
Copy link
Author

Another example of this being a problem on Windows: #6074 (comment)

Hello @lforst, I think this is coming from Sentry, can you please help us to resolve the issue so we can seamlessly use Sentry again, in the Production App to catch errors if something is broken in the Production Web App of Nextjs.

@lforst
Copy link
Member

lforst commented Nov 3, 2022

We just released version 7.17.4 of the SDK which should fix this issue via #6101. Feel free to ping us here if there are any more issues!

@MartinGerritsen
Copy link

Confirming that this fixes the issue on Windows build, thank you!

lotorvik added a commit to navikt/send-inn-frontend that referenced this issue Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants