daniel-samson / typefs

💾 The single way to manipulate files in NodeJS.
https://typefs.io
MIT License
1 stars 0 forks source link

Feature request: Split drivers into npm packages #210

Closed daniel-samson closed 1 year ago

daniel-samson commented 1 year ago

Is your feature request related to a problem? Please describe.

Problem 1:

Adding additional drivers drastically increases the bundle size. Which means that consumers of typefs still have to download the drivers which may not be using. It also means that this will be loaded into consumer apps, increasing the memory requirements each time we add a new driver.

Problem 2:

We need to be able to develop drivers in separate npm packages. So we can use the Storage.registerDriver feature to register only the drivers we are interested in. Thus keeping typefs performant and robust. It also lets us create experimental drivers, which can be battle tested before adding them to typefs.

Problem 3:

We need to keep the code quality, and quality assurance for each package, so that consumers can trust that we will not break their code.

Describe the solution you'd like

Create a new package called typefs-registry, which acts like a disk driver registry. Then move the following types/interfaces into the typefs-registry package:

so that we can develop drivers that share the common interfaces and do not need to have all the dependencies from all the drivers installed to work.

The TDiskDriver may be need to be redefined as DiskDriver in order to make it abstract enough to pass typescript checks.

The s3 driver should (eventually) be moved into a package called typefs-s3.

Describe alternatives you've considered

Bundling the drivers in the typefs package, would be ideal if you don't want to have to npm install and register the all the drivers. Perhaps we could make a meta package like typefs-kichen-sink, that just has all the drivers included.

Additional context

Only the file driver should be packaged in typefs. The S3 driver should remain in typefs until version 2.0 but it should be marked as deprecated, and moved in to a separate npm package. The deprecated message must inform consumers to npm install typefs-s3 and register the driver. Perhaps we should also add a log message in the s3 driver CallableFunction in config.ts, to inform consumers how to migrate to the new convention, when they use the build in version of s3. However we need to be careful that we don't spam stderr or stdout. One message should be logged per process execution.