jsoneditor icon indicating copy to clipboard operation
jsoneditor copied to clipboard

Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js"

Open hoogw opened this issue 4 years ago • 8 comments

I got this warning when build, using "jsoneditor": "^9.1.6",

                 Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js"

full code:

                   parcel build --no-minify --no-cache --public-url ./ arcgis/*.html

                 ⚠️  Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js".
                 ⚠️  Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js".
                 ✨  Built in 8.14s.

hoogw avatar Dec 29 '20 16:12 hoogw

How can I reproduce this issue?

josdejong avatar Dec 30 '20 10:12 josdejong

how to reproduce issue:

                          npm init

                          npm install jsoneditor

I use parcel.js to bundle. install parcel.js by:

                          npm install --save-dev parcel-bundler     

create a simple html, js file. in js file, I will import jsoneditor as:

                         // jsoneditor
                            import 'jsoneditor/dist/jsoneditor.css';   // do not forget CSS !
                            import JSONEditor from "jsoneditor";

Then, run:

                 parcel build --no-minify --no-cache --public-url ./    *.html

Then you will see warning

                      Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js".
             ⚠️  Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js".
             ✨  Built in 8.14s.

This is my package.json, you could have yours,

                                                 {
                 "name": "ol2",                          
                 "version": "1.0.0",
                 "description": "",
                 "main": "index.js",
                        "scripts": {
                          "test": "echo \"Error: no test specified\" && exit 1",
                          "start": "parcel arcgis/*.html",
                          "build": "parcel build --no-minify --no-cache --public-url ./ arcgis/*.html"
                        },
                        "author": "",
                        "license": "ISC",
                        "dependencies": {
                          "@mdi/font": "^5.8.55",
                          "jquery": "^3.5.1",
                          "json": "^10.0.0",
                         "jsoneditor": "^9.1.6",
                         "ol": "^6.4.3",
                          "ol-layerswitcher": "^3.8.3",
                          "ol-mapbox-style": "^6.3.0",
                          "proj4": "^2.6.3",
                          "terraformer": "^1.0.12"
                        },
                        "devDependencies": {
                         "parcel-bundler": "^1.12.4"
                        }
                      }

hoogw avatar Dec 31 '20 15:12 hoogw

I managed to reproduce the issue by following your steps and creating:

file issue_1208.html:

<html>
  <head>
    <script src="issue_1208.js"></script>
  </head>
  <body>
    
  </body>
</html>

and file issue_1208.js

// jsoneditor
import 'jsoneditor/dist/jsoneditor.css';   // do not forget CSS !
import JSONEditor from "jsoneditor";

Anyone able to look into why Parcel outputs this warning about the source map?

josdejong avatar Jan 01 '21 13:01 josdejong

It's not just parcel but webpack as well. I am trying to debug an issue and plugging in source-map-loader revealed this

WARNING in ../node_modules/jsoneditor/dist/jsoneditor.min.js
Module Warning (from ../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '[redacted]/client/node_modules/jsoneditor/dist/0' file: Error: ENOENT: no such file or directory, open '[redacted]/client/node_modules/jsoneditor/dist/0'

Nikki1993 avatar Feb 08 '21 13:02 Nikki1993

Thanks for the update @Nikki1993 , that means this is probably not a Parcel specific issue but something generic being wrong with the source map of jsoneditor.

josdejong avatar Feb 08 '21 19:02 josdejong

Same issue here, and I am using webpack, not parcel.

Error is:

WARNING in ../node_modules/jsoneditor/dist/jsoneditor.min.js
Module Warning (from ../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'node_modules\jsoneditor\dist\0' file: Error: ENOENT: no such file or directory, open 'node_modules\jsoneditor\dist\0'
 @ ./src/components/Generic/JsonEditor.tsx 20:0-36 45:33-43
 @ ./src/components/Generic/ObjectTable.tsx 4:0-55 9:28-51
 @ ./src/config/routes.tsx 10:37-80
 @ ./src/App.tsx 4:0-63 19:32-46 20:81-97 21:77-93
 @ ./src/index.tsx 4:0-24 5:27-30

erichiller avatar Jun 17 '21 18:06 erichiller

@josdejong

Looks like all that has to be done is to change the main field in your package.json to ./dist/jsoneditor.js

See my fix

erichiller avatar Jun 26 '21 16:06 erichiller

Looks like all that has to be done is to change the main field in your package.json to ./dist/jsoneditor.js

hm, yeah not using the minified version (with source map) but the non-minified version will indeed work around the issue, though it doesn't really solve the issue of course.

josdejong avatar Jun 30 '21 06:06 josdejong

Any updates with this issue, I still have it in the console, with create-react-app project, React v18

ahmedbecirevic avatar Sep 29 '22 08:09 ahmedbecirevic

No news. Help solving this would be very welcome.

josdejong avatar Sep 29 '22 10:09 josdejong

I was able to prevent the warning by importing from index in my typescript project!

import JSONEditor from "jsoneditor/index";

sreenaths avatar Jan 17 '23 08:01 sreenaths

🤔 that is interesting.

~Thinking aloud here: maybe defining the exports object in package.json will solve this, let me give that a try.~

EDIT: ah, of course: the index.js file is pointing to the non-minified bundle. The issue is in the minified bundle. So, yeah, using "jsoneditor/index" is a workaround for this.

josdejong avatar Jan 17 '23 08:01 josdejong

This is fixed now in v9.10.0 via #1499

josdejong avatar Feb 20 '23 08:02 josdejong