New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add correct mime types for Javascript #5661
Conversation
Thank you, @jonnitto. I combined Check the artifacts below ⬇️ |
Download the artifacts for this pull request:
See Testing a PR |
Rebased because the artifact bot comment links were invalid (see #5662). |
in regards of consistency is the mime type already available for apache? cuz the patch only updates the nginx config but ddev is shipping with nginx and apache? so i wondered if the apache config would have to be updated as well that both support it? |
Thank you @rpkoller, this is a good point. I checked Apache2, and it gives the correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Debian bullseye we have application/javascript
:
cat /etc/mime.types | grep "js mjs"
application/javascript js mjs
In Debian Bookworm we have text/javascript
(source from media-types):
cat /etc/mime.types | grep "js mjs"
text/javascript es js mjs
If this is the right file for Apache, we can add cjs
here:
ddev/containers/ddev-webserver/ddev-webserver-base-files/etc/apache2/mods-available/mime.conf
Line 29 in 94d7750
AddType application/x-bzip2 .bz2 |
And it is better to use text/javascript
instead of deprecated application/javascript
.
See https://trac.nginx.org/nginx/ticket/2216
This adds the correct type for the Javascript file extension for Modules `.mjs` and for CommonJS `.cjs`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased, updated MIME types for Apache2, used newer text/javascript
, tested and updated the manual testing instructions.
This add the correct MIME type for the Javascript file extension for Modules
.mjs
and for CommonJS.cjs
CJS, MJS, and .JS are file extensions used to denote different types of JavaScript files. Here's the difference between them:
JS (JavaScript):
The
.js
extension is the most common file extension for JavaScript files. It is used to indicate that a file contains JavaScript code..js
files can be executed in different JavaScript environments, such as web browsers, servers, and other JavaScript runtime environments.CJS (CommonJS):
CommonJS is a module system for JavaScript used in server-side environments like Node.js. The CJS module format allows you to define modules using the
require
andmodule.exports
syntax. In CommonJS, each file is treated as a separate module, and you can import/export functionality between modules usingrequire
andmodule.exports
.MJS (ECMAScript Modules):
MJS is an extension used for JavaScript files that adhere to the ECMAScript Modules (ESM) specification. ECMAScript modules are part of the JavaScript language standard and provide a more modern and standardized way to define modules. ECMAScript modules use the
import
andexport
keywords to define dependencies and expose functionality between modules.The Issue
If I try to include a Javascript Module with the extension
.mjs
, I'll get the errorHow This PR Solves The Issue
It adds the correct type for all kind of Javascript files
Manual Testing Instructions
Automated Testing Overview
If there is way to test this, please tell me
Release/Deployment Notes
This does not affect the behavior of other parts of ddev itself.
If a user's application relies on a non-standards-compliant content-type mimetype for
.mjs
/.cjs
files, their application may fail, as we are now serving the files as javascript