Skip to content

Commit 22bc65f

Browse files
committed
feat: support concurrent diagnostics
1 parent 91bb1ef commit 22bc65f

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typescript = ["transforms", "swc_ecma_transforms_typescript"]
2929
utils = ["swc_ecma_utils"]
3030
view = ["dprint-swc-ext/view"]
3131
visit = ["swc_ecma_visit", "swc_visit", "swc_visit_macros", "swc_macros_common"]
32+
concurrent = ["swc_common/concurrent"]
3233

3334
[dependencies]
3435
anyhow = { version = "1.0.64", optional = true }

src/source_map.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22

3-
use std::rc::Rc;
4-
53
use crate::swc::common::FileName;
64
use crate::swc::common::SourceFile;
5+
use swc_common::sync::Lrc;
76

87
use crate::ModuleSpecifier;
98

@@ -31,7 +30,7 @@ impl IntoSwcFileName for &str {
3130

3231
#[derive(Clone, Default)]
3332
pub struct SourceMap {
34-
inner: Rc<crate::swc::common::SourceMap>,
33+
inner: Lrc<crate::swc::common::SourceMap>,
3534
}
3635

3736
impl SourceMap {
@@ -43,15 +42,15 @@ impl SourceMap {
4342
map
4443
}
4544

46-
pub fn inner(&self) -> &Rc<crate::swc::common::SourceMap> {
45+
pub fn inner(&self) -> &Lrc<crate::swc::common::SourceMap> {
4746
&self.inner
4847
}
4948

5049
pub fn new_source_file(
5150
&self,
5251
file_name: impl IntoSwcFileName,
5352
source: String,
54-
) -> Rc<SourceFile> {
53+
) -> Lrc<SourceFile> {
5554
self
5655
.inner
5756
.new_source_file(file_name.into_file_name(), source)

src/transpiling/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22

3-
use std::rc::Rc;
43
use std::sync::Arc;
4+
use swc_common::sync::{Lrc, Send, Sync};
55

66
use anyhow::Result;
77
use swc_ecma_visit::as_folder;
@@ -308,9 +308,12 @@ fn transpile(
308308

309309
#[derive(Default, Clone)]
310310
struct DiagnosticCollector {
311-
diagnostics_cell: Rc<RefCell<Vec<SwcDiagnostic>>>,
311+
diagnostics_cell: Lrc<RefCell<Vec<SwcDiagnostic>>>,
312312
}
313313

314+
unsafe impl Send for DiagnosticCollector {}
315+
unsafe impl Sync for DiagnosticCollector {}
316+
314317
impl DiagnosticCollector {
315318
pub fn into_handler(self) -> crate::swc::common::errors::Handler {
316319
crate::swc::common::errors::Handler::with_emitter(

0 commit comments

Comments
 (0)