jsonix-schema-compiler icon indicating copy to clipboard operation
jsonix-schema-compiler copied to clipboard

Is there an option to produce JSon instead of javascript module ?

Open hokkos opened this issue 9 years ago • 4 comments

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.

hokkos avatar Mar 11 '15 15:03 hokkos

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?

highsource avatar Mar 17 '15 22:03 highsource

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 .

hokkos avatar Mar 17 '15 23:03 hokkos

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.

highsource avatar Mar 18 '15 08:03 highsource

ok, I will try it, thanks.

hokkos avatar Mar 18 '15 12:03 hokkos