🚇 The JavaScript bundler for React Native. https://facebook.github.io/metro
Go to file
James Ide bb93e339fa Use `error.message` to set the `description` property of a nested error payload
Summary:
Depends on #124.

 ---

**Summary**
Metro reports errors using a JSON payload that has an `errors` array. Each item in this array has a `description` field. For transform errors, this field was set using the value in `error.description` -- however, JS Error objects only have a `message` field. (Grepping the Metro code, no errors (except in one test) ever get a `description` field.) This commit uses `error.message` instead of `error.description` when creating JSON payloads.

```
$ git grep description -- 'packages/**/*.js'
packages/metro/src/JSTransformer/__tests__/Transformer-test.js:        babelError.description = message;
packages/metro/src/lib/formatBundlingError.js:    description: string,
packages/metro/src/lib/formatBundlingError.js:): {type: string, message: string, errors: Array<{description: string}>} {
packages/metro/src/lib/formatBundlingError.js:      errors: [{description: message}],
packages/metro/src/lib/formatBundlingError.js:        description: error.message,
packages/metro/src/node-haste/__tests__/Module-test.js:  description: "A require('foo') story",
```

**Test Plan**
Added a unit test to check that the description field is set for transform errors (with the delta bundler).

Also in a test RN app, inspected the error payload that is received by RN when there's a syntax error with HMR turned on and verified that `data.body.errors[0].description` was set.
Closes https://github.com/facebook/metro/pull/125

Differential Revision: D6730671

Pulled By: rafeca

fbshipit-source-id: 58311462db9223d65580d77748203d8ea0ea1ac7
2018-01-16 17:14:32 -08:00
.github Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
docs Copypasta / typo 2018-01-05 13:42:53 -08:00
flow-typed Rename `BabelRawMapping` to `BabelSourceMapSegment` 2018-01-12 04:23:40 -08:00
packages Use `error.message` to set the `description` property of a nested error payload 2018-01-16 17:14:32 -08:00
scripts Add babel version to build output 2018-01-15 07:29:29 -08:00
website Fix Get started and Learn more button links on the index page 2018-01-13 13:58:46 -08:00
.babelrc fix support for node v4 2017-06-26 05:08:50 -07:00
.eslintignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.eslintrc.js Consolidate eslint config + fix some issues 2017-12-11 12:32:20 -08:00
.flowconfig @allow-large-files [flow] deploy flow 0.60 2017-12-04 13:30:30 -08:00
.gitignore Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
.npmignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.travis.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
CHANGELOG.md Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT.md 2017-11-22 02:58:16 -08:00
CONTRIBUTING.md Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
LICENSE Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
PATENTS Rename metro-bundler to metro 2017-11-30 11:56:25 +00:00
README.md dropthe 2018-01-08 03:38:32 -08:00
appveyor.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
circle.yml Add script to automatically deploy the website 2017-11-30 04:03:29 -08:00
lerna.json Bump metro to v0.24.4 2018-01-12 09:18:09 -08:00
package.json Upgrade Jest to 22.0.5 2018-01-10 08:58:23 -08:00
yarn.lock Fix RN redbox messages for syntax errors by including error messages in payload 2018-01-16 17:14:32 -08:00

README.md

Metro

CircleCI Build Status npm version

🚇 The JavaScript bundler for React Native.

  • 🚅 Fast: We aim for sub-second reload cycles, fast startup and quick bundling speeds.
  • ⚖️ Scalable: Works with thousands of modules in a single application.
  • ⚛️ Integrated: Supports every React Native project out of the box.

This project was previously part of the react-native repository. In this smaller repository it is easier for the team working on Metro Bundler to respond to both issues and pull requests. See react-native#13976 for the initial announcement.

Installation & Documentation

See the Metro website for documentation.