Skip to content

Shared directory for all workspaces #311

Open

Description

@yanmandev

We use approximately the following directory structure in the project. And each workspace has a react-create-app.

  "bolt": {
    "workspaces": [
      "packages/*"
    ]
  }
project
└───packages
    │   cabinet
    │   landing

During the development process, a lot of code appears that is the same in all workspaces (for example, utils, api, constants). So I want to put the code at the top level and reuse it.

project
│   shared
│   │   utils
│   │   constants
│   │   apis
│
└───packages
    │   cabinet
    │   landing

I haven't found a working way to import shared code inside packages/{name} yet. Can someone share working solutions?
Thank you!!

Activity

  1. Emasoft commented on Jun 20, 2025

    @Emasoft

    You can simply import the shared code as packages. Like this:

    project
    └───packages
        │   cabinet
        │   landing
        |   utils
        |   constants
        |   apis
    

    Or, if you organize the shared code in a single shared utilities library:

    project
    └───packages
        │   cabinet
        │   landing
        |   shared_utils
    
  2. Yvem commented on Jul 12, 2025

    @Yvem

    @yanmandev Your repo structure looks good! To enable it: Isn't that why workspaces is an array?

      "bolt": {
        "workspaces": [
          "shared/*",
          "packages/*"
        ]
      }

    (if your repo is new, bolt is a bit outdated, I'd recommend yarn v4 or pnpm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions