Skip to content

Automatic sveltekit load instrumentation causes vite bundle errors with duplicate identifier "load" #8854

Description

@fnimick

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

7.64.0

Framework Version

1.22.6

Link to Sentry event

No response

SDK Setup

Sentry.init({
    dsn: "https://7f6570917828021f8dea53dc2b778775@o1098001.ingest.sentry.io/4505744165699584",
    tracesSampleRate: 1
})

Steps to Reproduce

I added the Sentry SDK to a Sveltekit project using the wizard.

My vite config is:

export default defineConfig({
  plugins: [
    sentrySvelteKit({
      sourceMapsUploadOptions: {
        org: "million-marker",
        project: "future",
      },
      debug: true,
    }),
    houdini(),
    sveltekit(),
    Icons({ compiler: "svelte" }),
    svg({
      svgoOptions: {
        plugins: [
          {
            name: "preset-default",
            params: { overrides: { removeViewBox: false } },
          },
          {
            name: "prefixIds",
          },
        ],
      },
    }),
  ],
  ssr: {
    // Prevent crashes in SSR when Felte forms are used. See
    // https://github.com/pablo-abc/felte/issues/201#issuecomment-1381641343
    noExternal: ["felte"],
  },
});

Expected Result

No crash when running in development

Actual Result

Upon starting a dev server, I immediately receive errors due to the automatic load instrumentation. With the plugin debug option enabled:

Wrapping /Users/francis/millionmarker/future/src/routes/+layout.ts with Sentry load wrapper
Wrapping /Users/francis/millionmarker/future/src/routes/(app)/+page.ts with Sentry load wrapper
Internal server error: ENOENT: no such file or directory, open '/src/routes/(app)/+layout.js'
   (x2)
Internal server error: Transform failed with 2 errors:
/Users/francis/millionmarker/future/src/routes/+layout.ts:13:13: ERROR: Multiple exports with the same name "load"
/Users/francis/millionmarker/future/src/routes/+layout.ts:13:13: ERROR: The symbol "load" has already been declared
  Plugin: vite:esbuild
  File: /Users/francis/millionmarker/future/src/routes/+layout.ts:13:13
  
  Multiple exports with the same name "load"
  11 |  }
  12 |  
  13 |  export const load = userModule.load ? wrapLoadWithSentry(userModule.load) : undefined;
     |               ^
  14 |  export * from "/Users/francis/millionmarker/future/src/routes/+layout.ts?sentry-auto-wrap";
  
  The symbol "load" has already been declared
  11 |  }
  12 |  
  13 |  export const load = userModule.load ? wrapLoadWithSentry(userModule.load) : undefined;
     |               ^
  14 |  export * from "/Users/francis/millionmarker/future/src/routes/+layout.ts?sentry-auto-wrap";

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions