It's not clear what you mean, but there should never be a case where you need 
to check in library code the import of the user code.

If your library has required dependencies, then your module should re-export 
them.

For example :
    
    
    # Package foo
    
    # src/foo/bar.nim
    proc bar*() = discard
    
    # src/foo.nim
    import bar
    
    proc foo*() = discard
    export bar # bar() is a
    
    # external user code
    import foo
    
    foo()
    bar()
    
    
    
    Run

Otherwise you can use `when compiles(...): doStuff()` to check at compile time 
if the module is present :
    
    
    # import std/re
    when compiles(re):
      echo "OK import re"
    else:
      echo "KO import re"
    
    import strutils
    when compiles(strutils):
      echo "OK import strutils"
    else:
      echo "KO import strutils"
    
    
    Run

But I really don't know why you would need this construct and this feels like a 
XY problem.

Reply via email to