1
2
3
4
5
6
7
8
9
use anyhow::Error;
use swc_common::{FileName, Span};
use swc_ecma_ast::Expr;

/// Note: As this is rarely used, it's recommended to pass it as a trait object.
pub trait Hook: swc_common::sync::Sync + swc_common::sync::Send {
    /// Return [None] to preserve `import.meta.url`
    fn get_import_meta_url(&self, span: Span, file: &FileName) -> Result<Option<Expr>, Error>;
}