Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph does not support multiple imports of the same specifier #80

Open
kitsonk opened this issue Dec 14, 2021 · 1 comment
Open

Graph does not support multiple imports of the same specifier #80

kitsonk opened this issue Dec 14, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Dec 14, 2021

When doing something like this:

import a from "./a.js";
import * as b from "./a.js";
const c = await import("./a.js");

The dependencies for the module only include one import site. They should actually be two seperate dependency objects, as they "may" differ in ways (like import assertions or type definitions).

That being said, it still works and adding support for it would make everything related to it fairly complex, as knowing the import location would become essential for accessing information (unless we stored a vec of locations, and associated information, like it being a dynamic import and any import assertions).

@kitsonk kitsonk added the enhancement New feature or request label Jan 10, 2022
@devingfx
Copy link

Yes I had got the issue with https://esm.sh 's redirect packages:

/* esm.sh - package@x.y.z */
export * from "https://esm.sh/v117/package@x.y.z/deno/index.mjs"
export { default } from "https://esm.sh/v117/package@x.y.z/deno/index.mjs"

With a simple custom naive replacer, you are not able to know the existence of other instance in text, so url replacement fail here:

(pseudo code)

graph.modules.map( m=> {
    m.content = load file in cache folder
    for( const dep of m.dependencies )
        replaceBetweenStartEnd( m.content, dep.code.span, makeLocalhost(dep.specfier) )
})

Produces

/* esm.sh - package@x.y.z */
export * from "http://localhost:8117/cache/deps/https/..."   << only this one is replaced
export { default } from "https://esm.sh/v117/package@x.y.z/deno/index.mjs"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants