Skip to content

Named export 'SourceMapSource' not found in bundler-plugin-core dependency (webpack-sources) #209

@wopian

Description

@wopian

Environment

Vite 4 with pure ESM

  • Node 18.15.0
  • Yarn 3.5.0
  • Vite 4.2.1
  • @sentry/vite-plugin 0.7.0

Steps to Reproduce

  1. Install and configure @sentry/vite-plugin in a { "type": "module" } project
  2. Run Vite's build command

Configuration:

createSentryPlugin({
  org: '[redacted]',
  project: '[redacted]',
  include: './dist',
  authToken: environment.VITE_SENTRY_AUTH_TOKEN,
  telemetry: false
}),

Expected Result

Vite compiles the app successfully with Sentry plugin (as 0.6.0 does)

Actual Result

Vite fails to build due to a missing export (or a CommonJS-only export) in a package @sentry/bundler-plugin-core depends on.

failed to load config from /[redacted]/vite.config.ts
error during build:
file:///[redacted]/.yarn/cache/@sentry-bundler-plugin-core-npm-0.7.0-bf4461084c-b32002fac1.zip/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:16
import *** SourceMapSource *** from 'webpack-sources';
         ^^^^^^^^^^^^^^^
SyntaxError: Named export 'SourceMapSource' not found. The requested module 'webpack-sources' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'webpack-sources';
const *** SourceMapSource *** = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Relevant PR that adds the webpack-sources import is #198

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions