Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Reliance on @paulbetts/mime-types is highly inconvenient #145

Open
bengotow opened this issue Oct 29, 2016 · 1 comment
Open

Reliance on @paulbetts/mime-types is highly inconvenient #145

bengotow opened this issue Oct 29, 2016 · 1 comment

Comments

@bengotow
Copy link

bengotow commented Oct 29, 2016

I'd like for electron-compile to support CJSX. I rebased #57 on top of master but found that it still didn't work. The problem is that the require-hook only maps extensions to compilers based on the mime-types database (https://github.com/electron/electron-compile/blob/master/src/require-hook.js#L13), and the mime database does not include an entry for text/cjsx:

If you log the values of ext, it looks like this. Note that text/cjsx is not the only compiler which is broken and not mapping to any file types. text/tsx is also not mapping to anything.

text/less
less
text/stylus
styl
text/jsx
jsx
application/javascript
js
text/cjsx
false         <<<<<<<
text/coffeescript
coffee
text/typescript
ts
text/tsx
false         <<<<<<<
text/cson
cson
text/html
html
text/jade
jade
text/plain
txt
image/svg+xml
svg

Technically, I could submit a PR to https://github.com/jshttp/mime-db to get text/cjsx in there, but they encourage contributors to submit new mimetypes to the governing body according to RFC 6838 section 5. I could do that, but it'd probably take a while, and then we'd have to get a chain of dependencies updated to support it.

I think it would be very preferable to replace all this with a lookup table of extensions to mimetypes. This would also allow for custom mappings - in N1, we use .es6 for ES2016 JavaScript files so that we can track our progress toward the ES2016 standard, and it would be nice for that to be mapped within electron-compile as well.

@bengotow
Copy link
Author

Was able to get this working by adding text/cjsx to the overrides already in place on top of mime-types here: https://github.com/electron/electron-compile/blob/master/src/rig-mime-types.js#L8. 👍

If 5/12 mimetypes aren't in the upstream library, maybe it'd still make sense to remove it and just add the other 7 items to that lookup table?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants