DEV Community

Bithman
Bithman

Posted on

RN - Problem with dynamic imports

Hi, I need your help because I'm stuck with a problem.
I have an app built with react native 0.51, and I want to update to 0.60.4 version.
I have an error related with this piece of code:

// eslint-disable-next-line import/no-unresolved, import/extensions
import * as translations from '../**/i18n.js';

When I ran the app I have this error log:

BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [05/Aug/2019:15:19:02 +0000] "GET /index.bundle?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"
error: bundling failed: Error: Unable to resolve module ../**/i18n.js from /reactProject/CameraExample/src/config/i18n.js: The module ../**/i18n.js could not be found from /reactProject/CameraExample/src/config/i18n.js. Indeed, none of these files exist:

  • /reactProject/CameraExample/src/**/i18n.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • /reactProject/CameraExample/src/**/i18n.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) at ModuleResolver.resolveDependency (/reactProject/CameraExample/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15) at ResolutionRequest.resolveDependency (/reactProject/CameraExample/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (/reactProject/CameraExample/node_modules/metro/src/node-haste/DependencyGraph.js:283:16) at Object.resolve (/reactProject/CameraExample/node_modules/metro/src/lib/transformHelpers.js:264:42) at dependencies.map.result (/reactProject/CameraExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31) at Array.map () at resolveDependencies (/reactProject/CameraExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18) at /reactProject/CameraExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33 at Generator.next () at asyncGeneratorStep (/reactProject/CameraExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24) BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

The dynamics imports has changed in this version of RN?

Thanks in advance for your help

Regards
Flavio

Top comments (1)

Collapse
 
bithman profile image
Bithman

Hi, I resolve my problem.
I made this steps:

1) yarn add babel-plugin-import-glob
2)Verify in package.json this line: "babel-plugin-import-glob": "2.0.0",
3)Add in .babelrc this line:
"plugins": ["import-glob"]

Regards
Flavio