Terra-core: Cannot find module 'intlLoaders' from 'intlLoaders.js'

Created on 9 Oct 2018  路  4Comments  路  Source: cerner/terra-core

Bug Report

Description

After modifying dependencies and re-running yarn install, jest tests break with the error

Cannot find module 'intlLoaders' from 'intlLoaders.js'
   at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
   at Object.<anonymous> (node_modules/terra-i18n/lib/intlLoaders.js:3:20)

This forces developers to run something like

rm -rf node_modules/terra-i18n/
yarn --check-files

to perform a re-install of the offending terra-i18n module.

While Terra seems to favor npm, this is cumbersome to workflows involving package updates. Here are two repos where this is occuring:
https://github.cerner.com/careaware-connect/blackcomb_server/
https://github.cerner.com/ibus-core-internal/careaware-deployer-react

This has been recurring off and on for months. This is most easily reproducible with the careaware-deployer-react repo. blackcomb_server doesn't fail as reliably.

Steps to Reproduce


  1. Clone repo
  2. yarn install
  3. yarn upgrade ___
  4. yarn jest
  5. Observe failure

Additional Context / Screenshots

Expected Behavior

Possible Solution

Environment

  • Component Name and Version: [email protected]
  • Browser Name and Version: N/A (Chrome 69.0.3497.100)
  • Node/npm Version: Node v8.11.3 / NPM 6.4.1
  • Webpack Version: N/A (4.19.0)
  • Operating System and version (desktop or mobile): Desktop
  • Yarn v1.10.1

@ Mentions

terra-i18n bug

All 4 comments

I've heard about this from another team but we we not able to come up with a reliable test case. This issue offers some more details to what steps seem to trigger the issue. The other team that was seeing this issue resolved it by running the aggregate-translations pre-build tool before running Jest tests.

We are planning to remove the post-install script that automatically writes the intlLoaders.js file, as relying on its existence via the post-install script is unreliable as evident by this logged issue.

When we remove the post-install script from terra-i18n, we'll be recommending teams run the aggregate-translations pre-build tool before running jests. We haven't landed on exactly how we want to roll this out to consumers yet. We may recommend doing it in a jest setup file, calling the aggregate-translations function from terra toolkit or we may recommend adding a pretest npm script that uses the aggregate-translations CLI script.

For now, I'd recommend take a look at one of those 2 options and see if it resolves the issues your running into.

Thanks for the detailed description & info @bjankord. A quick Github search for aggregate-translations in our internal Github indicates several projects are running this as part of jestSetup (or similar). The code below seems to have resolved this issue in our project.

jestSetup.js
import aggregateTranslations from 'terra-toolkit/scripts/aggregate-translations/aggregate-translations';
aggregateTranslations();

I've confirmed this by executing:

rm -rf node_modules/terra-i18n/lib/intlLoaders.js
yarn jest

We can use this strategy until a long-term strategy lands.

I ran into this same issue when changing some dependency versions. Running yarn --force fixes it for me (found this on https://github.com/cerner/terra-core/issues/1405#issuecomment-419142822).

This should be resolved with the latest release of [email protected] / [email protected]
For long term strategy, we recommend calling aggregate-translations pre-build script in a global jest setup file as described here if you are still seeing this issue occur.

Was this page helpful?
0 / 5 - 0 ratings