sentry-electron
sentry-electron copied to clipboard
Failure to load with webpack 5
Versions + Platform
- [x] SDK version -
@sentry/[email protected] - [x] Electron version -
[email protected] - [x] Platform -
macOS
Description
We are upgrading our build from webpack 4 to the latest webpack 5.73.0. This led to the following build error:
App threw an error during load
TypeError: mod.require is not a function
at dynamicRequire (/Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:12536:16)
at getIntegrations (/Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:10592:70)
at Object.../../node_modules/@sentry/electron/index.js (/Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:10507:59)
at __webpack_require__ (/Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:127246:42)
at /Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:127384:38
at /Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:127887:3
at Object.<anonymous> (/Users/murrayju/dev/popsql/popsql/packages/popsql-desktop/main.dev.js:127890:12)
at Module._compile (internal/modules/cjs/loader.js:1078:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
at Module.load (internal/modules/cjs/loader.js:935:32)
I came across #92, where the comments led me to try changing how we import this package from
import * as Sentry from '@sentry/electron';
to
import * as Sentry from '@sentry/electron/main';
This appears to solve my problem, but my concern is that this does not agree with the documented usage of this package.
I'm hoping that you can either update the documentation if this usage is preferred, or address the underlying issue that prevents the documented method from working with webpack 5.
This detail is already in the docs but probably needs adding to the repository readme.