iansan5653/unraw

npm package distribution - source maps errors with webpack@5 and CRA

char0n opened this issue ยท 15 comments

Hello all,

I've noticed that npm distribution package is causing errors with CRA@5 (Create React App).

WARNING in ./node_modules/unraw/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/char0n/Documents/GitHub/test/node_modules/unraw/src/index.ts' file: Error: ENOENT: no such file or directory, open '/home/char0n/Documents/GitHub/test/node_modules/unraw/src/index.ts'
 @ ./node_modules/@swagger-api/apidom-ast/es/yaml/schemas/canonical-format.js 6:0-26 105:146-151
 @ ./node_modules/@swagger-api/apidom-ast/es/yaml/schemas/ScalarTag.js 2:0-140 16:24-39 19:24-46 22:24-46 25:24-42 28:24-41
 @ ./node_modules/@swagger-api/apidom-ast/es/yaml/schemas/failsafe/index.js 9:0-37 89:24-33
 @ ./node_modules/@swagger-api/apidom-ast/es/index.js 32:0-72 32:0-72
 @ ./node_modules/@swagger-api/apidom-core/es/traversal/visitor.js 11:0-85 13:0-35 13:0-35 88:9-17 112:45-53
 @ ./node_modules/@swagger-api/apidom-core/es/index.js 17:0-107 17:0-107 17:0-107 17:0-107 17:0-107 17:0-107
 @ ./node_modules/@swagger-api/apidom-ls/es/index.js 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199 1:0-199
 @ ./src/plugins/monaco/components/EditorPane.jsx 8:0-51 41:12-21
 @ ./src/plugins/monaco/index.js 3:0-49 8:6-16 11:6-16
 @ ./src/components/IdePreset.jsx 7:0-51 13:33-51
 @ ./src/App.jsx 5:0-41 9:11-14
 @ ./src/index.jsx 6:0-24 9:38-41

I'm not really sure what's happening there. If needed I could create a repo that reproduce the issue.

Thanks for the report! I'll try and look into this after this weekend.

@iansan5653 thanks, appreciate it. Just ping me for more info or Steps to Reproduce.

Hi, sorry for the long wait. I think I just need to remove the sourcemaps from the public distribution. Could you try deleting all the *.map.* files in your project's node_modules/unraw/dist folder? The changes will be overwritten next time you run npm install but if it fixes the problem then I'll publish a new version without the map files.

IMHO deleting the *.map.* will not help. The comments like this //# sourceMappingURL=index.d.ts.map need to be removed from the files as well.

Hmm, I see. Another option is to package the source TS files as well, which would increase the package size but might improve the development experience. I'll have to play with it a little more and see what works.

@iansan5653 this might probably help with the direction: microsoft/vscode-languageserver-node#879

That does look helpful, thank you!

Hi, it's been a while since the last reply but I'd like to suggest editing the tsconfig file with "sourceMap" to false since sources are not packaged ?
Not 100% sure it would work because when I tried it in my project, it didn't seem to be able to use my modified sources

k-funk commented

Same issue. swagger-ui-react uses this library under the hood, which is causing these warnings.

char0n commented

@iansan5653 just pinging.

By using your library in Swagger tooling we've managed to increase downloads of this library significantly. But the source map issues is causing a lot of issues for everybody using Swagger tooling.

image

Would you have time to address this? If this library is no longer maintained, please let me know and I'll go for forking this library, as it's the only long term solution.

Thanks for this library and thanks a lot for the answer!

Hey, sorry for the very delayed reply - it's always hard to find time outside of work to focus on personal projects. I am taking a look at this now and will try to resolve this week.

I tried to build a reproduction but was unable to get this warning. I'm just going to try and stop distributing sourcemaps altogether and see how that goes. I won't be able to verify the fix though until someone else here can test it. Stay tuned for a release...

I've just published version 3.0.0, a major version bump because it removes both the sourcemaps and the minified files (I was running into issues publishing the minified files due to bitrot and rather than debug it I decided to just scrap that since it wasn't important). I also made a number of other changes that should make future maintenance easier.

Please try this out and let me know if it resolves your problem. If not, I'll reopen the issue.

char0n commented

Hi @iansan5653,

it's always hard to find time outside of work to focus on personal projects

I understand and completely relate

I've just published version 3.0.0, a major version bump because it removes both the sourcemaps and the minified files (I was running into issues publishing the minified files due to bitrot and rather than debug it I decided to just scrap that since it wasn't important). I also made a number of other changes that should make future maintenance easier.

I can confirm, v3.0.0 no longer emits warnings in webpack@5

Thanks a lot for all your work!

Awesome, thanks for confirming!