curiosity-ai / h5

🚀 The next generation C# to JavaScript compiler
https://github.com/curiosity-ai/h5
Apache License 2.0
226 stars 31 forks source link

Check if we can invert the order of metadata loading #58

Open theolivenbaum opened 3 years ago

theolivenbaum commented 3 years ago

Currently h5 will emit the metadata file used for reflection after the project file:

<head>
    <script src="h5.js" defer></script>
    <script src="h5.meta.js" defer></script>
    <script src="newtonsoft.json.js" defer></script>
    <script src="app.js" defer></script>
    <script src="app.meta.js" defer></script>    
</head>

But this means if you use reflection on the app entry point:

console.log(JsonConvert.SerializeObject(new MyClass()));

This fails as the metadata file app.meta.js is not yet loaded. Adding a timeout to let the file load works fine.

Need to investigate if we can invert the output order (i.e. load app.meta.js before app.js). On a quick test it works fine.

The fix might be as simple as re-ordering metadata and javascript files here