bos-web-engine icon indicating copy to clipboard operation
bos-web-engine copied to clipboard

🔷 [Epic] Support BOS modules (libs)

Open mpeterdev opened this issue 2 years ago • 3 comments

Description

Developers need the ability to reuse logic between components without the substantial overhead of publishing an npm package.

mpeterdev avatar Jan 12 '24 16:01 mpeterdev

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: Screenshot 2024-01-12 at 11 15 09 AM

mpeterdev avatar Jan 12 '24 16:01 mpeterdev

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

mpeterdev avatar Jan 12 '24 16:01 mpeterdev

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.

andy-haynes avatar Feb 02 '24 19:02 andy-haynes