Skip to content

Commit

Permalink
Merge pull request #75 from gadget-inc/eval-sourcefile-name
Browse files Browse the repository at this point in the history
Add a sourceURL to eval'd code so sourcemap aware things pick up the dynamic function name
  • Loading branch information
airhorns authored Nov 16, 2023
2 parents 85e18e7 + 9f9b15c commit c0a0cda
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/fast-instantiator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ class InstantiatorBuilder<T extends IClassModelType<Record<string, IAnyType>, an
// build a function that closes over a bunch of aliased expressions
// evaluate the inner function source code in this closure to return the function
// eslint-disable-next-line @typescript-eslint/no-implied-eval
const aliasFunc = new Function("model", "imports", aliasFuncBody);
const aliasFunc = eval(`
(
function buildFastInstantiator(model, imports) {
${aliasFuncBody}
}
)
//# sourceURL=mqt-eval/dynamic/${className}.js
`);

// evaluate aliases and get created inner function
return aliasFunc(this.model, { $identifier, $env, $parent, $memos, $memoizedKeys, $readOnly, $type, QuickMap, QuickArray }) as T;
Expand Down

0 comments on commit c0a0cda

Please sign in to comment.