react-file-drop icon indicating copy to clipboard operation
react-file-drop copied to clipboard

Failed to parse source map

Open velislavatwone opened this issue 3 years ago • 8 comments

Using react-scripts 5.0.0 to bundle a JavaScript project and getting the following error:

WARNING in ./node_modules/react-file-drop/FileDrop.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<full path>/node_modules/src/FileDrop.tsx' file: Error: ENOENT: no such file or directory, open '<full path>/node_modules/src/FileDrop.tsx'

Seems like it's caused by these changes https://github.com/sarink/react-file-drop/compare/v3.0.1...v3.0.3

Similar problems have been happening with other packages https://github.com/facebook/create-react-app/discussions/11767

velislavatwone avatar Mar 15 '22 15:03 velislavatwone

Facing a similar issue here. Just a warning though, but this is the only package we use that throws this warning

max-mathieu avatar Apr 20 '22 01:04 max-mathieu

Can you share a test repo that demonstrates this issue? I don't really understand what could be causing it 🤔

sarink avatar Apr 22 '22 02:04 sarink

I'm seeing the same issue as well. Using version "3.1.3".

wznuk avatar May 12 '22 16:05 wznuk

We are also seeing this same issue, version 3.1.5

jay-herrera avatar Jun 01 '22 16:06 jay-herrera

``Yeah... I have the same problem: Failed to parse source map from '/home/andrehen/development/react-file-tree-visualizer/node_modules/src/FileDrop.tsx' file: Error: ENOENT: no such file or directory, open '/home/andrehen/development/react-file-tree-visualizer/node_modules/src/FileDrop.tsx'

It's trying to locate the file in a directory that really doesn't exist inside node_modules: /node_modules/src/FileDrop.tsx

Here is my package.json for versions, it's really a fresh project:

{
  "name": "react-file-tree-visualizer",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.9.0",
    "@emotion/styled": "^11.8.1",
    "@mui/icons-material": "^5.8.3",
    "@mui/lab": "^5.0.0-alpha.85",
    "@mui/material": "^5.8.3",
    "@mui/x-data-grid": "^5.12.2",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-file-drop": "^3.1.5",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

andrehen avatar Jun 20 '22 03:06 andrehen

I have exactly the same issue. The sourcemap FileDrop.js.map contains a reference to a source file that is not in the npm package:

"sources":["../src/FileDrop.tsx"]

josdejong avatar Jul 07 '22 13:07 josdejong

I had the same issue in an other project of mine where I use rollup to generate a bundle. To solve the issue there I had to set sourceMap and inlineSources to true in the configuration options for the typescript plugin:

// rollup.config.js
// ...
export default {
  // ...
  output: [
    {
      // ...
      sourcemap: true
    }
  ],
  plugins: [
    // ...
    typescript({ sourceMap: true, inlineSources: true }),
    // ...
  ]
}

This project has a different setup but maybe it gives a clue on how to fix the sourcemap

josdejong avatar Jul 07 '22 13:07 josdejong

Does anyone have an example repo?

sarink avatar Jul 15 '22 04:07 sarink

@sarink here is a repo you can review: https://github.com/bcepuran/react-file-drop-map-error

if you npm install and npm start you should see the warning in the terminal window.

bcepuran avatar Sep 22 '22 18:09 bcepuran

I also submitted a PR that I think will address the issue by turning off the creation of the source map

bcepuran avatar Sep 22 '22 19:09 bcepuran

Fixed by #96

sarink avatar Sep 28 '22 04:09 sarink