In this issue #5105 a workaround is provided to eval typescript code by transpiling it with with Bun.Transpiler. Like in this repository https://github.com/Kleywalker/bun-eval the Bun.Transpiler does not result in an evaluable code. In this example the code
import { kebab } from "case";
const result = kebab('Test Content');
export default result;
transpiles to the code
import {kebab} from "case";
const result = kebab("Test Content");
export default result;
which does not work with eval.
What is the feature you are proposing to solve the problem?
With tsc this code
import * as tsc from "typescript";
const content = `import { kebab } from "case";
const result = kebab('Test Content');
export default result;`;
const tscTranspiled = tsc.transpile(content);
console.log(tscTranspiled);
transpiles to this code
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var case_1 = require("case");
var result = (0, case_1.kebab)('Test Content');
exports.default = result;
with works with eval just fine.
What alternatives have you considered?
An alternative would be to create a Bun.eval function that evals code including imports and exports.
What is the problem this feature would solve?
In this issue #5105 a workaround is provided to eval typescript code by transpiling it with with Bun.Transpiler. Like in this repository https://github.com/Kleywalker/bun-eval the
Bun.Transpiler
does not result in an evaluable code. In this example the codetranspiles to the code
which does not work with eval.
What is the feature you are proposing to solve the problem?
With
tsc
this codetranspiles to this code
with works with
eval
just fine.What alternatives have you considered?
An alternative would be to create a
Bun.eval
function that evals code includingimports
andexports
.No response