monads icon indicating copy to clipboard operation
monads copied to clipboard

Source maps linking to non-existing source files

Open MBuchalik opened this issue 1 year ago • 0 comments

When using @sniptt/monads in React, I am getting a warning indicating that source maps are pointing to non-existing files.

Expected behavior

I expected the library to compile without any compiler warnings.

Actual behavior

When compiling, the React compiler (to be more precise: source-maps-loader) prints multiple warnings, all looking similar to the following:

WARNING in ./node_modules/@sniptt/monads/build/result/result.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '[Path to my project]\node_modules\@sniptt\monads\lib\result\result.ts' file: Error: ENOENT: no such file or directory, open '[Path to my project]\node_modules\@sniptt\monads\lib\result\result.ts'

Potential reason

It seems like the source maps are pointing to a "lib" folder that does not exist. For instance, build/result/result.js.map has the following content:

{"version":3,"file":"result.js","sourceRoot":"","sources":["../../lib/result/result.ts"], [...]

Thus, this source map is trying to reference (root)/lib/result/result.ts. However, the lib/ folder does not exist since it is not part of the package; only the build/ folder is currently included in package.json:

https://github.com/sniptt-official/monads/blob/fe0b45709cf3efa0a82b2602c3ef619553fbe21e/package.json#L11-L13

Environment

  • @sniptt/monads: Version 0.5.10
  • Project based on Create-React-App with React 18.2.0.

MBuchalik avatar Oct 17 '22 14:10 MBuchalik