Page MenuHomePhabricator

TypeError: require.context is not a function
Closed, ResolvedPublicBUG REPORT


Steps to replicate the issue (include links if applicable):

  • Clone the latest repo, where we have files for testing.
  • Run npm run test, to test the functionality.
  • You will see the build failed.

What happens?:
Jest does not recognise webpack functions, and throws the error for the same.

What should have happened instead?:
Test should have run, and build should have been success.

Other information (browser name/version, screenshots, etc.):

Screenshot 2023-04-03 at 12.48.38.png (784×1 px, 395 KB)

Event Timeline

One solution to this can be to configure webpack, by running all the scripts seperately.
Another approach can be to shift from CRA to vite, which removes Webpack from the scene entirely.
Will see if this works out Migrate from CRA

this shall be closed by
as we will be using Vite instead of CRA, and so will be moving away from Webpack bundler to Rollup

This is now resolved, as we have migrated to Vite, which does not use Webpack behind the scenes :)