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

Sourcemap warning with webpack 5 #316

Closed
jsmolina opened this issue May 4, 2022 · 4 comments · Fixed by #321
Closed

Sourcemap warning with webpack 5 #316

jsmolina opened this issue May 4, 2022 · 4 comments · Fixed by #321

Comments

@jsmolina
Copy link

jsmolina commented May 4, 2022

hi,

I'm getting this warning:

WARNING in ./node_modules/react-csv-downloader/dist/esm/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

it's only happening on react-csv-downloader, so I guess it has some relation

@myeongwooni
Copy link

@jsmolina Hello! Did you figure out about it?
It happens to me too. ;(

@jonenst
Copy link

jonenst commented Aug 23, 2022

Hi @dolezel, this happens for all users of this library with the new Create React App 5 (webpack 5). It's also very troubling as the warning is prominently displayed in the npm start output. To reproduce, just create a new CRA project npx create-react-app foo, npm install react-csv-downloader and add import CsvDownloader from 'react-csv-downloader'; in app.js

Capture d’écran de 2022-08-23 12-07-23

This warning reflects a real problem with the published package: this package is publishing sourcemaps but not publishing source
https://unpkg.com/browse/[email protected]/dist/esm/index.js line71
//# sourceMappingURL=index.js.map
https://unpkg.com/browse/[email protected]/dist/esm/index.js.map
"sourceRoot":"","sources":["../../src/index.tsx"],
but there is no src folder in the tarball so we get warnings.

From what I understand (not an npm publishing best practice expert), it should either not publish sourcemaps:

$ git diff tsconfig.json
diff --git a/tsconfig.json b/tsconfig.json
index c50f051..6f2cdd9 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,7 +6,7 @@
     "lib": ["es2017", "dom"],
     "moduleResolution": "node",
     "allowJs": false,
-    "sourceMap": true,
+    "sourceMap": false,
     "jsx": "react",
     "declaration": true,
     "forceConsistentCasingInFileNames": true,

this results in not having the sourceMappingUrl comment in the js files in dist/, and not having the map files in the dist folder.

or publish the source files:

diff --git a/.npmignore b/.npmignore
index 03b4c1b..ac3857f 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,5 +1,4 @@
 .*
 mocha*
 node_modules/
-src/
 example/

Here's the output of npm pack for the different possibilities:
current:

npm notice package size:  12.7 kB                                 
npm notice unpacked size: 92.9 kB                                 
npm notice total files:   25                                      

no maps:

npm notice package size:  9.3 kB                                  
npm notice unpacked size: 59.3 kB                                 
npm notice total files:   19                                      

maps and sources:

npm notice package size:  15.4 kB                                 
npm notice unpacked size: 108.7 kB                                
npm notice total files:   28                                      

Given the low byte size of all the packages, maybe the best is to publish source files ? This would allow to have a readonly debugging experience with browser devtools or vscode when stepping into this library code and setting breakpoints.

here are similar issues in other projects:
googleapis/google-cloud-node#2867
facebook/create-react-app#11767 (comment)
facebook/create-react-app#11752
...probably many more..

Cheers,
Jon

@dolezel dolezel mentioned this issue Nov 18, 2022
@dolezel
Copy link
Owner

dolezel commented Nov 18, 2022

Completed in #321

@dolezel dolezel closed this as completed Nov 18, 2022
@jonenst
Copy link

jonenst commented Nov 21, 2022

Thanks for shipping this in 2.9.0, no more warnings for me !

jonenst added a commit to gridsuite/gridexplore-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridexplore-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/commons-ui that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridapp-template that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/griddyna-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridmerge-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridstudy-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/commons-ui that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridapp-template that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/griddyna-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridmerge-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridstudy-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
jonenst added a commit to gridsuite/gridexplore-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
thangqp pushed a commit to gridsuite/griddyna-app that referenced this issue Nov 21, 2022
Failed to parse source map from 'node_modules/react-csv-downloader/src/index.tsx' file: Error: ENOENT: no such file or directory, open 'node_modules/react-csv-downloader/src/index.tsx'

dolezel/react-csv-downloader#316
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 a pull request may close this issue.

4 participants