Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

dynamic imports throw an error in module mode

未关闭
#51 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
领域
web-dev

调研方向

在启用和未启用模块模式的 web worker 中,复现 issue 中的动态导入示例,包括第 68-74 行的 test.js 案例。首先跟踪 ERR_INVALID_URL 和 ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING 的路径;完成的标准是动态导入能够在模块模式的 worker 中正常工作,且不会出现这些错误。

由索引模型根据 Issue 内容生成。

描述

I was made aware that make-asynchronous does't import dynamic imports (https://github.com/sindresorhus/make-asynchronous/blob/7fce502f8c5f7d2a4af20f253e9dbb14c68fa21c/test.js#L68-L74). So I looked into this by testing dynamic imports in web-worker, and I found that they somehow throw an error in "module" mode. Why?

> new (await import('web-worker')).default('data:,import("make-asynchronous").then(console.log)');
Worker {}
> new (await import('web-worker')).default('data:,import("make-asynchronous").then(console.log)', {type: "module"});
Worker {}
> TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at getSource (node:internal/modules/esm/load:47:13)
    at defaultLoad (node:internal/modules/esm/load:111:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ModuleLoader.load (node:internal/modules/esm/loader:417:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:288:11)
    at async link (node:internal/modules/esm/module_job:67:21) {
  input: 'data:,import("make-asynchronous").then(console.log)',
  code: 'ERR_INVALID_URL'
}

Through some debugging I got to an error involving ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING

主要语言
JavaScript
星标
1.2k
派生
57
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

developit/web-worker 的其他 Issue

查看 developit/web-worker 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。