<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="283694" data-post-id="283694">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hst337" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hst337
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What exactly is the nature of these dependencies? Is it compile-time dependency (like your module can be called from schema module at compile time) or what?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283694" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/why-are-compile-time-dependencies-between-modules-transitive/54899/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-283694" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283694"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="283696" data-post-id="283696">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="japhib" data-post="11" data-topic="54899">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/japhib/48/23787_2.png" class="avatar"> japhib:</div>
<blockquote>
<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> Would the following optimization be possible in the Elixir compiler?</p>
</blockquote>
</aside>
<p>We already track these dependencies as export dependencies. Although I need more information/context than the small example above to understand how you propose them to be used.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283696" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/why-are-compile-time-dependencies-between-modules-transitive/54899/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-283696" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283696"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="283999" data-post-id="283999">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="japhib" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/japhib/120/23787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  japhib
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve working on putting together a minimal umbrella app that reproduces the issue, but it’s not as straightforward as I thought <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"> In the process, I’m learning about compile-time dependencies. Maybe I’ll be able to improve our situation by fixing some of the compile-time dependencies in our project.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283999" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/why-are-compile-time-dependencies-between-modules-transitive/54899/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-283999" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283999"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="284004" data-post-id="284004">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="japhib" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/japhib/120/23787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  japhib
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In the meantime, I do have a question – when running <code>mix compile</code>, it’s easy enough to see which files are getting compiled, with <code>--verbose</code> or <code>--profile=time</code>, but I can’t figure out how to tell <em>why</em> each file is getting recompiled. Is there any flag that would tell me something like that? For instance, something like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Module A being compiled because of changes
Module B being compiled because of runtime dependency on A
Module C being compiled because of compile-time dependency on B
...
</code></pre>
<p>Does such a compiler flag exist? If not, is there any chance you could point me to the general area in the Elixir codebase where I could add logs to try to deduce this myself?</p>
<p>(Note: I’m aware of <code>mix xref trace</code> and <code>mix xref graph</code> and have been using those tools to track down dependencies. However, even after changing certain dependencies from compile-time to run-time, certain files are still getting unexpectedly re-compiled on each change. The <code>xref</code> tools don’t show any dependencies between the files that would necessitate re-compilation, yet they’re getting recompiled anyway.)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="284004" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/why-are-compile-time-dependencies-between-modules-transitive/54899/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-284004" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="284004"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="284028" data-post-id="284028">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="axelson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/axelson/120/26351_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  axelson
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Scenic Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="japhib" data-post="15" data-topic="54899">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/japhib/48/23787_2.png" class="avatar"> japhib:</div>
<blockquote>
<p>Does such a compiler flag exist? If not, is there any chance you could point me to the general area in the Elixir codebase where I could add logs to try to deduce this myself?</p>
<p>(Note: I’m aware of <code>mix xref trace</code> and <code>mix xref graph</code> and have been using those tools to track down dependencies. However, even after changing certain dependencies from compile-time to run-time, certain files are still getting unexpectedly re-compiled on each change. The <code>xref</code> tools don’t show any dependencies between the files that would necessitate re-compilation, yet they’re getting recompiled anyway.)</p>
</blockquote>
</aside>
<p><code>mix xref graph</code> is the main tool for tracking down compile-time dependencies.</p>
<p>If you haven’t seen it <a href="https://medium.com/multiverse-tech/how-to-speed-up-your-elixir-compile-times-part-2-test-your-understanding-f6ff3de5eb5d" rel="nofollow">https://medium.com/multiverse-tech/how-to-speed-up-your-elixir-compile-times-part-2-test-your-understanding-f6ff3de5eb5d</a> is a great article that really walks you through what causes a compilation dependencies, including the surprising/tricky bit about transitivity.</p>
<p>Another tool you could try is DepViz, which I wrote when I encountered the same pain that you’re encountering: <a href="https://forum.elixirforum.com/t/depviz-a-visual-tool-to-understand-inter-file-dependencies/35408/5" class="inline-onebox" rel="nofollow">DepViz - A visual tool to understand inter-file dependencies - #5 by axelson</a></p>
<p>DepViz will give you a view similar to what you’re asking for. Imagine you’re trying to figure out why <code>create_connection.ex</code> is recompiled, you hover over that file:<br>
</p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/9/b/9b740b6ec93ed61a7d421f1d955bbf56502d06af.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/9b740b6ec93ed61a7d421f1d955bbf56502d06af" title="image" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/9/b/9b740b6ec93ed61a7d421f1d955bbf56502d06af_2_571x600.jpeg" alt="image" data-base62-sha1="mbcDd9Ok7RbLltdgwL52SIqxCHl" width="571" height="600" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/9/b/9b740b6ec93ed61a7d421f1d955bbf56502d06af_2_571x600.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/9/b/9b740b6ec93ed61a7d421f1d955bbf56502d06af_2_856x900.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/9/b/9b740b6ec93ed61a7d421f1d955bbf56502d06af_2_1142x1200.jpeg 2x" data-dominant-color="EDE9EC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1200×1260 79.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>From that you can see that there’s 16 files that will cause <code>create_connection.ex</code> to be recompiled. Of those, 3 are direct dependencies, but 15 of them are transitive dependencies via the compile-time dependency on <code>command.ex</code><br>
(side-note: something is not quite right in the math there! Probably the other two top-level files are being double-counted because there’s a comptile-time dependency loop)</p>
<p>If you want to dig further into how a specific file is reached via <code>command.ex</code> then first click on <code>create_connection.ex</code>, then click on a file (e.g. <code>write_local_name.ex</code>):</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/7/7/77d61944a22e31b9d32c442d38102e56f4fb11e3.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/77d61944a22e31b9d32c442d38102e56f4fb11e3" title="image" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/3X/7/7/77d61944a22e31b9d32c442d38102e56f4fb11e3.jpeg" alt="image" data-base62-sha1="h67wrICyY1njkMyW2NpiSthXKcH" width="690" height="412" data-dominant-color="EDEAEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1200×718 44.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>From that we can now see that there is the dependency chain:</p>
<ul>
<li><code>create_connection.ex</code></li>
<li><code>command.ex</code></li>
<li><code>write_local_name.ex</code></li>
</ul>
<p>Where <code>create_connection.ex</code> depends on <code>command.ex</code> at compile-time, and <code>command.ex</code> depends on <code>write_local_name.ex</code> (at compile-time as indicated by the red dotted lines, although a run-time dependency between these two files would also create a transitive compile-time dependency for <code>create_connection.ex</code>).</p>
<p>I hope this helps you track down your compile-time dependencies!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="284028" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/why-are-compile-time-dependencies-between-modules-transitive/54899/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-284028" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="284028"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>