Project-relative `require`?

It’s not really as it appears. How I migrated Athena to a Monorepo...and you can too goes into things in more detail, but the gist of it is that all development happens within the monorepo, but then changes are synced out to read-only repo mirrors via git subtrees. This allows you to get the developmental benefits of a monorepo, while still adhering to the “one-shard-per-repo” requirement.

In regards to tests, they’re all still invoked on a per component basis. E.g. https://github.com/athena-framework/athena/blob/master/scripts/test.sh. So some sort of __ROOT__ const would still work.

Although I haven’t really run into a need for it too much. In the spec context I just require all my fixtures, helpers, and source code within spec_helper then require that one file in each spec versus the specific thing each test uses on its own.

A pipe dream of mine is having something like import - JavaScript | MDN, versus having require be global. But deff not something we’ll see soon, or ever ha.

EDIT: Which you can kinda replicate with like:

macro import(type)
  private alias {{type.stringify.split("::").last}} = {{type}}
end

import MyApp::SomeNamespace::Things::MyClass

pp MyClass.new

but :person_shrugging:, debatable of its usefulness, at least without proper IDE support and such.

7 Likes