codemirror-json-schema
                                
                                 codemirror-json-schema copied to clipboard
                                
                                    codemirror-json-schema copied to clipboard
                            
                            
                            
                        Add ES modules (ESM) support?
Trying to use with ES modules, I get this error
import { Draft07, isJsonError } from "json-schema-library";
         ^^^^^^^
SyntaxError: Named export 'Draft07' not found. The requested module 'json-schema-library' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'json-schema-library';
const { Draft07, isJsonError } = pkg;
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:190:5)
Using the following:
"codemirror-json-schema": "^0.7.0"
"vite": "^5.1.5",
tsconfig compilerOptions:
  "compilerOptions": {
    "lib": ["DOM", "DOM.Iterable", "ES2022"],
    "types": ["vitest/globals"],
    "isolatedModules": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "target": "ES2022",
    "strict": true,
    "allowJs": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./app/*"]
    },
hello, I think you are looking for this issue in our dependency json-schema-library. I reccomend subscribing for the fix. this is the codemirror-json-schema repo so we don't have control over that, but we might end up contributing the fix. I have full time and oss contract obligations in other repos but I hope to get to it in the coming months!
https://github.com/sagold/json-schema-library/issues/51
to note for anyone using next.js, we resolved this using transpileModules which is now built-in to next 13.
afaik, there is not a known workaround for vite/esbuild however, this requires adding full esm support to json-schema-library
hello, I think you are looking for this issue in our dependency
json-schema-library. I reccomend subscribing for the fix. this is thecodemirror-json-schemarepo so we don't have control over that, but we might end up contributing the fix. I have full time and oss contract obligations in other repos but I hope to get to it in the coming months!to note for anyone using next.js, we resolved this using
transpileModuleswhich is now built-in to next 13.afaik, there is not a known workaround for vite/esbuild however, this requires adding full esm support to
json-schema-library
Thanks a lot! I appreciate your work and efforts There's no workaround for esbuild AFAIK unfortunately, but there's on for vite (fix)
our demo build is with vite actually, i forgot how we got around it?? i wonder if we switch back from moduleResolution: bundler to node if that would fix it
I think this can be closed now?
yes i think it is resolved, please let us know if the latest releases do not resolve this and we can re-open
Unfortunately if you're using native ESM, or esbuild, this doesn't work because the underlying json-schema-library doesn't support ESM: https://github.com/sagold/json-schema-library/issues/59