Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hoogw opened this issue Dec 29, 2020 · 13 comments

Comments

@hoogw
Copy link

hoogw commented Dec 29, 2020

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.
@josdejong
Copy link
Owner

How can I reproduce this issue?

@hoogw
Copy link
Author

hoogw commented Dec 31, 2020

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"
                        }
                      }

@josdejong
Copy link
Owner

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?

@Nikki1993
Copy link

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'

@josdejong
Copy link
Owner

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.

@erichiller
Copy link

erichiller commented Jun 17, 2021

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
Copy link

@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

@josdejong
Copy link
Owner

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.

@ahmedbecirevic
Copy link

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

@josdejong
Copy link
Owner

No news. Help solving this would be very welcome.

@sreenaths
Copy link

sreenaths commented Jan 17, 2023

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

import JSONEditor from "jsoneditor/index";

@josdejong
Copy link
Owner

josdejong commented Jan 17, 2023

🤔 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
Copy link
Owner

This is fixed now in v9.10.0 via #1499

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants