fix(web) restore type checking for production build #1625
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Yesterday we found that production build was failing at OBS because type checking. See #1623.
There were some valid complaints because of wrong reference and missing @testing-library/dom dependency overlooked during latest migration to latest dependencies versions #1612 However, the build was failing with a bunch of unexpected errors that were not thrown neither on CI nor in our development environments.
Unexpected because claimed children were actually there, but as nested JSX nodes instead of regular
prop
. Remember,This made us suspect about
@types/react
where a type definition hinting TypeScript about such an special prop is expected. However, since we have no clue about those React advanced types and were in a hurry, we took the shortcut to temporary disable the type checking in order to get the production build working again.Further investigation shows we were on the right track since the issue only occurs when
@types/react
isn't present. The OBS build is using--legacy-peer-deps
, which does an slightly different dependencies installation.Now, we were able to reproduce the issue faced at OBS.
Solution
The fix is quite simple and clear: to explicitly add the
@types/react
dev dependency. But this PR adds@types/react-dom
too, to avoid similar silly build issues.Testing
To make sure this is the right fix, below tests has been performed against
master
branch after restoring the type checking for production build (transpileOnlye: development
at webpack config file).NODE_ENV=production npm run build
does not fail (because@types/react
dep is present)node_modules
and run annpm install --legacy-peer-deps
: theNODE_ENV=production npm run build
fails (because@types/react
is not present)@types/react
dev dep explicitly (npm install -D @types/react
)node_modules
and run annpm install --legacy-peer-deps
again: theNODE_ENV=production npm run build
ends successfully.Open questions
Should CI been updated for using the same
npm install
flags than OBS in an attempt to try catching these issues soon?A bit unrelated with this: should we try to go ahead without
babel-loader
? It still there after start using TypeScript becauseBut maybe we could re-evaluate if we actually need both or could use
ts-loader
only instead. If so, please be aware of https://github.com/TypeStrong/ts-loader?tab=readme-ov-file#faster-builds and https://github.com/TypeStrong/fork-ts-checker-webpack-plugin