Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider moving away from using workspaces #141

Closed
bitzoic opened this issue Apr 20, 2023 · 0 comments · Fixed by #224
Closed

Consider moving away from using workspaces #141

bitzoic opened this issue Apr 20, 2023 · 0 comments · Fixed by #224
Assignees
Labels
Improvement Enhancing a feature that already exists Repo Misc General repository upkeep

Comments

@bitzoic
Copy link
Member

bitzoic commented Apr 20, 2023

Motivation

Description

Issue

The sway-libs repository currently uses workspaces to organize each library. This separates each library into its own project and allows for each library to be imported using only the library name. This does however comes with a major downside, being that each library must be imported individually.

For example, here we would like to use 3 different libraries; StorageString, String, and Ownership. Adding these as dependencies would look like the following:

[dependencies]
string = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.8.1" }
ownership = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.8.1" }
storage_string = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.8.1" }

Our Sway contract would then import these as so:

contract;

use string::String;
use storage_string::StorageString;
use ownership::owner;

Proposed Change

Instead, if we organize the repository akin to the std lib with a root Forc.toml file, we would have the following dependencies and imports:

[dependencies]
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.8.1" }
contract;

use sway_libs::{string::String, storage_string::StorageString, ownership::owner};

Motivation

As more libraries are introduced, it may make sense to move away from workspaces to reduce the number of individual imports.

@bitzoic bitzoic added Improvement Enhancing a feature that already exists Repo Misc General repository upkeep labels Apr 20, 2023
@bitzoic bitzoic changed the title Considerer moving away from using workspaces Consider moving away from using workspaces Apr 27, 2023
@bitzoic bitzoic self-assigned this Mar 26, 2024
bitzoic added a commit that referenced this issue Mar 29, 2024
## Type of change

<!--Delete points that do not apply-->

- Improvement (refactoring, restructuring repository, cleaning tech
debt, ...)

## Changes

The following changes have been made:

- All imports have changed from multiple imports to a single imports
using the following:
```sway
libraries = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.4.0" }
```
From there your desired library may be imported:
```sway
use libraries::ownership::only_owner;
```

- Many of the primary functions have been moved out of the library's
folder. The documentation for this will be moved into a book in a follow
up PR.
- There are a number of private modules that are now exposed until
FuelLabs/sway#5765 is resolved.

## Notes

- This should get `forc doc` to produce a single document containing all
libraries rather than multiple documents for each library.

## Related Issues

<!--Delete everything after the "#" symbol and replace it with a number.
No spaces between hash and number-->

Closes #141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Enhancing a feature that already exists Repo Misc General repository upkeep
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant