uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.03k stars 149 forks source link

Missing Source Map Files for parse5 in hast-util-raw Dependencies #624

Closed nmahser closed 3 months ago

nmahser commented 3 months ago

Description

When building a React project using react-md-editor, webpack emits warnings about missing source map files for the parse5 package, a dependency of hast-util-raw. This occurs despite a successful installation.

Steps to Reproduce

  1. Create a new React project with create-react-app and include react-md-editor as a dependency.
  2. Run the build process -npm run build
  3. Observe the warnings in the console regarding missing source map files for parse5 within the hast-util-raw package.

Environment

Error and Warning messages in the console:

WARNING in ./node_modules/hast-util-from-html/node_modules/parse5/dist/tokenizer/preprocessor.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-from-html/node_modules/parse5/dist/tokenizer/preprocessor.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-from-html/node_modules/parse5/dist/tokenizer/preprocessor.js.map'

WARNING in ./node_modules/hast-util-from-html/node_modules/parse5/dist/tree-adapters/default.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-from-html/node_modules/parse5/dist/tree-adapters/default.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-from-html/node_modules/parse5/dist/tree-adapters/default.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/html.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/token.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/index.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/index.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/galileo-frontend/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.js.map'

WARNING in ./node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.js.map' file: Error: ENOENT: no such file or directory, open '/home/user/project/md-test/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.js.map'

package.json:

{
  "name": "md-test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/lodash": "^4.14.194",
    "@types/node": "^16.18.12",
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@uiw/react-md-editor": "^4.0.4",
    "ag-grid-community": "^30.2.0",
    "ag-grid-react": "^30.2.0",
    "antd": "^5.8.6",
    "downshift": "^7.6.0",
    "highlight.js": "^11.9.0",
    "json-loader": "^0.5.7",
    "match-sorter": "^6.3.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.10.1",
    "react-markdown": "^8.0.7",
    "react-query": "^3.39.3",
    "react-router-dom": "^6.8.1",
    "react-scripts": "5.0.1",
    "remark-gfm": "^3.0.1",
    "typescript": "^4.9.5",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "export REACT_APP_ENVIRONMENT=local-dev && export FAST_REFRESH=false && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "prettier": "prettier --list-different '**/*{.js,.tsx,.ts,json,scss,css}'"
  },
  "jest": {
    "transformIgnorePatterns": [
      "node_modules/(?!@remark-gfm)/"
    ],
    "moduleNameMapper": {
      "react-markdown": "<rootDir>/node_modules/react-markdown/react-markdown.min.js"
    }
  },
  "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"
    ]
  },
  "devDependencies": {
    "prettier": "^2.8.4"
  }
}

Part of package-lock.json:

"node_modules/@uiw/react-md-editor": {
      "version": "4.0.4",
      "resolved": "https://registry.npmjs.org/@uiw/react-md-editor/-/react-md-editor-4.0.4.tgz",
      "integrity": "sha512-JH9nDXXRhJtWPP4yE61VE+9ryFo9tg9v7KMwGfJCnaOOKuLF1MR3l/MNsiJCGkRjUwyto5WrU7kBSq8ODJEtYw==",
      "dependencies": {
        "@babel/runtime": "^7.14.6",
        "@uiw/react-markdown-preview": "^5.0.6",
        "rehype": "~13.0.0",
        "rehype-prism-plus": "~2.0.0"
      },
      "funding": {
        "url": "https://jaywcjlove.github.io/#/sponsor"
      },
      "peerDependencies": {
        "react": ">=16.8.0",
        "react-dom": ">=16.8.0"
      }
    },
jaywcjlove commented 3 months ago

@nmahser If you are webpack, you can add this configuration.

https://github.com/uiwjs/react-md-editor/blob/55a55a158683d92605e4e253f75ff1328ca722a5/www/.kktrc.ts#L14-L18

jaywcjlove commented 3 months ago

@nmahser

You can remove the warning by adding GENERATE_SOURCEMAP=false to your .env file

Actually, CRA with Webpack 5.x cause it. They are working on resolving (https://github.com/facebook/create-react-app/pull/11752)

jaywcjlove commented 3 months ago
 "scripts": {
    "start": "GENERATE_SOURCEMAP=false && react-scripts start",
nmahser commented 3 months ago

Thanks!