developit / developit/web-worker

dynamic imports throw an error in module mode

Abierto
#51 1 comentario 0 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

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.