Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Missing sourcemaps or a misconfigured package with Create React App - CRA #293

Closed
ktalley opened this issue Feb 17, 2022 · 9 comments · Fixed by #299
Closed

Missing sourcemaps or a misconfigured package with Create React App - CRA #293

ktalley opened this issue Feb 17, 2022 · 9 comments · Fixed by #299
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ktalley
Copy link

ktalley commented Feb 17, 2022

After updating to the newest version of Create React App I'm getting warnings for missing sourcemap files in this package. See below for the exact warnings, and see this issue for similar warnings.

What are the steps to reproduce this issue?

  1. Update any project using CRA to v5 and include the Honeybadger React library.
    1a. Here's an example repo if you need one to test with
  2. Start the dev server npm run start or build npm run build

What happens?

WARNING in ./node_modules/@honeybadger-io/react/dist/honeybadger-react.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<project>/node_modules/@honeybadger-io/src/DefaultErrorComponent.tsx' file: Error: ENOENT: no such file or directory, open '<project>/node_modules/@honeybadger-io/src/DefaultErrorComponent.tsx'

What were you expecting to happen?

No errors or warnings

What versions are you using?

Operating System: MacOS 10.15.7 / Node 16.3.0
Package Version: 2.0.0
Browser Version: N/A

@joshuap
Copy link
Member

joshuap commented Feb 18, 2022

@ktalley thanks! We'll take a look.

@joshuap joshuap added bug Something isn't working help wanted Extra attention is needed labels Feb 18, 2022
@subzero10
Copy link
Member

Hey @joshuap , I'm currently looking at this and it seems that it's the same issue described here.

Basically, we are generating source maps for files that we do not ship with the package. We only distribute the dist folder, but the source maps point to the source code which is in the src folder. I'm trying to understand the reason we generate these source maps, do you know why?

@joshuap
Copy link
Member

joshuap commented Mar 14, 2022

Hey @joshuap , I'm currently looking at this and it seems that it's the same issue described here.

Basically, we are generating source maps for files that we do not ship with the package. We only distribute the dist folder, but the source maps point to the source code which is in the src folder. I'm trying to understand the reason we generate these source maps, do you know why?

I don't really have a reason besides that it seems useful to point back to the original source, even if it's not included in the NPM package. Occasionally honeybadger.js will appear in a stack trace, and having the source map is handy. I didn't realize the physical source files were required to be in the package? (This is the first I'm hearing of it if so.)

I'm OK with changing this if it's not conventional.

@subzero10
Copy link
Member

Occasionally honeybadger.js will appear in a stack trace, and having the source map is handy.

How does this work though if the source is not available? My guess is that the source map won't have any effect.

I didn't realize the physical source files were required to be in the package?

I don't think they should be required. However we are generating source maps that point to them, which seems useless right?

@joshuap
Copy link
Member

joshuap commented Mar 14, 2022

Occasionally honeybadger.js will appear in a stack trace, and having the source map is handy.

How does this work though if the source is not available? My guess is that the source map won't have any effect.

I didn't realize the physical source files were required to be in the package?

I don't think they should be required. However we are generating source maps that point to them, which seems useless right?

I may be missing something. Do you mean that source maps other than honeybadger.min.js.map and honeybadger.js.map are being generated? In Honeybadger we have the ability to link the source files to GitHub—so they don't necessarily need to exist on disk. But also, doesn't the sourcesContent property in the source map file contain the original source code?

@subzero10
Copy link
Member

Do you mean that source maps other than honeybadger.min.js.map and honeybadger.js.map are being generated?

These are the generated files:
image

In Honeybadger we have the ability to link the source files to GitHub—so they don't necessarily need to exist on disk.

True, but our users link their github repositories, so they still can't link to the source code of Honeybadger, right?

But also, doesn't the sourcesContent property in the source map file contain the original source code?

No, it's null:
image
But this could be another solution we can look into. Here's the suggested way to fix that. I will give this a go and let you know.

@subzero10
Copy link
Member

subzero10 commented Mar 15, 2022

@joshuap Your pointer to sourcesContent and its fix seems to have made the error go away and we can keep source maps generation. PR for review.

@ktalley
Copy link
Author

ktalley commented Mar 17, 2022

Thank you both so much! 🙌 Will 2.0.1 be published to NPM soon?

@joshuap
Copy link
Member

joshuap commented Mar 21, 2022

Thank you both so much! 🙌 Will 2.0.1 be published to NPM soon?

Oops, I thought I had, but looks like the command had failed. It should be up now:

https://www.npmjs.com/package/@honeybadger-io/react/v/2.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants