deno_graph icon indicating copy to clipboard operation
deno_graph copied to clipboard

refactor: flatten dependency structure

Open nayeemrmn opened this issue 1 year ago • 0 comments

Towards #247. Implements the proposed API on the rust side while keeping a legacy serialization layer to preserve deno info --json.

Essentially dependencies like this:

{
  dependencies: [
    {
      specifier: "./foo.js",
      code: {
        specifier: "file:///foo.js",
        range: { /*...*/ },
      },
      type: {
        specifier: "file:///foo.d.ts",
        range: { /*...*/ },
      },
    },
  ]
}

are now like this:

{
  dependencies: [
    {
      key: "./foo.js",
      specifier: "file:///foo.js",
      range: { /*...*/ },
      externalTypesIndex: 1, // Points to the second entry below.
    },
    {
      key: "./foo.d.ts",
      specifier: "file:///foo.d.ts",
      range: { /*...*/ },
      isTypeOnly: true,
    },
  ]
}

where you can actually reason about the properties of each dependency since they are limited to one specifier key, one resolved specifier and a flatter structure.

nayeemrmn avatar Apr 24 '23 09:04 nayeemrmn