Skip to content
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

[nxt_http_static] add .mjs extension to default_types #1541

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

kedartal
Copy link
Contributor

Associate file extension .mjs with application/javascript.

Context: common output of static site generators. There's little risk of ambiguity for this extension, so might as well support it out of the box.

@ac000
Copy link
Member

ac000 commented Jan 13, 2025

I'm in two minds about this.

There are several other obvious missing entries...

But then you can always add your own (and modify existing ones) like

"settings": {
    "http": {
        "static": {
            "mime_types": {
                "application/javascript": [
                    ".js",
                    ".mjs"
                ]
            }
        }
    }
},

Each mime_types entry can either be an array or a string.

@kedartal
Copy link
Contributor Author

@ac000 Of course, but that requires a call to the control API -- in practice, often a separate call from the one for configuring listeners, applications, routes et cetera. IMHO we should add all or most of the standard types: the impacts on the binary size and runtime complexity are negligible, standard MIME changes very slowly so little maintenance cost, and obviously it's easier for users so good for adoption. As you said, users can always append / replace, so including all or most types by default seems natural.
An alternative might be to offload the types list into a file processed by a build make script, but I guess most users prefer installing from a package manager rather than build from sources, and I'm not sure it would make life easier for anyone.

@ac000
Copy link
Member

ac000 commented Jan 14, 2025

I'm not against adding it... let's see what others think...

Cc: @hongzhidao
Cc @avahahn :

@hongzhidao
Copy link
Contributor

Hi,
I’m fine with it.

Associate file extension `.mjs` with `application/javascript`.

Context: common output of static site generators. There's little risk of
ambiguity for this extension, so might as well support it out of the
box.

[ Subject tweak - Andrew ]
Signed-off-by: Andrew Clayton <[email protected]>
@ac000 ac000 merged commit ed12d8a into nginx:master Jan 14, 2025
@ac000
Copy link
Member

ac000 commented Jan 14, 2025

Thanks Tal, applied (with a minor tweak to the commit subject).

@kedartal
Copy link
Contributor Author

@ac000 Thanks!

@kedartal kedartal deleted the static_types branch January 14, 2025 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants