Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ts_serve/utils/transpile_response.ts>transpileResponse

Transpile TypeScript on the fly and deliver it from your server as ES Modules.
Latest
function transpileResponse
import { transpileResponse } from "https://deno.land/x/ts_serve@v1.4.4/utils/transpile_response.ts";

Transpile the body of the response and return a new response.

import { serve } from "https://deno.land/std@0.177.0/http/mod.ts";
import { serveFile } from "https://deno.land/std@0.177.0/http/file_server.ts";

import { transpileResponse } from "https://deno.land/x/ts_serve@v1.4.4/utils/transpile_response.ts"

serve(async (request) => {
  const filePath = "./mod.ts";
  const response = await serveFile(request, filePath);
  return await transpileResponse(response, request.url, filePath);
});

Parameters

response: Response

The response you want to transpile

requestUrl: string

The URL used to construct the source map URL

optional
filepath: string

If specified, the file path extension is used to determine the file type.