Skip to content

Conversation

cmwhited
Copy link
Collaborator

@cmwhited cmwhited commented Nov 7, 2024

Description

Updated the build pattern for each package to be same as graph-framework-utils to use vite to generate dist directory with es/cjs compiled files as well as exports declared in package.json.

This does mean that changes must be built first before seeing updates in implementing code (which is good and bad).

Let me know if y'all agree with this approach cc @nikgraf @pcarranzav

@cmwhited cmwhited requested a review from nikgraf November 7, 2024 23:01
@nikgraf nikgraf force-pushed the chris.whited/feat-shared-tsconfig branch 2 times, most recently from baedd9c to 4578eda Compare November 8, 2024 07:53
@nikgraf
Copy link
Collaborator

nikgraf commented Nov 8, 2024

I gave it a try, but this one concerns me a bit. Usually I aim for the following setup

  • During development I directly uses the source files. Typescript errors don't prevent the build in order to iterate fast
  • Builds are for production and fail once there is one Typescript error

The current setup:

  • Build work in the packages regardless of a Typescript error and it uses the build files
  • Unknown for me right now: Does this impact the stack traces or are source maps setup well enough

I'm open to switch over to this setup in general, but wondering if there is something even better and what are best practices. Would love to get @fubhy 's input (once he gets access to the repo) since he did a lot of that in the Effect repo.

Base automatically changed from chris.whited/feat-shared-tsconfig to main November 8, 2024 08:25
@nikgraf
Copy link
Collaborator

nikgraf commented Nov 8, 2024

@cmwhited I talked to @fubhy and he recommends the following:

  1. no build step for local development, but rather use proper references
  2. use tsc for building, which also means build should fail in case of an error. Building libs with vite he experienced that type definition files are sometimes not 100% correct (which for Effect was problematic). That said, they do a lot of manual steps to get everything setup correctly. We agreed that for our use-case building with vite is fine for now, but at some point later he will do a call with us and show us all the thing to do for a perfect set.

Regarding the dev setup: Do get it to work we should have a proper TypeScript composite project. Meaning correct setup of:

  • Project references
  • Path aliases

We can get inspired by the Effect repo. Here are some notable mentions:

  • https://github.com/Effect-TS/effect/blob/main/tsconfig.json includes all paths with tests and so on for the editor to pick it up.
  • https://github.com/Effect-TS/effect/blob/main/tsconfig.build.json on the other hand only cares about the build setups. This means each package has a separate build tsconfig https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.build.json
  • One thing that's annoying and requires manual work, but is important is to manually reference dependencies in the tsconfig of each package e.g. https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.build.json#L3-L7 & https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.src.json#L4-L8
  • There are several tsconfig
    • tsconfig.ts is for the editor (it includes src and test)
    • tsconfig.src.ts actual src
    • tsconfig.test.ts
    • tsconfig.build.ts only includes build and src references

What do you think about this approach?

@cmwhited
Copy link
Collaborator Author

cmwhited commented Nov 8, 2024

@cmwhited I talked to @fubhy and he recommends the following:

  1. no build step for local development, but rather use proper references
  2. use tsc for building, which also means build should fail in case of an error. Building libs with vite he experienced that type definition files are sometimes not 100% correct (which for Effect was problematic). That said, they do a lot of manual steps to get everything setup correctly. We agreed that for our use-case building with vite is fine for now, but at some point later he will do a call with us and show us all the thing to do for a perfect set.

Regarding the dev setup: Do get it to work we should have a proper TypeScript composite project. Meaning correct setup of:

  • Project references
  • Path aliases

We can get inspired by the Effect repo. Here are some notable mentions:

  • https://github.com/Effect-TS/effect/blob/main/tsconfig.json includes all paths with tests and so on for the editor to pick it up.

  • https://github.com/Effect-TS/effect/blob/main/tsconfig.build.json on the other hand only cares about the build setups. This means each package has a separate build tsconfig https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.build.json

  • One thing that's annoying and requires manual work, but is important is to manually reference dependencies in the tsconfig of each package e.g. https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.build.json#L3-L7 & https://github.com/Effect-TS/effect/blob/main/packages/cluster/tsconfig.src.json#L4-L8

  • There are several tsconfig

    • tsconfig.ts is for the editor (it includes src and test)
    • tsconfig.src.ts actual src
    • tsconfig.test.ts
    • tsconfig.build.ts only includes build and src references

What do you think about this approach?

I am fine with that approach. Going to close this PR and get the tsconfig setup then

@cmwhited cmwhited closed this Nov 8, 2024
@nikgraf
Copy link
Collaborator

nikgraf commented Nov 8, 2024

cool, thanks @cmwhited 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants