How to use a workspace folder as package.json dependency?

I’m working on a project that requires the usage of a local dependency, which is present in the same repository under the folder “lib”, this dependency is referenced in the package.json as follows:

"dependencies": {
   "@myDep": "file:../lib"

However there’s a job that compiles and generates some files for the dependency in the lib folder, i have the following config for that job:

      - image: circleci/node:8.11.1
    working_directory: ~/root
      - checkout
      - attach_workspace:
          at: ~/root
      - run:
          name: Yarn install
          command: yarn install
          working_directory: lib/
      - run:
          name: Typescript Build
          command: yarn build
          working_directory: lib/
      - persist_to_workspace:
          root: ~/root
            - lib/

The issue here is that the Yarn install command, ends up using the old version of the “lib” folder (without the compiled files). How could i use the workspace version of lib as the real dependency to be installed with yarn install?