Skip to content

Source maps warning when using Create-React-App@5 #26

Description

@dwjohnston

The reproduction steps are:

  1. Create a new CRA application with react-scripts@5 and typescript
npx create-react-app --template=typescript .
  1. Add react-json-to-table and use it.

  2. Run yarn start and you will get this showing as error:

WARNING in ./node_modules/react-json-to-table/build/lib/components/JsonToTable/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/djohnston/git/repros/json-to-table-issue/node_modules/react-json-to-table/src/components/JsonToTable/index.ts' file: Error: ENOENT: no such file or directory, open '/home/djohnston/git/repros/json-to-table-issue/node_modules/react-json-to-table/src/components/JsonToTable/index.ts'
 @ ./node_modules/react-json-to-table/build/lib/components/index.js 10:20-44
 @ ./src/App.tsx 7:0-50 35:37-48
 @ ./src/index.tsx 7:0-24 11:33-36

WARNING in ./node_modules/react-json-to-table/build/lib/components/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/djohnston/git/repros/json-to-table-issue/node_modules/react-json-to-table/src/components/index.tsx' file: Error: ENOENT: no such file or directory, open '/home/djohnston/git/repros/json-to-table-issue/node_modules/react-json-to-table/src/components/index.tsx'
 @ ./src/App.tsx 7:0-50 35:37-48
 @ ./src/index.tsx 7:0-24 11:33-36

Note that you do not get this warning/error when running yarn build.

I'm using react-json-to-table@0.1.17 - if we look at the package.json:

{
  "name": "react-json-to-table",
  "version": "0.1.7",
  "description": "Convert json to HTML <table>",
  "private": false,
  "main": "build/lib/components/index.js",
  "types": "build/lib/components/index.d.ts",
  "engines": {
    "node": ">=8.0.0"
  },
  ...  
  "files": [
    "build/lib"
  ],

The package.json clearly marks where the package entry point and types are.

I believe the issue is with those source maps.

ie. index.js.map

{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,uBAAqB;AAErB,uCAAuC;AACvC,6CAAqD;AAA7C,oCAAA,OAAO,CAAe"}

I believe that the source map loader is looking at this source map file, and then warning that it can't find "../../../src/components/index.tsx".

Should the source maps be excluded from the artefact?

I think I recommend either:

  • Just leave the sourcemaps out
  • Include the src folder in the package, just so that the sourcemaps work.

(Somebody correct me if I'm wrong, I'm not especially familiar with using/configuring source maps).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions