electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 97 forks source link

Switch to a local mime-type lookup table #148

Open bengotow opened 8 years ago

bengotow commented 8 years ago

This PR replaces @paulbetts/mime-types with a local lookup table of mime types to file extensions. This is a bit less sophisticated than the previous approach, but allows electron-compile to be more flexible and removes the need for rig-mime-types, which took me a while to find when trying to contribute to the project.

It also fixes a few issues:

Resolves my general confusion in #145 :-)

anaisbetts commented 7 years ago

So, the reason we use @paulcbetts/mime-types is not to add mime-types, but to remove them. The shipped mime-db is huge and takes up like megabytes of memory, and 99%+ of the MIME types are for non-web content. @paulcbetts/mime-db is stripped to only MIME types that browsers are interested in

bengotow commented 7 years ago

Hey! Sorry for the delay - I think the issue is that @paulcbetts/mime-types is actually missing several important mime-types (for CJSX, TSX) and the current implementation doesn't allow for one-to-many compiler to mimetype mappings, (eg. for .es6). I agree mime-db is huge and unnecessary, but it seems like using a subset of the mime database for resolving compilers isn't the cleanest approach. (eg: needing rig-mime-types to add some mappings.)

In this PR @paulcbetts/mime-types is still used to resolve mime types for the protocol handler, but the file <=> compiler mapping is done in a more direct way.