       @phoenix_pipeline nil
       Phoenix.Router.Scope.init(__MODULE__)
       @before_compile unquote(__MODULE__)
+    end
+  end
+
+  # Because those macros are executed multiple times,
+  # we end-up generating a huge scope that drastically
+  # affects compilation. We work around it then by
+  # defining the add_route definition only once and
+  # simply calling it over and over again.
+  defp defs() do
+    quote unquote: false do
+      var!(add_route, Phoenix.Router) = fn route ->
+        exprs = Route.exprs(route)
+        @phoenix_routes {route, exprs}
+
+        defp match(var!(conn), unquote(route.verb), unquote(exprs.path),
+                   unquote(exprs.host)) do
+          unquote(exprs.dispatch)
+        end
+      end
     end
   end
 

  defmacro __using__(_) do
    quote do
      unquote(prelude())
      unquote(plug())
    end
  end

  end

  defp add_route(verb, path, controller, action, options) do
    quote do
      var!(add_route, Phoenix.Router).(
        Scope.route(__MODULE__, unquote(verb), unquote(path), unquote(controller),
                                unquote(action), unquote(options))
      )
    end
  end

