Skip to content

dev and prod have inconsistent content-types for .ts filesΒ #4167

Closed
@kgullion

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions