jsonix-schema-compiler
jsonix-schema-compiler copied to clipboard
Is there an option to produce JSon instead of javascript module ?
Hi, the jsonix-schema-compiler produce javascript module, would it be possible to generate simply json so we can load the mappings dynamically in a simpler way ? Thanks.
Hi,
not at the moment. I was thinking adding an option to produce different module styles - CJS, AMD, "pure" globals. This might be placed there.
Why do you need "simply JSON"? I thought modules are a way to go. You could load dynamically with SystemJS for instance. Could you tell me a bit more about your use case?
My use case is the web application doesn't know what mapping it will have to load, so I don't require() the generated modules, for now I use eval() but maybe there is a better way .
I'll add the feature to produce different module formats and syntaxes in one of the next versions.
As for your use case, I'd really advise to use SystemJS. SystemJS can load modules dynamically in the runtime and works with AMD and CJS modules. So it should work with Jsonix. I think this is a better way than making all the modules JSON. When you're loading mappings on your own as JSON you're basically reinventing this.
Nevertheless I was going to allow module formats to be configurable anyway, supporting pur JSON as a format is no big deal.
ok, I will try it, thanks.