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

Initial refactor #944

Merged
merged 10 commits into from
Sep 27, 2022
Merged

Initial refactor #944

merged 10 commits into from
Sep 27, 2022

Conversation

AdityaHegde
Copy link
Collaborator

@AdityaHegde AdityaHegde commented Sep 23, 2022

Things in this PR,

  • Existing app inside web-local
  • Build, test and package point to web-local

@AdityaHegde AdityaHegde marked this pull request as ready for review September 23, 2022 10:56
Copy link
Contributor

@begelundmuller begelundmuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this come together! I went over the PR at a high level and left some inline comments. I also have a few extra questions:

  1. Why not put the (non-test) code in web-local/src instead of directly in web-local? That would also mirror how web-cloud is setup (basic Svelte layout)
  2. I see you moved to relative imports within the package instead of absolute paths. I don't have a strong preference, but curious to understand the motivation?
  3. Regarding (2.), there are a bunch of imports from $web-local/lib/ which are still absolute that remain to be converted

I'm sure there'll be loose ends to tie up different places, but the way I see it, we don't have to make it perfect in this PR. Just establishing the workspaces and making sure everything runs as before is the important step, then we can gradually tidy smaller things up in later PRs.

package.json Outdated Show resolved Hide resolved
tsconfig.json Outdated
Comment on lines 29 to 36
"$web-local/lib": ["web-local/lib"],
"$web-local/lib/*": ["web-local/lib/*"],
"$web-local/common": ["web-local/common"],
"$web-local/common/*": ["web-local/common/*"],
"$web-local/cli": ["web-local/cli"],
"$web-local/cli/*": ["web-local/cli/*"],
"$web-local/server": ["web-local/server"],
"$web-local/server/*": ["web-local/server/*"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use $ over @? And what do you think about prefix the paths with @rilldata for clarity? Like import { ... } from "@rilldata/web-common". (Prisma also does that: https://github.com/prisma/prisma/blob/main/tsconfig.build.bundle.json)

And is it necessary to duplicate each path with a /* variant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard to use $ instead of @ comes from sveltekit. Adding @rilldata will possibly conflicts with actual packages. I am not sure about the duplication, it was added by sveltekit init I believe (was present before i joined the old data-modeler).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that this can be explicitly changed.

Copy link
Contributor

@begelundmuller begelundmuller Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked a little more into this. @rilldata should be a scope that only we can publish to, so conflicts shouldn't be a problem.

The idea of using NPM workspaces is to treat each workspace as a separate package, but with the convenience of paths resolving locally instead of through NPM (many also appear to publish packages to NPM for external consumption). Check out these examples:

tsconfig.json Outdated Show resolved Hide resolved
@AdityaHegde
Copy link
Collaborator Author

Yes makes sense to move stuff to src directory. Regarding the imports, i am not sure why some are relative and some aren't. These were the result of just moving the files into the folder on webstorm.

@ericpgreen2
Copy link
Contributor

Nice to see this! Agree with all Benjamin's comments.

Regarding imports, there's a VSCode configuration for relative/absolute imports. I'm currently on the default setting "shortest", but maybe the "project-relative" setting is the right way to go. My only preference is for consistency. Is there something similar in WebStorm?

image

image

@AdityaHegde
Copy link
Collaborator Author

AdityaHegde commented Sep 26, 2022

Updating the aliases before moving code to src fixed the paths to use the aliases. I guess that was the issue initially, i updated the aliases after moving.

Regarding the setting for module import. I feel shortest is better. It would be pretty ugly when we import a file in the same directory with the project-relative.

Copy link
Contributor

@begelundmuller begelundmuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@AdityaHegde AdityaHegde merged commit a7976d3 into main Sep 27, 2022
@AdityaHegde AdityaHegde deleted the npm-workspaces branch September 27, 2022 12:00
djbarnwal pushed a commit that referenced this pull request Aug 3, 2023
* Initial refactor

* Fixing build and test

* Fixing local dev command

* Fixing vercel binary

* Moving files within src directory

* Moving to using @rilldata for module alias

* Fixing missing test data files

* Fixing npm publish
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.

4 participants