Skip to content

Cannot use SDK version > 9.15 with Remix v2 using CJS #16420

Closed
@abhi-fwd

Description

@abhi-fwd

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

9.23.0

Framework Version

2.16.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

I'm trying to upgrade our SDK version because logs require 9.17.0. But I can only upgrade to 9.15 - starting with 9.16.0 I get a build error due to an import in SentryHttpInstrumentation.js.

Steps to Reproduce

This is our remix.config:

module.exports = {
  appDirectory: "app",
  browserBuildDirectory: "public/build",
  publicPath: "/build/",
  serverBuildDirectory: "build",
  serverModuleFormat: "cjs",
  browserNodeBuiltinsPolyfill: {
    modules: {
      process: true,
      crypto: true,
      util: true,
      buffer: true,
      stream: true,
      os: true,
      http: true,
      https: true,
      url: true,
      child_process: true,
      fs: true,
      path: true,
      inspector: true,
      diagnostics_channel: true,
      async_hooks: true,
    },
  },
  serverDependenciesToBundle: [
    "react-dnd",
    "react-dnd-html5-backend",
    "react-dnd-touch-backend",
    "@react-dnd/invariant",
    "dnd-core",
    "@react-dnd/shallowequal",
    "@react-dnd/asap",
    "@sentry/node",        // added to see if this resolves the issue but no joy
  ],
};

Note: we're using CJS because of our major UI library didn't support ESM. It's easier to stick with CJS until we upgrade to react-router v7.

Expected Result

A minor version update should not break a build

Actual Result

✘ [ERROR] No matching export in "node-modules-polyfills:node:diagnostics_channel" for import "subscribe"

    node_modules/@sentry/node/build/esm/integrations/http/SentryHttpInstrumentation.js:1:9:
      1 │ import { subscribe, unsubscribe } from 'node:diagnostics_channel';
        ╵          ~~~~~~~~~


✘ [ERROR] No matching export in "node-modules-polyfills:node:diagnostics_channel" for import "unsubscribe"

    node_modules/@sentry/node/build/esm/integrations/http/SentryHttpInstrumentation.js:1:20:
      1 │ import { subscribe, unsubscribe } from 'node:diagnostics_channel';

I'm no expert on the differences between CJS and ESM builds. So, there's a chance I'm missing a config option to make this work.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions