# How to declare compilation dependencies manually?

**URL:** <https://racket.discourse.group/t/how-to-declare-compilation-dependencies-manually/2049>\
**Category:** Questions & Answers\
**Created:** [June 28, 2023, 1:01pm UTC](https://racket.discourse.group/t/how-to-declare-compilation-dependencies-manually/2049 "2023-06-28T13:01:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shhyou](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@shhyou](https://racket.discourse.group/u/shhyou)\
**Post date:** [June 28, 2023, 1:01pm UTC](https://racket.discourse.group/t/how-to-declare-compilation-dependencies-manually/2049/1 "2023-06-28T13:01:11Z")

</div>

How can I declare a (module) dependency manually without `require`ing it?

I have found the function [register-external-module](https://docs.racket-lang.org/raco/cm-accomplice.html#%28def._%28%28lib._compiler%2Fcm-accomplice..rkt%29._register-external-module%29%29), but it only adds an additional dependency _after_ the code has been compiled. In other words, the new dependencies work only after re-compilation.

Here is an example code that demonstrates the problem:

```plaintext
;; main.rkt
#lang racket/base
(require (for-syntax racket/base compiler/cm-accomplice))
(define-syntax (ghost-require stx)
  (syntax-case stx ()
    [(_ relative-path)
     (register-external-module (path->complete-path (syntax-e #'relative-path)))
     #'(begin)]))

(ghost-require "ext.rkt")

```

I hope that compiling `main.rkt` using `raco make` would trigger the compilation of `ext.rkt`, while instantiating `main.rkt` itself would not load or instantiate `ext.rkt`. Is this possible? With `ghost-require`, I need to compile `make.rkt` twice to actually compile `ext.rkt`.

```scheme
$ raco make -v main.rkt 
"main.rkt":
  making #<path:...cm/main.rkt>
 [output to "compiled/main_rkt.zo"]
$ ls compiled 
main_rkt.dep main_rkt.zo
$ raco make -v main.rkt 
"main.rkt":
  making #<path:...cm/ext.rkt>
  making #<path:...cm/main.rkt>
 [output to "compiled/main_rkt.zo"]
$ ls compiled 
ext_rkt.dep ext_rkt.zo main_rkt.dep main_rkt.zo
$ 

```

---

<div class="post-metadata">

**Author:** ![Laurent.O](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/laurent.o/32/18_2.png) [@Laurent.O](https://racket.discourse.group/u/Laurent.O)\
**Post date:** [June 28, 2023, 1:11pm UTC](https://racket.discourse.group/t/how-to-declare-compilation-dependencies-manually/2049/2 "2023-06-28T13:11:13Z")

</div>

i'm not sure this fits all your requirements, but maybe a submodule could help, such as

```plaintext
(module compile-deps racket/base (require "ext.rkt"))

```

This will make `ext.rkt` a dependency of `main.rkt`, but instantiating the latter should not instantiate the former I guess?
