-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I'm trying to build a .NET version of dpack. Translating the existing code into another language would be too much effort to accomplish and maintain, but there are alternatives to this as we can interpret JavaScript using Node as a proxy back and forth between the CLR.
Using https://github.com/JeringTech/Javascript.NodeJS for example, I could write this:
var services = new ServiceCollection();
services.AddNodeJS();
var serviceProvider = services.BuildServiceProvider();
var js = File.ReadAllText(@"..\dpack\node_modules\dpack\dist\index.js");
string result = await StaticNodeJSService.InvokeFromStringAsync<string>(js, "serialize", args: new[] { "{ a: '1' }" });
Which works, but the first problem I run into is the window object is undefined. I assume others will follow.
For this use case, I wouldn't need to do anything else beyond converting a string representation of JSON <-> a string representation of dpack.
Would it be possible to generate a dist that includes exports for only these two methods (and ideally one that pure JS, completely agnostic to the browser or node)?