Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate sourcemaps #35

Closed
wants to merge 1 commit into from
Closed

Conversation

nashbridges
Copy link

@nashbridges nashbridges commented Feb 12, 2024

Somehow generated cjs/mjs bundles contain

//# sourceMappingURL=index.mjs.map

line, whereas the actual sourcemap file is not included.

When using CRA (Webpack), this results in the following warning (see facebook/create-react-app#11752)

WARNING in ./node_modules/antlr4ng/dist/index.mjs
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/nash/projects/my-project/node_modules/antlr4ng/dist/index.mjs.map' file: Error: ENOENT: no such file or directory, open '/Users/nash/projects/my-project/node_modules/antlr4ng/dist/index.mjs.map'

To fix that we have either to make sure the hint line is not there, or actually generate sourcemaps. I think latter is more useful.

Signed-off-by: Andrii Malyshko <[email protected]>
@nashbridges
Copy link
Author

The downside is that the package size will increase. The resulting map is about 900Kb (200Kb zipped), and it is duplicated both for .cjs and .mjs.

@mike-lischke
Copy link
Owner

Including the full maps is not a good idea, sorry. Since you never debug the package in your target project and you don't have the package sources at hand to which the mappings point, it simply makes no sense to include those.

The source map reference line is a left over from the build process, where I generated the maps and excluded them from bundling, but didn't think about that reference line.

So, the best approach is not to generate source maps at all, at least not for packaging.

@nashbridges nashbridges deleted the patch-1 branch February 13, 2024 09:26
@nashbridges
Copy link
Author

The source map reference line is a left over from the build process, where I generated the maps and excluded them from bundling, but didn't think about that reference line.

Ah, I see. So the next release won't have the hint, right?

@mike-lischke
Copy link
Owner

Yep, that's the plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants