Skip to content

Commit

Permalink
Various things
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jun 4, 2021
1 parent 134c731 commit a72bc3b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/transformers/js/core/src/dependency_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum DependencyKind {
WebWorker,
ServiceWorker,
ImportScripts,
URL,
Url,
File,
}

Expand Down Expand Up @@ -465,7 +465,7 @@ impl<'a> Fold for DependencyCollector<'a> {

fn fold_expr(&mut self, node: ast::Expr) -> ast::Expr {
if let Some((specifier, span)) = match_import_meta_url(&node, self.decls) {
self.add_dependency(specifier.clone(), span, DependencyKind::URL, None, false);
self.add_dependency(specifier.clone(), span, DependencyKind::Url, None, false);

return ast::Expr::Call(create_require(specifier));
}
Expand Down
18 changes: 7 additions & 11 deletions packages/transformers/js/core/src/hoist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ impl Visit for Collect {
self
.exports
.entry(id!(namespace.name))
.or_insert("*".into());
.or_insert_with(|| "*".into());
}
}
}
Expand Down Expand Up @@ -1732,10 +1732,8 @@ impl Collect {
}
}
Pat::Array(array) => {
for el in &array.elems {
if let Some(el) = el {
self.get_non_const_binding_idents(&el, idents);
}
for el in array.elems.iter().flatten() {
self.get_non_const_binding_idents(&el, idents);
}
}
_ => {}
Expand All @@ -1744,7 +1742,7 @@ impl Collect {
}

fn is_marked(span: Span, mark: Mark) -> bool {
let mut ctxt = span.ctxt().clone();
let mut ctxt = span.ctxt();

loop {
let m = ctxt.remove_mark();
Expand Down Expand Up @@ -1836,11 +1834,9 @@ fn has_binding_identifier(node: &Pat, sym: &JsWord, decls: &HashSet<IdentId>) ->
}
}
Pat::Array(array) => {
for el in &array.elems {
if let Some(el) = el {
if has_binding_identifier(&el, sym, decls) {
return true;
}
for el in array.elems.iter().flatten() {
if has_binding_identifier(&el, sym, decls) {
return true;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/transformers/js/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,14 @@ fn parse(
}
}

type EmitResult = (Vec<u8>, Vec<(swc_common::BytePos, swc_common::LineCol)>);

fn emit(
source_map: Lrc<SourceMap>,
comments: SingleThreadedComments,
program: &Module,
source_maps: bool,
) -> Result<(Vec<u8>, Vec<(swc_common::BytePos, swc_common::LineCol)>), std::io::Error> {
) -> Result<EmitResult, std::io::Error> {
let mut src_map_buf = vec![];
let mut buf = vec![];
{
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/js/src/JSTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export default (new Transformer({
loc: convertLoc(dep.loc),
});
}
} else if (dep.kind === 'URL') {
} else if (dep.kind === 'Url') {
asset.addURLDependency(dep.specifier, {
loc: convertLoc(dep.loc),
});
Expand Down

0 comments on commit a72bc3b

Please sign in to comment.