caolan / caolan/async

Webcomponent imports fail

Open
#2,010 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
28.1k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**What version of async are you using?**
3.2.6

**Which environment did the issue occur in (Node/browser/Babel/Typescript version)?**
Webcomponents (browser)

**Is there a compiler in your toolchain? If so, is it targeting ES2017 or later and preserving `async` functions?**
No

**What did you do? Please include a minimal reproducible case illustrating issue.**
index.html contains
```
"imports": {
"async-es": "./node_modules/async-es/index.js"
}

```
webcomponents.js contains
```
import { each } from './node_modules/async-es/index.js';
```
**What did you expect to happen?**
That it would load the appropriate files (under async-es/index.js) and allow me to call `each`

**What was the actual result?**
A string of errors in the console like
```
GET http://localhost:8080/node_modules/async-es/unmemoize net::ERR_ABORTED 404 (Not Found)
```

My (possibly wrong) diagnosis.

This seems to be because index.js contains lines like
```
import apply from './apply'
```
which don't specify the `.js`

I'm guessing this would work in node as it might be able to make the assumption. but browser modules are very picky and want exact filenames which return correct mime-types etc.

Note --- as a workaround, the non-modules version of async, actualy works better in browser modules for some strange reason.
```
import async from './node_modules/async/dist/async.mjs';
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.