🔷 [Epic] Support BOS modules (libs)
Description
Developers need the ability to reuse logic between components without the substantial overhead of publishing an npm package.
This BOS post gives a great overview of the module support on the VM https://near.social/mob.near/widget/MainPage.N.Post.Page?accountId=sdks.near&blockHeight=109924527
Screenshot for archival:
We did not initially plan this feature for BWE since arbitrary dependencies could be considered a replacement for the module syntax, but that does not acknowledge the weight of the workflow change that would be required for a developer to publish packages there.
You should be able to develop, test, and publish your libs right alongside your components.
@andy-haynes I think it would make the most sense if this were special syntax for import that pulls from chain instead of esm.sh
i.e. import @near/michaelpeter.near/mylib.ts
I'd agree that this is a natural piece of functionality given the current implementation. For simple code libraries the use case is pretty straightforward, but things get complicated quickly when we consider stateful singletons or services decoupled from Components. In theory it's not a stretch to support more complex scenarios like this, since one can essentially accomplish the same thing as a HOC currently.
I'm particularly interested to explore what the concept of trust would mean for modules, given how tightly coupled it is to Components.