Suggestion: support es modules .mjs file with mime-type application/javascript

37 views
Skip to first unread message

jxck jxck

unread,
Aug 16, 2017, 2:16:47 AM8/16/17
to Ruby on Rails: Core
Hi all.

Node.js decided to use `.mjs` file extension for ES Moduels.


this cause developer will write es modules in .mjs file and also serve to browser as is.

so http server who determine content-type via file extension should support `.mjs` avoid to be `content-type: octet-stream`

the mime type for `.mjs` are same as `.js` as follow.


so rails/actionpack/lib/action_dispatch/http/mime_types.rb better to add following line


```
Mime::Type.register "text/javascript", :js, %w( application/javascript application/x-javascript )
+ Mime::Type.register "text/javascript", :mjs, %w( application/javascript application/x-javascript )
```

any comments are welcome.

thanks

Jxck
Reply all
Reply to author
Forward
0 new messages