dev and prod have inconsistent content-types for .ts filesΒ #4167
Closed
Description
Describe the bug
.ts
files imported via the *?url
hook have different content-types. In dev, the .ts file is served with the content-type application/javascript
while in prod it is served as a video/mp2t
dataUri.
Related: #2642
Reproduction
https://github.com/kgullion/vite-typescript-audio-worklet-example
The first 2 lines of src/main.ts
are sufficient for reproduction. I've included a short example for additional context.
npm run dev
works as expected but npm run build && npm run serve
returns the incorrect Content Type for the AudioWorklet. This causes Uncaught (in promise) DOMException: The user aborted a request.
in the browser (see: https://stackoverflow.com/a/51469624/992385).
System Info
System:
OS: Linux 5.12 undefined
CPU: (4) x64 Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz
Memory: 346.62 MB / 3.74 GB
Container: Yes
Shell: 5.1.8 - /bin/bash
Binaries:
Node: 16.2.0 - /usr/bin/node
Yarn: 1.22.10 - /usr/bin/yarn
npm: 7.15.1 - /usr/bin/npm
Browsers:
Brave Browser: 91.1.25.68
Chromium: 91.0.4472.77
Firefox: 89.0
npmPackages:
vite: ^2.4.0 => 2.4.1
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.