Skip to content

Support multiple ranges for an import in the graph #132

@kitsonk

Description

@kitsonk

Currently the graph cannot represent multiple locations an import specifier might be imported in a file. For example, an import can be like this:

import * as a from "https://example.com/a";
import { default as b } from "https://example.com/a";

In addition, in theory, a module can be statically and dynamically imported:

import * as a from "https://example.com/a";
const b = await import("https://example.com/a";

Or in TypeScript the same specifier can be provided for a type only import:

import { a } from "https://example.com/a";
import type { A } from "https://example.com/a";

Currently we only store the last range for the specifier in the graph. This makes it difficult when trying to rewrite specifiers (like in dnt or deno vendor) as well as means that diagnostics are only issued for the "last" import location, not all import locations for a given specifier.

We should enhance the graph to be able to store this information, which is likely going to be a breaking change, but one that increases the usability of the graph.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions