Open adius opened 9 years ago
I can confirm the patch of @brettz9 just works, which is great.
Also note that although the package is on npm right now, it does not actually work, it will just return an empty object.
The patch does not work when you want to use json-editor in isomorphic applications as window
is hardcoded everywhere in json-editors source and it is impossible to defer access to window
to a later point after requireing json-editor.
Something like
var jsonEditorGlobalScope;
if(typeof window !== 'undefined') jsonEditorGlobalScope = window; // browser
elseif(typeof global !== 'undefined') jsonEditorGlobalScope = global; // nodejs / iojs / web worker
and make everything else in json-editor operate on jsonEditorGlobalScope
after that can solve this. There are other ways too, for example access window
only after a call to JSONEditor()
.
ATM I'm doing
var JSONEditor;
try {
require('json-editor');
JSONEditor = window.JSONEditor;
} catch(ex) {
}
in components using json-editor.
Thanks for the work around!
Is there any plans on implementing this? It would be nice not to have a customized version in the build process.
It would be cool if json-editor was available as a CommonJS module so that you can require it and use it with browserify.js. Any chance this is going to happen?