jsoneditor
jsoneditor copied to clipboard
Could not load source file "0" in source map of "../node_modules/jsoneditor/dist/jsoneditor.min.js"
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.
How can I reproduce this issue?
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"
}
}
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?
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'
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.
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
@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
Looks like all that has to be done is to change the
main
field in yourpackage.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.
Any updates with this issue, I still have it in the console, with create-react-app project, React v18
No news. Help solving this would be very welcome.
I was able to prevent the warning by importing from index in my typescript project!
import JSONEditor from "jsoneditor/index";
🤔 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.
This is fixed now in v9.10.0
via #1499