💡 Error Message

Refused to execute script from 'http://localhost:3000/static ...ts' because its MIME type ('video/mp2t') is not executable.

 

💡 Error 난 코드

const url = new URL('./worker.ts', import.meta.url);
const worker = new Worker(url);

 

💡 원인(추정)

ts는 브라우저에서 바로 사용이 불가능해서 js로 컴파일 하는 과정이 필요하다.

그러나 저렇게 따로 넣어주게 되면 js 컴파일이 되지 않는다.

 

💡 해결

const worker = new Worker(new URL("./worker.ts", import.meta.url))

이렇게 넣어주어야 에러가 나지 않는다.

"./worker.ts"는 자신의 worker path의 상대경로를 넣어주면 된다.

 

 

🍎 관련 webpack issue

https://github.com/webpack/webpack/issues/15165

728x90

+ Recent posts