@@ -11,7 +11,7 @@ import finalhandler from "finalhandler";
1111import { Hono } from "hono" ;
1212import koa from "koa" ;
1313import memfs , { Volume , createFsFromVolume } from "memfs" ;
14- import mime from "mime-types " ;
14+ import { lookup , mimes } from "mrmime " ;
1515import router from "router" ;
1616import request from "supertest" ;
1717import { Stats } from "@rspack/core" ;
@@ -34,6 +34,14 @@ import getCompilerHooks from "./helpers/getCompilerHooks";
3434// Suppress unnecessary stats output
3535rs . spyOn ( globalThis . console , "log" ) . mockImplementation ( ) ;
3636
37+ const UTF8_CHARSET_MIME_TYPES = new Set ( [
38+ "application/javascript" ,
39+ "application/json" ,
40+ "application/manifest+json" ,
41+ ] ) ;
42+
43+ mimes . usdz = "model/vnd.usdz+zip" ;
44+
3745async function startServer ( name , app ) {
3846 return new Promise ( ( resolve , reject ) => {
3947 if ( name === "router" ) {
@@ -270,7 +278,21 @@ function get404ContentTypeHeader(name) {
270278}
271279
272280function getContentTypeHeader ( name , ext = "js" ) {
273- return mime . contentType ( ext ) ;
281+ const mimeType = lookup ( ext ) ;
282+
283+ if ( ! mimeType ) {
284+ return undefined ;
285+ }
286+
287+ if ( mimeType . includes ( ";" ) ) {
288+ return mimeType ;
289+ }
290+
291+ if ( mimeType . startsWith ( "text/" ) || UTF8_CHARSET_MIME_TYPES . has ( mimeType ) ) {
292+ return `${ mimeType } ; charset=utf-8` ;
293+ }
294+
295+ return mimeType ;
274296}
275297
276298function applyTestMiddleware ( name , middlewares ) {
0 commit comments