Add pkg/transform: public library for running transforms - #224
Merged
Conversation
Exposes Run(ctx, source, entities, opts) which compiles TS/JS via esbuild,
executes transform_entities() in goja with the same host functions and JS
helpers the production hub registers, and returns entities + captured logs.
Self-contained — no dependency on internal/* — so external consumers can
import it without pulling in CLI internals. The existing mim transform test
command continues to use internal/transform/ unchanged.
Notable details:
- esbuild Transform output has top-level import/export stripped before
handing to goja, since goja treats them as reserved-word syntax errors.
- `import * as dh from "datahub-tslib"` namespace aliases are resolved by
emitting a shim object that binds every host fn + helper as a property.
- Result.Logs/Entities are always non-nil so JSON marshals to `[]` not
`null` for downstream JS consumers.
- ctx cancellation and Options.Timeout both interrupt long-running scripts
via engine.Interrupt
erik-heggenhougen
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exposes Run(ctx, source, entities, opts) which compiles TS/JS via esbuild,
executes transform_entities() in goja with the same host functions and JS
helpers the production hub registers, and returns entities + captured logs.
Self-contained — no dependency on internal/* — so external consumers can
import it without pulling in CLI internals. The existing mim transform test
command continues to use internal/transform/ unchanged.
Notable details:
import * as dh from "datahub-tslib"namespace aliases are resolved by emitting a shim object that binds every host fn + helper as a property.[]notnullfor downstream JS consumers.