Skip to content

need for runtime dependency is breaking the build #18215

@tcurdt

Description

@tcurdt

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

10.25.0

Framework Version

10.25.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

The current docs suggest to import @sentry/sveltekit as runtime dep. That's pretty bad as is pulls in deps that are really (or at least should) only be needed during build time. To make this possible I tried to split the imports.

For node (hooks.server.ts) I can use

import * as Sentry from '@sentry/node';

    Sentry.init({
      dsn: config.sentry.dsn,
      tracesSampleRate: 0
    });

but for the browser (hooks.client.ts) I still need

import * as Sentry from '@sentry/sveltekit';

  Sentry.init({
    dsn: env.PUBLIC_SENTRY_DSN,
    tracesSampleRate: 0,
  })

and with a package.json like this

  "devDependencies": {
    "@sentry/sveltekit": "^10.25.0"
    ...
  },
  
  "dependencies": {
    "@sentry/node": "^10.25.0",
    ...
  },

and vite.config.ts like this

export default defineConfig(({ mode }) => {
  return {
    ssr: {
      external: ['fsevents', '@sentry/sveltekit']
    },

It should work. But it does not.

Steps to Reproduce

See above

Expected Result

There is vite plugin that needs to be available as devDependency.
There is a runtime component that needs to be available as dependency.

The Sentry SDK should clearly separate dev and runtime deps.
The vite plugin should not be needed as dependency.

Actual Result

Right now dev tooling is needed during runtime - which makes the build bigger and is clearly wrong.

Separating the two as documented in this issue currently gives a build error.

error during build:
RollupError: node_modules/.pnpm/[email protected]/node_modules/fsevents/fsevents.node (1:0): Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
    at getRollupError (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
    at ParseError.initialise (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:14454:28)
    at convertNode (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:16337:10)
    at convertProgram (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:15577:12)
    at Module.setSource (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:17332:24)
    at async ModuleLoader.addModuleSource (file:///sk/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21352:13)
 ELIFECYCLE  Command failed with exit code 1.

Additional Context

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions