-
Notifications
You must be signed in to change notification settings - Fork 44
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
removed tsc-alias #6796
base: master
Are you sure you want to change the base?
removed tsc-alias #6796
Conversation
@kurtisassad I was expecting this PR to have a bunch of import renames and removing the "*" path in
The purpose of |
@Rotorsoft It seems that we actually didn't need tsc-alias as the backend builds fine without it. We had never used that type of * alias on the backend (It is only used on the frontend, but webpack handles it, not tsc-alias). I see what you are saying about the aliases on the backend though. These can be fixed in a subsequent PR in order to separate the concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't remove tsc-alias
if we don't first remove "*": ["./*", "shared/*", "client/scripts/*"]
from paths. The current implementation breaks on deployment since paths like /server/...
or /shared/...
will pass type-checks + build but fail when executed. Additionally, even if we refactor existing instances of such imports, the paths property in the tsconfig allows for new imports using such patterns which would again break when deployed.
To replicate the above error you need to run server.js
not server.ts
(see Procfile).
c7765f1
to
f62d050
Compare
Ah nvm, was running start-external-webpack, which doesn't run the exact production build since it still runs server.ts, not the js variant |
f6421e8
to
d3c5797
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in my previous review, removing the tsc-alias
dependent imports does make the build work but merging this is dangerous since future tsc-alias
dependent imports are still allowed. As such we could accidentally deploy a broken build without realizing it because we don't run server.js
in testing/CI.
@timolegros I added in a tsconfig for the server to override this so that it throws an error if we use this pattern on the server. The issue from a full refactor is that the client uses this pattern a lot, it will be a huge refactor. Anyways with these minimal changes the tsc-alias is no longer needed, because webpack handles the recursive imports on the client side. |
@@ -4,7 +4,7 @@ | |||
"private": true, | |||
"scripts": { | |||
"add-component-showcase": "npx ts-node -T ./scripts/add-component-showcase.ts", | |||
"build": "tsc -b && tsc-alias", | |||
"build": "tsc -b", | |||
"clean": "rm -rf build", | |||
"check-types": "tsc --noEmit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (check-types
) would use the packages/commonwealth/tsconfig.json
config so it would pass with the bad imports no? Likely need to temporarily have 2 tsc --noEmit
checks here -> one for the client and one for the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so this might be a problem. Basically we don't get any build errors from adding these imports, but we do get editor visual errors:
The only issue with having a separate check-types is that tsc won't actually work because the folder that you are type checking are not allowed to have imports outside the root (In this case we have server importing modules from other packages like @hicommonwealth/core). So I am not sure the solution for this one. Maybe its better just to settle for the editor errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kurtisassad per convo we should definitely not settle for editor errors. I'm not exactly sure what the solution is here but we should hop in a huddle with @Rotorsoft and figure this out this week.
# Conflicts: # packages/commonwealth/main.ts # packages/commonwealth/server/routes/communities/get_communities_handler.ts
# Conflicts: # packages/commonwealth/main.ts # packages/commonwealth/package.json # packages/commonwealth/server/controllers/server_comments_methods/search_comments.ts # packages/commonwealth/server/controllers/server_communities_methods/search_communities.ts # packages/commonwealth/server/routes/profiles/search_profiles_handler.ts # packages/commonwealth/server/util/queries.ts # packages/commonwealth/test/integration/api/index.spec.ts
# Conflicts: # packages/commonwealth/server/routes/viewGlobalActivity.ts
@kurtisassad I created an import from |
@timolegros are you considering the type checking discussed here in #7407 ? |
Some conflicts |
Setting back to draft pending conficts. |
@kurtisassad what happened with this PR? |
Link to Issue
Closes: #6362
Description of Changes
Test Plan
Run build of commonwealth via(Side note, this doesn't work because it runs the .ts file instead of the .js)yarn build && yarn bundle && yarn start-external-webpack
and ensured it ran correctly.yarn build && cd packages/commonwealth && NODE_ENV=production NODE_OPTIONS=--max-old-space-size=$(../../scripts/get-max-old-space-size.sh) node --enable-source-maps ./build/server.js
and ensured it ran correctly.node ./build/index.js
(dev experience)