Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda