react / react/metro

bundling failed: ReferenceError: SHA-1 for file .../node_modules/lodash.zip is not computed

Open
#441 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
Including lodash.zip as a dependency in my React-Native project causes the following error to be thrown by the metro bundler:

error: bundling failed: ReferenceError: SHA-1 for file /my_project_dir/node_modules/lodash.zip (/my_project_dir/node_modules/lodash.zip) is not computed
    at DependencyGraph.getSha1 (/my_project_dir/node_modules/metro/src/node-haste/DependencyGraph.js:259:13)
    at /my_project_dir/node_modules/metro/src/DeltaBundler/Transformer.js:211:26
    ...

My guess is that because the folder in node_modules for this particular dependency happens to be called something with '.zip' in it (lodash.zip), the bundler erroneously thinks that it is some sort of .zip file that it needs to check.

I am using metro version 0.54.1 which is the version used in the latest version of React-Native (0.60.4).

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

  1. Be in any React-Native project using RN 0.60.4 (metro version 0.54.1)
  2. yarn add lodash.zip
  3. react-native run-android
  4. Observe error described above.

What is the expected behavior?
The metro bundler should not fail bundling.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Metro configuration:

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

Metro version: 0.54.1
node: 12.4.0
yarn: 1.13.0
operating system: macOS Mojave 10.14.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SHA-1 lookup in node_modules/metro/src/node-haste/DependencyGraph.js and the caller in node_modules/metro/src/DeltaBundler/Transformer.js. Reproduce the failure by adding lodash.zip to a React Native 0.60.4 project and running react-native run-android. Done means Metro bundles the project without the ReferenceError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.