Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe_through [SomePlugModule] should not introduce a compile-time dependency #4408

Closed
marcandre opened this issue Aug 10, 2021 · 2 comments
Closed

Comments

@marcandre
Copy link
Contributor

marcandre commented Aug 10, 2021

Environment

$ elixir -v 
Erlang/OTP 24 [erts-12.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.12.1 (compiled with Erlang/OTP 22)
  • Phoenix version (mix deps): 1.5.10

Expected behavior

  scope "/", HelloWeb do
    pipe_through [:browser, HelloWeb.Plugs.SomePlug]
    # ...

This should not creates a compile-time dependency to the file where SomePlug is defined but it does:

    $ mix xref graph --source lib/hello_web/router.ex --label=compile
    lib/hello_web/router.ex
    ├── lib/hello_web.ex (compile)
    ├── lib/hello_web/plugs/some_plug.ex (compile)
    └── lib/hello_web/telemetry.ex (compile)

Note that the equivalent code below does not create such a compile-time dependency:

  pipeline :some_pipe do
    plug HelloWeb.Plugs.SomePlug
  end

  scope "/", HelloWeb do
    pipe_through [:browser, :some_pipe]
    # ...
$ mix xref graph --source lib/hello_web/router.ex --label=compile
lib/hello_web/router.ex
├── lib/hello_web.ex (compile)
└── lib/hello_web/telemetry.ex (compile)

Basic project showing this: with compile-time dependency and without (marcandre/basic_phoenix@916e769)

@marcandre
Copy link
Contributor Author

Let me know if I should make a PR for this

@marcandre
Copy link
Contributor Author

marcandre commented Aug 10, 2021

Confirmed still present in master as of today (0da9b5c)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant