如何使用 Create-React-App 节点服务器定义 MIME 类型?

How to define MIME types with Create-React-App's node server?

我正在尝试处理这个 WebAssembly 注释:"Note: To run with instantiateStreaming and compileStreaming, you need your webserver to serve .wasm file with application/wasm MIME type. The https crate can be used to serve files from localhost, and includes the application/wasm MIME type out of the box."

确实,我在 JS 控制台中收到 MIME 错误。 Google 搜索显示无法配置它。 Mozilla 建议在 depricated WebAssembly.instantiate 上使用 instantiateStreaming。如果使用 stdweb 或 bindgen,后者对我也不起作用:它需要第二个参数,我不确定如何提供。

不幸的是,您正在研究前沿技术! WebAssembly 流式编译是一个非常新的特性,只有 currently supported in FireFox and Chrome

你说得对,这取决于服务器上的文件是否具有正确的 mime 类型。正在进行实现此目标所需的更改:

但是,这些都是 create-react-app 的上游依赖项,通过 react-scripts。 react-scripts has a dependency on webback-dev-middleware that supports wasm 的最前沿版本,但尚未发布。 npm 上的最新版本使用旧版本。

目前,我将转向流式编译,直到这些更改使其成为 'production'。