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

feat: subset type graph for JSR dependencies #346

Merged
merged 97 commits into from Jan 8, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jan 4, 2024

This is the first pass on adding a subset type graph for JSR dependencies. This type graph can then be provided to TypeScript instead of the original sources, causing very fast type checking and enabling the ability to distribute performant TypeScript as sources.

This is currently being called "fast check".

src/ast.rs Outdated
@@ -48,48 +49,35 @@ static PATH_REFERENCE_RE: Lazy<Regex> =
static TYPES_REFERENCE_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"(?i)\stypes\s*=\s*["']([^"']*)["']"#).unwrap());

pub struct ModuleParseOptions<'a> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not thrilled with this name. There is already a ParseModuleOptions in the root. Any suggestions on a better name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, this is gonna be confusing 😬 maybe just ParseOptions?

fn get_scope_analysis_parsed_source(
&self,
specifier: &ModuleSpecifier,
) -> Option<ParsedSource>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables lazily upgrading a parsed source to have scope analysis only if it's needed, which simplifies the code quite a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains the main public API changes.

// n.decorators.clear();
// n.value = None;
// Ok(true)
todo!("Remove auto-accessor for now. Waiting on https://github.com/swc-project/swc/pull/8436")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm waiting on this PR for this. I think this is ok to do for now because barely anyone uses accessors.

@@ -3767,9 +3868,79 @@ impl<'a, 'graph> Builder<'a, 'graph> {
}
module_slot
}

#[cfg(feature = "fast_check")]
fn create_fast_check_type_graph(&mut self) {
Copy link
Member Author

@dsherret dsherret Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently doesn't support caching this fast check type graph. I will add that in #347 as this PR is already large enough.

…otherwise.

- Ensure `cargo test` passes with no-default-features
@@ -44,14 +44,19 @@ jobs:
- name: Lint
if: contains(matrix.os, 'ubuntu')
run: |
cargo clippy --locked --release --all-features --all-targets -- -D clippy::all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason besides CI time to not use --release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the code has conditions based on release or debug, so it's faster to just do debug on the CI.

src/ast.rs Outdated
@@ -48,48 +49,35 @@ static PATH_REFERENCE_RE: Lazy<Regex> =
static TYPES_REFERENCE_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"(?i)\stypes\s*=\s*["']([^"']*)["']"#).unwrap());

pub struct ModuleParseOptions<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, this is gonna be confusing 😬 maybe just ParseOptions?

@dsherret dsherret merged commit 9177fe9 into denoland:main Jan 8, 2024
4 checks passed
@dsherret dsherret deleted the low_res_graph branch January 8, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants