Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Cannot import WebWorker file in Vue 3 app

I would like to use Comlink in my Vue 3 application and I think Comlink just works fine however when I try to reference my worker for new Worker() I think it fails to take hold onto that file. My tree looks like this: src --pages ----page.vue --workers ----worker.js

My worker.js:

import * as Comlink from 'comlink';

const worker = {
  trial() {
    return 'hello';
  },
};

Comlink.expose(worker);

My page.vue:

import * as Comlink from "comlink";

export default {
  methods: {
    tryOnClick() {
      const worker = new Worker("../../workers/worker.js");
      Comlink.wrap(worker);
      worker.trial();
    },
  },
};

(Later I would use my worker in a manager class and not directly in the page I just want to try it out) This gives me the error in the console:

worker.js:1 Uncaught SyntaxError: Unexpected token '<'

When I open this error up it seems like it fails at the very beginning of the HTML:

<!DOCTYPE html>

How should I reference my worker.js when I initialize the new Worker?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda