developit / developit/web-worker

`1.5.0` regression: workers treated as ESM by default

Abierto
#55 1 comentario 5 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
1.2k
Forks
57
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi,

Glad to stumbled on this neat project and looking forward to using it to write more consistent browser-node code.

I'm trying to get duckdb-wasm working in node, I found a [`bare-node`](https://github.com/duckdb/duckdb-wasm/blob/main/examples/bare-node/index.cjs) example in their repo.

It fails when I run it, with error:

`ReferenceError: module is not defined`

It uses web-worker, and it seems like the worker code (clearly CJS and with file extension `cjs`) gets detected like an ESM module.

Downgrading web-worker from `1.5.0` to `1.4.1` fixes the issue. I tried a few other things like passing type: commonjs, type: classic - none worked.

Suggests a regression in 1.5.0 release (edit: unless changing the default behavior in 1.5.0 is intentional)

Thanks
Declan

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by running the duckdb-wasm bare-node example at examples/bare-node/index.cjs with web-worker 1.5.0, then compare it with 1.4.1. Trace how the worker script is loaded and how its module type is selected; done means the CJS worker runs under 1.5.0 without the `module is not defined` error while preserving the documented worker behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
backend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
52/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.