MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / tryTransform

Function tryTransform

framework/register/index.js:54–65  ·  view source on GitHub ↗
(filename, content, tsx = true)

Source from the content-addressed store, hash-verified

52 /(const|let|var)\s+__filename\s*=\s*(?:(\/\*\s*@__PURE__\s*\*\/)\s*)?getFilename\s*\(\s*\)\s*;?/g,
53];
54function tryTransform(filename, content, tsx = true) {
55 for (const regex of remove) content = content.replace(regex, '');
56 return esbuild.transformSync(content, {
57 tsconfigRaw: '{"compilerOptions":{"experimentalDecorators":true}}',
58 sourcefile: filename,
59 sourcemap: 'both',
60 format: 'cjs',
61 loader: tsx ? 'tsx' : 'ts',
62 target: `node${major}.${minor}`,
63 jsx: 'transform',
64 });
65}
66
67function transform(filename, tsx = true) {
68 const code = fs.readFileSync(filename, 'utf-8');

Callers 1

transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected