Skip to content

Commit

Permalink
feat: chunkGraph.getModuleId
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Dec 12, 2024
1 parent bd04c60 commit ff9c023
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/rspack_binding_values/src/chunk_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ptr::NonNull;

use napi::Result;
use napi_derive::napi;
use rspack_core::{Compilation, SourceType};
use rspack_core::{ChunkGraph, Compilation, SourceType};

use crate::{JsChunk, JsChunkWrapper, JsModule, JsModuleWrapper};

Expand Down Expand Up @@ -118,4 +118,13 @@ impl JsChunkGraph {
.collect(),
)
}

#[napi]
pub fn get_module_id(&self, js_module: &JsModule) -> napi::Result<Option<&str>> {
let compilation = self.as_ref()?;
Ok(
ChunkGraph::get_module_id(&compilation.module_ids, js_module.identifier)
.map(|module_id| module_id.as_str()),
)
}
}

0 comments on commit ff9c023

Please sign in to comment.