developit / developit/web-worker

`1.5.0` regression: workers treated as ESM by default

未關閉
#55 1 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
1.2k
分支
57
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

研究方向

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.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, node.js
領域
backend
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。