Skip to content

Commit

Permalink
chore: 🤖 add usage
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Sep 24, 2023
1 parent 50684e5 commit 0a2354a
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions crates/rspack_plugin_javascript/src/plugin/inner_graph_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,38 +249,22 @@ impl<'a> InnerGraphPlugin<'a> {
}

pub fn on_usage(&mut self, on_usage_callback: UsageCallback) {
// if self.is_enabled() {
// if let Some(symbol) = symbol {
// self
// .state
// .usage_callback_map
// .entry(symbol)
// .or_insert(vec![])
// .push(on_usage_callback);
// } else {
// on_usage_callback(Some(UsedByExports::Bool(true)));
// }
// } else {
// on_usage_callback(None);
// }
if self.is_enabled() {
if let Some(symbol) = self.get_top_level_symbol() {
self
.state
.usage_callback_map
.entry(symbol)
.or_insert(vec![])
.push(on_usage_callback);
} else {
on_usage_callback(self.dependencies, Some(UsedByExports::Bool(true)));
}
} else {
on_usage_callback(self.dependencies, None);
}
}

// pub fn on_usage_by_span(&mut self, symbol: Option<JsWord>, start: u32, end: u32) {
// self.on_usage(
// symbol,
// Box::new(|used_by_exports| {
// if matches!(used_by_exports, None | Some(UsedByExports::Bool(true))) {
// return;
// } else {
// // TODO usedByExports
// // self
// // .presentational_dependencies
// // .push(Box::new(PureExpressionDependency::new(start, end)));
// }
// }),
// )
// }

pub fn visit_class(&mut self, symbol: JsWord, class: &Class) {
self.set_top_level_symbol(Some(symbol.clone()));
for stmt in class.body.iter() {
Expand Down

0 comments on commit 0a2354a

Please sign in to comment.