Tinkoff / micro-sentry

Tiny Sentry client with idiomatic wrapper for Angular
Apache License 2.0
118 stars 8 forks source link

[BUG] - Module not found: Error: Can't resolve '@micro-sentry/core' (webpack 4 & micro-sentry 5-6) #36

Open tmns opened 2 years ago

tmns commented 2 years ago

🐞 Bug report

Description

Hey all, first thanks for the work on this library -- it's an absolute life saver!

I'm currently using the vanilla version (though in a React app), @micro-sentry/browser, and in versions 5 & 6, I get the following error during build (with webpack):

ERROR in ./node_modules/@micro-sentry/browser/fesm2015/micro-sentry-browser.mjs
Module not found: Error: Can't resolve '@micro-sentry/core' in '/home/projects/github-x25w5q/node_modules/@micro-sentry/browser/fesm2015'
 @ ./node_modules/@micro-sentry/browser/fesm2015/micro-sentry-browser.mjs 1:0-65 16:39-56 562:23-31
 @ ./src/index.js

ERROR in chunk main [entry]
main.js
/home/projects/github-x25w5q/src/index.js 848129bca480294ec4fa1da45f08ffd4
Unexpected token (17:39)
|     return window;
| }
| class BrowserMicroSentryClient extends !(function webpackMissingModule() { var e = new Error("Cannot find module '@micro-sentry/core'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()) {
|     constructor(options, window = getWindow()) {
|         super(options);

For some reason it looks like it can't resolve @micro-sentry/core from within that file, even though it's definitely been installed. On my end it looks like there may be a conflict with Webpack 4. When I test it in Webpack 5 it works as expected. Unfortunately though I have to use Webpack 4 IRL.

Luckily, version 4 of micro-sentry works fine; so I can use that, but just wanted to raise it here as eventually it would be nice to be able to use a version that doesn't include tslib too.

Any help would be great!

Reproduction

  1. Open up the following Stackblitz: https://stackblitz.com/edit/github-x25w5q?file=src/index.js
  2. In the terminal run webpack
  3. Observe the error

Expected behavior

To successfully build!

Versions