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: make ParsedModule implement Sync #11581

Merged
merged 4 commits into from
Aug 6, 2021

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Aug 4, 2021

This PR is the first two points in #11345.

Basically, this change does two main things:

  1. Removes the use of swc's SourceMap and SourceFile in favour of the new SourceFileInfo, which implements Sync.
  2. Moves out comments from SingleThreadedComments to a new immutable MultiThreadedComments.

@dsherret dsherret requested a review from kitsonk August 4, 2021 19:46
@@ -0,0 +1,53 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
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 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,
Copy link
Member Author

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,
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 parameter is not necessary.

.unwrap()
}
}
}
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 function is probably not as elegant as it could be.

Copy link
Contributor

@kitsonk kitsonk left a 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"] }
Copy link
Contributor

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.

Copy link
Member Author

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)]
Copy link
Contributor

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?

@dsherret dsherret changed the title chore: make ParsedModule implement Sync refactor: make ParsedModule implement Sync Aug 6, 2021
@dsherret dsherret force-pushed the parsed-module-sync branch from 5517fc5 to 7152928 Compare August 6, 2021 13:56
@dsherret dsherret merged commit 466d3df into denoland:main Aug 6, 2021
@dsherret dsherret deleted the parsed-module-sync branch August 6, 2021 14:36
@dsherret
Copy link
Member Author

dsherret commented Aug 6, 2021

@kitsonk thanks! Fixed. Sometimes I forget to do refactor instead of chore.

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.

2 participants