gcanti / fp-ts-routing

A type-safe bidirectional routing library for TypeScript

Home Page:https://gcanti.github.io/fp-ts-routing/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: Failed to parse source map

anast-bd opened this issue Β· comments

πŸ› Bug report

Current Behavior

Get warnings when starting application

WARNING in ./node_modules/fp-ts-routing/es6/formatter.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\...\node_modules\fp-ts-routing\src\formatter.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\...\node_modules\fp-ts-routing\src\formatter.ts'

WARNING in ./node_modules/fp-ts-routing/es6/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\...\node_modules\fp-ts-routing\src\index.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\...\node_modules\fp-ts-routing\src\index.ts'

WARNING in ./node_modules/fp-ts-routing/es6/matcher.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\...\node_modules\fp-ts-routing\src\matcher.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\...\node_modules\fp-ts-routing\src\matcher.ts'

WARNING in ./node_modules/fp-ts-routing/es6/parser.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\...\node_modules\fp-ts-routing\src\parser.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\...\node_modules\fp-ts-routing\src\parser.ts'

WARNING in ./node_modules/fp-ts-routing/es6/route.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\...\node_modules\fp-ts-routing\src\route.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\...\node_modules\fp-ts-routing\src\route.ts'

Expected behavior

No warnings are expected

Your environment

Previous version of fp-ts-routing didn't give any warnings

Software Version(s)
fp-ts-routing 0.6.0
TypeScript 5.3.3
react-scripts 5.0.1

hi @anast-bd

I don't know react-scripts and why source-map-loader is triggered, but the warning is right: the source files which the source maps are referring to don't exist in the node_modules folder because they aren't packed when the library is built and published.

Besides the fact that these are warnings and not errors which block the script execution, there are 2 possible solutions:

  1. pack and publish also the source files; other libraries in the wild do this thing, but I feel it is quite dirty;
  2. set inlineSources property in the tsconfig.json to true in order to add the actual source to the source map declaration; I tried in my local environment, but I noticed that the source map still contains a reference to the path of the source file, thus I cannot be sure this will resolve the issue.

In the end, I also noticed that other packages in the fp-ts ecosystem (starting from fp-ts itself, but also io-ts) do not generate and publish source maps at all and I wonder if this would be the right solution, even only by consistency.

cc @gcanti