denoland / deno_ast

Source text parsing, lexing, and AST related functionality for Deno
https://crates.io/crates/deno_ast
MIT License
156 stars 46 forks source link

Map file extension to content type #133

Closed Cre3per closed 1 year ago

Cre3per commented 1 year ago

https://github.com/denoland/deno/pull/17172 adds --ext to deno, eg.

deno run --ext js mod

--ext needs to map file extensions to mime types

The mapping function in deno is incomplete and temporary.

deno_ast's MediaType already maps module specifiers and mime types to MediaType. I think this is a good place to map

Cre3per commented 1 year ago

I'd like to work on this.

There is no 1:1 mapping between file extensions and mime types, eg. application/typescript and text/typescript both have a ".ts" file extension. For a start, I'll write a mapping function based on the mime types in from_content_type()

dsherret commented 1 year ago

Sounds good to me!