Skip to content

[Tracking Issue] Share code between sides #725

@Tobbe

Description

@Tobbe

I'm going to spend some time working on sharing code between the web and the api side.
Opening this issue to track the progress

This is what needs to work:

  • yarn cedar g package <name>
    • Updates the root package.json file (feat(cca): Use modern workspace config #751 was a prerequisite for this)
    • Writes generic tsconfig, package.json, etc files for a package
    • Runs yarn install to let yarn know about the new package
    • Runs yarn build to make it possible to start using the package right away
      • Update this to leverage yarn cedar build <packageName> when possible
  • When running yarn cedar dev both the web and api sides can import and use the code in the package
  • When running yarn cedar dev HMR works for both the web and api sides
  • When building and then running yarn cedar serve, both the web and api sides can import and use the code
  • When deploying, the shared code is properly built on the deploy provider's side
    • Docker
    • Serverless (i.e. Netlify)
    • Baremetal
  • Unit testing works
    • api code that uses shared code
    • web code that uses shared code
    • tests specifically for the shared code only
  • yarn cedar upgrade also updates packages with the new version of Cedar packages
  • yarn cedar dev, yarn cedar test and other cli commands works inside package directories
  • It's possible to tweak the templates used for new packages (chore(cli): Refactor template handling in generators #761 and feat(cli): Custom script templates #813 were prerequisites for this)
  • git should ignore tsbuildinfo files
    • Update templates' .gitignore files
    • Make the package generator update .gitignore if needed
  • Document the new shared code feature
    • General "shared code" docs
    • Cedar CLI docs
  • Update yarn cedar build
    • To build all packages (in addition to web and api) when run without arguments
    • To allow passing a package name to build only that package

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