Skip to content

Option to build with only platform agnostic serialize/parse exports #1

@okfro

Description

@okfro

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions