denoland / denoland/deno_graph
Propose new dependency structure for 2.0
- Dominant language
- Rust
- Stars
- 137
- Forks
- 47
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
The current `Dependency` definition incurs an extra layer of depth to support an uncommon case like `// @deno-types`, we can flatten it with these types:
```ts
export type Dependency = {
key: string;
specifier?: string; // ┐
error?: string; // ┴─ mutually exclusive
range: Range;
isTypeOnly?: boolean;
isDynamic?: boolean;
externalTypesIndex?: number; // @deno-types is extracted as another dependency, the index pointing to it goes here.
}
export interface EsModule {
dependencies: Dependency[];
externalTypes: { // renamed from typesDependency
key: string; // specifier text
specifier?: string; // ┐
error?: string; // ┴─ mutually exclusive
range?: Range; // defined for ts reference, not X-TypeScript-Types (currently non-optional field with strange default)
}
// ...
}
```
This module gets the following serializations:
```js
///
///
import * as a from "./runtime.ts";
// @deno-types="./untyped_runtime.d.ts"
import * as a from "./untyped_runtime.js";
import * as a from "bad.js";
```
### Currently
```js
{
kind: "esm",
dependencies: [
{
specifier: "./runtime.ts",
code: {
specifier: "file:///runtime.ts",
span: { /*...*/ },
},
},
{
specifier: "./type_only.d.ts",
type: {
specifier: "file:///type_only.d.ts",
span: { /*...*/ },
},
},
{
specifier: "./untyped_runtime.js",
code: {
specifier: "file:///untyped_runtime.js",
span: { /*...*/ },
},
type: {
specifier: "file:///untyped_runtime.d.ts",
span: { /*...*/ },
},
},
{
specifier: "bad.js",
code: {
error: 'Relative import path "bad.js" not prefixed with / or ./ or ../',
span: { /*...*/ },
},
},
],
size: 250,
typesDependency: {
specifier: "./external_types.d.ts",
dependency: {
specifier: "file:///external_types.d.ts",
span: { /*...*/ },
},
},
mediaType: "JavaScript",
specifier: "file:///entry.js",
}
```
### Proposed
```js
{
kind: "esm",
dependencies: [
{
key: "./runtime.ts",
specifier: "file:///runtime.ts",
range: { /*...*/ },
},
{
key: "./type_only.d.ts",
specifier: "file:///type_only.d.ts",
range: { /*...*/ },
isTypeOnly: true,
},
{
key: "./untyped_runtime.js",
specifier: "file:///untyped_runtime.js",
range: { /*...*/ },
externalTypesIndex: 3,
},
{
key: "./untyped_runtime.d.ts",
specifier: "file:///untyped_runtime.d.ts",
range: { /*...*/ },
isTypeOnly: true,
},
{
key: "bad.js",
error: 'Relative import path "bad.js" not prefixed with / or ./ or ../',
range: { /*...*/ },
},
],
size: 250,
externalTypes: {
key: "./external_types.d.ts",
specifier: "file:///external_types.d.ts",
range: { /*...*/ },
},
mediaType: "JavaScript",
specifier: "file:///entry.js",
}
```
cc @dsherret
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the Dependency and EsModule definitions and the code that produces their current serializations. Compare those entry points with the proposed flattened shape, then trace consumers that depend on the existing nested fields; done means the 2.0 structure and shown serialization cases are represented consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, typescript
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100