jco
jco copied to clipboard
Better errors when failing to parse a wit directory
I wanted to try the fancy new feature to generate types from a directory, so I made a directory with two .wit
files and ran node src/jco.js types ./wit-dir -o ./types
, which produced
(jco types) ComponentError: failed to parse package: /code/jco/wit-dir
at generateTypes (file:///code/jco/obj/js-component-bindgen-component.js:3976:11)
at typesComponent (file:///code/jco/src/cmd/transpile.js:45:29)
at async types (file:///code/jco/src/cmd/transpile.js:18:17)
at async file:///code/jco/src/jco.js:186:9
Which is really not a helpful error.
Eventually by looking at the tests folder I was able to figure out that I'm supposed to have a single .wit
file at the top level of wit-dir
and put other files under the deps
folder, but I don't know how I was supposed to figure that out without looking at the tests.
Also, on a related note, when there's a syntax error in the top-level .wit
file it says failed to parse package:/code/jco/wit-dir
rather than naming the file, or giving any information about what the error is.