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

refactor: rewrite TS dependency analysis in Rust #5029

Merged
merged 55 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8a2d4e2
add permissions argument to file fetcher methods
bartlomieju Apr 30, 2020
c7dc065
drop permissions prefix
bartlomieju May 10, 2020
a8f431d
add permission check to SourceFileFetcher
bartlomieju May 10, 2020
17d06b3
use Permissions::allow_all
bartlomieju May 10, 2020
38ebecd
propagate proper permissions
bartlomieju May 10, 2020
98984e4
add docs
bartlomieju May 10, 2020
62e6db4
remove cli/compilers/js.rs
bartlomieju May 7, 2020
161a361
remove cli/compilers/; add cli/tsc.rs
bartlomieju May 7, 2020
c1e55bc
prototype module graph loader
bartlomieju May 1, 2020
ea6e891
add test for circular deps
bartlomieju May 1, 2020
198166a
update tests
bartlomieju May 4, 2020
cf840fb
prototype tests
bartlomieju May 6, 2020
22e879f
parse imports and type directives
bartlomieju May 6, 2020
ac3668c
type directives analysis
bartlomieju May 6, 2020
d6aff93
lint
bartlomieju May 7, 2020
319b94a
basic compilation working
bartlomieju May 7, 2020
db5405a
fmt
bartlomieju May 7, 2020
9bbd7a5
fix bundle tests
bartlomieju May 7, 2020
cfdef1e
fixes
bartlomieju May 11, 2020
7827a56
fix integration tests
bartlomieju May 11, 2020
ae1d693
fmt
bartlomieju May 11, 2020
ccf6413
tweak tests
bartlomieju May 11, 2020
4ae457c
fmt
bartlomieju May 11, 2020
834f114
Merge branch 'master' into module_graph
bartlomieju May 13, 2020
aaf4e7d
Merge branch 'master' into module_graph
bartlomieju May 14, 2020
d2eb3b3
concurrent downloads
bartlomieju May 14, 2020
10f1ce8
fmt
bartlomieju May 14, 2020
28ce202
cleanup
bartlomieju May 14, 2020
aa096a9
cleanup2
bartlomieju May 14, 2020
3a1c842
runtime compile remote files
bartlomieju May 16, 2020
5fccde9
runtime compiler tests passing
bartlomieju May 16, 2020
e26cc3e
fix bundles
bartlomieju May 16, 2020
a28794e
cleanup compiler
bartlomieju May 16, 2020
494a36b
fix bundle with dynamic imports
bartlomieju May 16, 2020
c0cc20e
Merge branch 'master' into module_graph
bartlomieju May 16, 2020
facf6ab
fix some tests
bartlomieju May 16, 2020
2224543
remove unused code
bartlomieju May 16, 2020
512f535
fix more tests
bartlomieju May 16, 2020
afcfb41
cleanup
bartlomieju May 16, 2020
8866437
Merge branch 'master' into module_graph
bartlomieju May 16, 2020
6897f7f
run TS compiler worker on the same thread
bartlomieju May 16, 2020
0eb065c
properly poll ts worker
bartlomieju May 16, 2020
cb8ced7
don't use oldProgram
bartlomieju May 17, 2020
4aacc79
Merge branch 'master' into module_graph
bartlomieju May 17, 2020
90e903a
fix after merge
bartlomieju May 17, 2020
e3ebbe7
remove debug code
bartlomieju May 17, 2020
8cb3a49
Merge branch 'master' into module_graph
bartlomieju May 17, 2020
f96c3e2
fix tests
bartlomieju May 17, 2020
a2e9a3b
Merge branch 'master' into module_graph
ry May 17, 2020
fa3c816
review
bartlomieju May 17, 2020
28544c9
fix
bartlomieju May 17, 2020
35adb52
review2
bartlomieju May 18, 2020
f84e66c
Merge branch 'master' into module_graph
bartlomieju May 18, 2020
5d02e05
fmt
bartlomieju May 18, 2020
aa67332
reset CI
bartlomieju May 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli/file_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct SourceFile {
pub url: Url,
pub filename: PathBuf,
pub types_url: Option<Url>,
pub types_header: Option<String>,
pub media_type: msg::MediaType,
pub source_code: Vec<u8>,
}
Expand Down Expand Up @@ -323,6 +324,7 @@ impl SourceFileFetcher {
media_type,
source_code,
types_url,
types_header: None,
})
}

Expand Down Expand Up @@ -380,6 +382,7 @@ impl SourceFileFetcher {
&fake_filepath,
headers.get("content-type").map(|e| e.as_str()),
);
let types_header = headers.get("x-typescript-types").map(|e| e.to_string());
let types_url = match media_type {
msg::MediaType::JavaScript | msg::MediaType::JSX => get_types_url(
&module_url,
Expand All @@ -394,6 +397,7 @@ impl SourceFileFetcher {
media_type,
source_code,
types_url,
types_header,
}))
}

Expand Down Expand Up @@ -502,6 +506,8 @@ impl SourceFileFetcher {
headers.get("content-type").map(String::as_str),
);

let types_header =
headers.get("x-typescript-types").map(String::to_string);
let types_url = match media_type {
msg::MediaType::JavaScript | msg::MediaType::JSX => get_types_url(
&module_url,
Expand All @@ -517,6 +523,7 @@ impl SourceFileFetcher {
media_type,
source_code: source,
types_url,
types_header,
};

Ok(source_file)
Expand Down
11 changes: 9 additions & 2 deletions cli/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl GlobalState {
maybe_referrer: Option<ModuleSpecifier>,
target_lib: TargetLib,
permissions: Permissions,
is_dyn_import: bool,
) -> Result<CompiledModule, ErrBox> {
let state1 = self.clone();
let state2 = self.clone();
Expand All @@ -115,14 +116,20 @@ impl GlobalState {
| msg::MediaType::JSX => {
state1
.ts_compiler
.compile(state1.clone(), &out, target_lib, permissions.clone())
.compile(state1.clone(), &out, target_lib, permissions, is_dyn_import)
.await
}
msg::MediaType::JavaScript => {
if state1.ts_compiler.compile_js {
state2
.ts_compiler
.compile(state1.clone(), &out, target_lib, permissions.clone())
.compile(
state1.clone(),
&out,
target_lib,
permissions,
is_dyn_import,
)
.await
} else {
if let Some(types_url) = out.types_url.clone() {
Expand Down
Loading