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

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

Closed
char0n opened this issue Jan 7, 2022 · 15 comments · Fixed by lingui/js-lingui#1761
Closed
Assignees
Labels
bug Something isn't working

Comments

@char0n
Copy link

char0n commented Jan 7, 2022

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.

@char0n char0n changed the title npm package distribution - missing source map npm package distribution - source maps errors with webpack@5 and CRA Jan 7, 2022
@iansan5653 iansan5653 added the bug Something isn't working label Jan 7, 2022
@iansan5653 iansan5653 self-assigned this Jan 7, 2022
@iansan5653
Copy link
Owner

iansan5653 commented Jan 7, 2022

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

@char0n
Copy link
Author

char0n commented Jan 8, 2022

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

@iansan5653
Copy link
Owner

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.

@char0n
Copy link
Author

char0n commented Jan 25, 2022

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.

@iansan5653
Copy link
Owner

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.

@char0n
Copy link
Author

char0n commented Jan 27, 2022

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

@iansan5653
Copy link
Owner

That does look helpful, thank you!

@ThaNico
Copy link

ThaNico commented Jun 12, 2023

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
Copy link

k-funk commented Jul 13, 2023

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

@char0n
Copy link
Author

char0n commented Jul 14, 2023

@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!

@iansan5653
Copy link
Owner

iansan5653 commented Jul 25, 2023

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.

@iansan5653
Copy link
Owner

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...

@iansan5653
Copy link
Owner

iansan5653 commented Jul 25, 2023

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
Copy link
Author

char0n commented Jul 26, 2023

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!

char0n added a commit to swagger-api/swagger-editor-cra that referenced this issue Jul 26, 2023
@iansan5653
Copy link
Owner

Awesome, thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants