【问题标题】:Phoenix umbrella compile order凤凰伞编序
【发布时间】:2018-01-26 03:51:32
【问题描述】:

我有一个包含 3 个应用程序的总括项目:main_web、main 和 child。

我在main 中定义了一个宏,child 应用程序使用它。

编译时,有时会报错说Main.MyMacro 没有在some_file_in_child_app.ex 中定义,当我再次运行相同的命令时,一切正常。

我认为这是 some_file_in_child_app.ex 在编译之前尝试使用宏。

确保Main.MyMacro 已加载并避免此错误的好方法是什么?

我不确定继续运行 mix compile apps/main 是否正确

【问题讨论】:

    标签: macros elixir phoenix-framework


    【解决方案1】:

    如果您的伞式应用程序之间存在依赖关系,则需要明确列出它们。

    你应该把它添加到apps/child/mix.exs:

    def deps do
      [
        # ... other deps ...
        {:main, in_umbrella: true}
      ]
    end
    

    现在 Mix 将确保在编译 child 之前编译 main。

    【讨论】:

      猜你喜欢
      • 2018-09-01
      • 2019-10-17
      • 2022-01-24
      • 1970-01-01
      • 2017-09-15
      • 2016-01-30
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多