title: How to satisfy strict mime type checking for wasm?
body: <p>I got a webassembly module to compile using emscripten. Now I'm trying to serve it up in a web page using expressjs. </p>
  
  <p>I've tried following <a href="https://github.com/webpack/webpack/tree/master/examples/wasm-simple" rel="noreferrer">this gist</a> on including webassembly via webpack, including a modification I found since this gist is a little older. </p>
  
  <p>The webpack looks like this:</p>
  
  <pre><code>const path = require('path');
  
  module.exports = {
    optimization: {
      mangleWasmImports: false
    },
    entry: './src/index.js',
    output: {
      path: path.resolve(__dirname, './dist/'),
      filename: 'dynamic-graph.bundle.js'
    },
    target: "web",
    module: {
      rules: [
        // Emscripten JS files define a global. With `exports-loader` we can 
        // load these files correctly (provided the global’s name is the same
        // as the file name).
        {
          test: /fourd\.js$/,
          loader: "exports-loader"
        },
        // wasm files should not be processed but just be emitted and we want
        // to have their public URL.
        {
          test: /fourd\.wasm$/,
          type: "javascript/auto",
          loader: "file-loader",
          options: {
            publicPath: "dist/"
          }
        }
      ]
    }
  }
  
  </code></pre>
  
  <p>I set up https on the dev-server, because I know that sometimes causes issues. It's a self signed certificate, but Chrome and Firefox let me get around that. </p>
  
  <pre class="lang-js prettyprint-override"><code>const express = require('express')
  const fs = require('fs')
  express.static.mime.types['wasm'] = 'application/wasm'
  const https = require('https')
  const app = express()
  
  app.use('/', express.static(__dirname))
  app.use((req, res, next) =&gt; {
    res.header('X-Content-Type-Options', 'nosniff')
    next()
  })
  https.createServer({
    key: fs.readFileSync('server.key'),
    cert: fs.readFileSync('server.cert')
  }, app).listen(8000, () =&gt; {
    console.log('Listening...')
  })
  </code></pre>
  
  <p>In a previous version, I was able to use Module.onRuntimeInitialized to wait for the wasm module to be instantiated. That code still works, I compiled the webpack using the same em++ flags as before, namely <code>-std=c++11 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s SAFE_HEAP=1 -O0 -g4 -s ASSERTIONS=1</code></p>
  
  <p>The error I get in the browser is the following: <code>Failed to load module script: The server responded with a non-JavaScript MIME type of "application/wasm". Strict MIME type checking is enforced for module scripts per HTML spec.</code> which throws me for a loop, because I thought application/wasm is exactly what the MIME type should be.</p>