Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

☂️ Dependencies analysis #4549

Closed
ematipico opened this issue May 31, 2023 · 1 comment
Closed

☂️ Dependencies analysis #4549

ematipico opened this issue May 31, 2023 · 1 comment
Labels
A-Compiler Area: compiler A-Project Area: project configuration and loading A-resolver Area: module resolution umbrella Issue to track a collection of other issues
Milestone

Comments

@ematipico
Copy link
Contributor

Description

Create a new crate to analyze the dependencies of a JavaScript project.

Since we don't support CSS, the crate will initially work only with JavaScript files.

I don't have a clear idea yet of how to break down the work; any input on this umbrella will be of great help.

Some initial thoughts:

  • we need to find a way to pass the virtual file system to the Workspace. Project analysis requires reading files from disk. Currently, the dyn FileSystem is created and passed to Rome as an argument, but eventually, the file is processed by the Workspace without the need for the file system. We have an internal cache where we save the content of a document and its AST. There are few options we can evaluate:
    • build the dependency graph before processing the files - walking the file system, and pass the graph to the tools that need it. We should be able to apply this strategy to the LSP too.
    • pass the FileSystem to the workspace. This is the best solution, although we need to find a way to make it thread-safe, because the Workspace is safe across thread boundaries and can't panic.
  • do not support aliases for now, we would need tsconfig.json support, which we lack - we need support comments in JSON files, e.g. feat: 🎸 allow comments in json file #4382
  • The dependency graph needs to be used inside the linter somehow. We have few options here, we can use it inside the existing rome_js_analyze or we could think about having a new crate.
@ematipico ematipico added umbrella Issue to track a collection of other issues A-Compiler Area: compiler A-Project Area: project configuration and loading A-resolver Area: module resolution labels May 31, 2023
@ematipico ematipico added this to the v12.2.0 milestone May 31, 2023
@Boshen
Copy link
Contributor

Boshen commented May 31, 2023

Can you convert this to a discussion for structured comments?


A few points:

analyze the dependencies of a JavaScript project

Probably need to scope this down:

  • A TypeScript project?
  • A node.js project?
  • A CJS or ESM project?
  • ... and the list goes on

build the dependency graph

I did this for the internal version of Oxc. There are a few prerequisites:

The dependency graph needs to be used inside the linter somehow.

I also implemented this for my internal version. You need to be careful with your implementation, a single export * can blow up everything ... performance and memory wise.

I think an event system is needed, where you signal the linter a particular file's dependencies are all resolved, and is ready for lint.

The linter can take in the whole semantic facade and assume all dependencies are resolved.

@rome rome locked and limited conversation to collaborators Jun 2, 2023
@ematipico ematipico converted this issue into discussion #4551 Jun 2, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
A-Compiler Area: compiler A-Project Area: project configuration and loading A-resolver Area: module resolution umbrella Issue to track a collection of other issues
Projects
None yet
Development

No branches or pull requests

2 participants