3.0.0 Webpack "Self-reference dependency has unused export name: This should not happen"
See original GitHub issueHi there! I’m really excited to see the 3.0 release bringing release health metrics, thanks for adding that.
This morning I attempted to migrate to version 3.0 using https://github.com/getsentry/sentry-electron/blob/3.0.0/MIGRATION.md#. It all works in development Webpack builds, but when using Webpack to make a production build mode: 'production'
of my app, I receive the following errors:
ERROR in ./node_modules/@sentry/electron/preload/index.js
Self-reference dependency has unused export name: This should not happen
Error: Self-reference dependency has unused export name: This should not happen
at CommonJsSelfReferenceDependencyTemplate.apply (/Users/vagrant/git/node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js:102:10)
at JavascriptGenerator.sourceDependency (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:206:12)
at JavascriptGenerator.sourceModule (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
at JavascriptGenerator.generate (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
at NormalModule.codeGeneration (/Users/vagrant/git/node_modules/webpack/lib/NormalModule.js:1198:22)
at /Users/vagrant/git/node_modules/webpack/lib/Compilation.js:3324:22
at /Users/vagrant/git/node_modules/webpack/lib/Cache.js:93:5
at Hook.eval [as callAsync] (eval at create (/Users/vagrant/git/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Cache.get (/Users/vagrant/git/node_modules/webpack/lib/Cache.js:75:18)
at ItemCacheFacade.get (/Users/vagrant/git/node_modules/webpack/lib/CacheFacade.js:111:15)
@ ./node_modules/@sentry/electron/main/integrations/preload-injection.js 40:18-59
@ ./node_modules/@sentry/electron/main/integrations/index.js 13:26-56
@ ./node_modules/@sentry/electron/main/index.js 6:33-58
@ ./src/app/crash-reporter/crash-reporter.js 281:85-117
@ ./src/js/index.tsx 15:0-76 31:2-25
ERROR in ./node_modules/@sentry/electron/preload/legacy.js
Self-reference dependency has unused export name: This should not happen
Error: Self-reference dependency has unused export name: This should not happen
at CommonJsSelfReferenceDependencyTemplate.apply (/Users/vagrant/git/node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js:102:10)
at JavascriptGenerator.sourceDependency (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:206:12)
at JavascriptGenerator.sourceModule (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
at JavascriptGenerator.generate (/Users/vagrant/git/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
at NormalModule.codeGeneration (/Users/vagrant/git/node_modules/webpack/lib/NormalModule.js:1198:22)
at /Users/vagrant/git/node_modules/webpack/lib/Compilation.js:3324:22
at /Users/vagrant/git/node_modules/webpack/lib/Cache.js:93:5
at Hook.eval [as callAsync] (eval at create (/Users/vagrant/git/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Cache.get (/Users/vagrant/git/node_modules/webpack/lib/Cache.js:75:18)
at ItemCacheFacade.get (/Users/vagrant/git/node_modules/webpack/lib/CacheFacade.js:111:15)
@ ./node_modules/@sentry/electron/main/integrations/preload-injection.js 39:18-60
@ ./node_modules/@sentry/electron/main/integrations/index.js 13:26-56
@ ./node_modules/@sentry/electron/main/index.js 6:33-58
@ ./src/app/crash-reporter/crash-reporter.js 281:85-117
@ ./src/js/index.tsx 15:0-76 31:2-25
My crash reporter code is mostly unchanged from 2.x implementation (I was using 2.5.4 before). I have a single crash-reporter.js
file that the renderer and main process share. Here is the basic structure of that file:
module.exports.initializeCrashReporter = function () {
Sentry().init({
dsn: '__DSN__',
release: '__VERSION__'
});
};
// This has to be dynamically loaded because it's different between the main and renderer processes
// https://github.com/getsentry/sentry-electron/blob/3.0.0/MIGRATION.md#relative-imports
function Sentry() {
return isRendererProcess()
? require('@sentry/electron/renderer')
: require('@sentry/electron/main');
}
The only change I had to make to migrate to 3.x implementation was within the Sentry
function, changing the require paths. Before, on 2.5.4
, the code was return isRendererProcess() ? require('@sentry/electron/dist/renderer') : require('@sentry/electron/dist/main');
Note that the dist
has been removed from the path for 3.x impl.
Any advice here on how to fix this? I should note that development Webpack builds work completely fine, but changing my webpack config to mode: 'production'
causes the error. I am using Webpack version 5.69.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top GitHub Comments
Thank you, @timfish! This PR fixes the issue: https://github.com/getsentry/sentry-electron/pull/446
Thanks, refactoring the code helps me work around the issue. Appreciate your time!