deep-foundation / deeplinks

https://discord.gg/deep-foundation
The Unlicense
14 stars 9 forks source link

deep.import aka bundler #262

Open Konard opened 1 year ago

Konard commented 1 year ago
(Package Bundle SyncTextFile)

When we use

await deep.import('package');

It looks to the database for the package of specific version, if it does not exist than bundle is created and stored in SyncTextFile link. If it exists the JavaScript code is loaded and passed through an eval, that gets a way to import a package.

It should be supported in async handlers: https://github.com/deep-foundation/js-docker-isolation-provider/blob/27d585214a7110d19ae0d110463b96506c30abe7/index.ts#L28 And it also should be supported in client handlers: https://github.com/deep-foundation/deepcase/blob/f5563dd72ffabcb8cd1710a5dd43374899a7a5d0/imports/client-handler.tsx#L201

To preserve backwards compatibility it can be added only as last resort than no over ways to import the package work.

Example of bundling function can be found here: https://github.com/deep-foundation/deeplinks/tree/main/bundles

Maybe we should support it on (Any Install PackageQuery) instance creation.

The code to modify in that case can be placed somewhere here: https://github.com/deep-foundation/npm-packager/blob/50b860d7e40ae5c877f62512518a3add09de4b5d/handlers/install-code.ts#L1-L285

Maybe we should also support deep.import in sync handlers. For sync-handlers we can install only those packages that are installed in the system.

For client and async handlers we can create a “can automatically install” permission rule. And by default all: sync, async, client handlers can use packages that were installed by admin. And now it will be possible to install not only deep packages.

Konard commented 7 months ago

@ivansglazunov do you have any objections?