-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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: make ParsedModule
implement Sync
#11581
Conversation
@@ -0,0 +1,53 @@ | |||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is a straight extract out of mod.ts
. I did a slight bit of cleanup in this PR as well.
static TARGET: JscTarget = JscTarget::Es2020; | ||
|
||
#[derive(Debug, Clone, Eq, PartialEq)] | ||
pub struct Location { | ||
pub filename: String, | ||
pub specifier: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to specifier
to align with elsewhere.
@@ -452,21 +431,12 @@ fn flatten_comments( | |||
comments.into_iter().flat_map(|el| el.1) | |||
} | |||
|
|||
pub fn lex( | |||
specifier: &str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter is not necessary.
.unwrap() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is probably not as elegant as it could be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but a couple of brief comments.
Also, I think it is more of refactor:
than a chore:
(https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716)
@@ -82,7 +82,7 @@ serde = { version = "1.0.126", features = ["derive"] } | |||
shell-escape = "0.1.5" | |||
sourcemap = "6.0.1" | |||
swc_bundler = "0.46.0" | |||
swc_common = { version = "0.11.0", features = ["sourcemap"] } | |||
swc_common = { version = "0.11.4", features = ["sourcemap"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the version bump required for this PR? Normally we bump all the other uses of swc_common across the crates before a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Need it for some changes I did in swc_common.
use swc_common::comments::SingleThreadedCommentsMapInner; | ||
use swc_common::BytePos; | ||
|
||
#[derive(Clone, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it is a big deal, but future generations might benefit from a little explanation of why we are doing this?
ParsedModule
implement Sync
ParsedModule
implement Sync
5517fc5
to
7152928
Compare
@kitsonk thanks! Fixed. Sometimes I forget to do |
This PR is the first two points in #11345.
Basically, this change does two main things:
SourceMap
andSourceFile
in favour of the newSourceFileInfo
, which implementsSync
.SingleThreadedComments
to a new immutableMultiThreadedComments
.