Skip to content

Webcomponent imports fail #2010

@mitra42

Description

@mitra42

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"
}
 <script src="./webcomponents.js" type="module"></script>

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'; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions