-
Notifications
You must be signed in to change notification settings - Fork 17
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
chore: replace local module with shared folder #1144
Conversation
e0fa59b
to
2e85a11
Compare
2e85a11
to
e0c461e
Compare
* develop: refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153) feat: add unit tests for error states in critical workflows (#1118) feat: support whitelisting domains through `agencies` table (#1141) feat: add tests for happy paths in critical workflows (#1110) fix: prevent campaign names from causing dashboard rows to overflow (#1147) fix(email): Fix SendGrid fallback integration (#1026)
Removed npm test:watch as we can just use npm t -- --watch instead. Did this to avoid duplicating pretest step.
script: | ||
- npm run build |
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.
Could you help explain why we didn't need the build step previously but have included it now? I guess its to build the shared module, but where was the backend being built previously
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.
Yep - this is to build the shared module. Previously there was not need to separate build the backend because npm test
handles it. However, ts-jest
does not automatically compile project references.
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.
Tested the following and lgtm
- All tests for backend and frontend passes
- Deploys successfully on backend and frontend
- Hot reload works for the shared module
Need to resolve merge conflicts
* develop: chore: replace local module with shared folder (#1144) 1.24.0
Problem
Closes #1139
Solution
Use Typescript project references to reference shared module
I've chosen to take a slightly different approach to referencing the shared module in
tsconfig
as compared to the vaccinegovsg-clinic repository. Instead of adding the shared folder path in theinclude
option, I've chosen to make use of project references instead.The main advantage for this approach is that we can avoid having to manually keep in sync the dependencies for the
shared
folder and the other modules. For example, if we were to use theinclude
approach, thexss
library has to be in each of thepackage.json
forbackend
,frontend
andworker
. Keeping all the differentpackage.json
in sync is a non-trivial problem and is prone to developer error.The drawback of this approach is that we have to manually
npm install
inside the shared folder to install its dependencies. The necessary changes to.travis.yml
and the respectiveDockerfile
have been made.Manually patch
moduleNameMapper
rather than usealiasJest
The default
aliasJest
function provided by react-app-rewire-alias does not work for our setup. The main reason for this is that the library assumes that our aliases would follow the pattern ofmodule/submodule
. However, there are quite a number of instances in our code that references aliases directly without a submodule (e.g.import config from 'config'
).Tests
Apart from changing the structure of the code, this PR should not modify or introduce any behaviour. To verify that everything works as expected:
In addition, hot reload should also work now for the shared module. Changing code in the shared module should automatically trigger a recompilation for any other module depending on it.