Summary: Don't bother to work on the source map if it won't be used anyways
Reviewed By: rafeca
Differential Revision: D6884244
fbshipit-source-id: ac014bf982e33c669a1e79f16dd06149e758a797
Summary:
This function was working on a source map object inline and then returning the same reference.
For clarity it's better if it either clones the whole thing (that would be a waste) or not return the reference at all. Also renamed the function (but not the file) for clarity.
Dropped the unused check and updated callsites instead.
Reviewed By: mjesun
Differential Revision: D6884241
fbshipit-source-id: 33aa7a1ad7096510903bbb74dd6b9c675b81aff5
Summary: Don't bother to work on the source map if it won't be used anyways
Reviewed By: mjesun
Differential Revision: D6884247
fbshipit-source-id: 811409313e7ac1a7255ddd0eed665ed92020241e
Summary: Don't bother to work on the source map if it won't be used anyways
Reviewed By: mjesun
Differential Revision: D6884243
fbshipit-source-id: 483664ad32a72a8e6e3de3e0cc224b3a6ea67d46
Summary: This prevents unnecessary JSON.stringify/JSON.parse when the operation is noop anyways.
Reviewed By: mjesun
Differential Revision: D6884246
fbshipit-source-id: 3370caac1e01cb79f86af95f0dd06285150c5d95
Summary:
An Ast consists of `Node` elements and the one Babel uses is specific to Babel (incompatible with Astree spec by default) so `BabelNode` seems more appropriate.
Keeping the other `ast` names for now to reduce the footprint of this diff.
Also makes sure `babel-core` properly exports the same node type as what the api returns making fixes to this type in the future easier to implement.
Reviewed By: davidaurelio
Differential Revision: D6834291
fbshipit-source-id: 4cb0eb2ee280a4988071b8412539edfad12cf56f
Summary: This test can be simplified.
Reviewed By: davidaurelio
Differential Revision: D6834289
fbshipit-source-id: 23072230ce844c39b5fba30cfe7ad51e5a879bed
Summary:
This bridge pulls in the various babel things and exports them again.
In a future update this bridge will also pull in babel 7 versions of the same thing and an env var will determine which sources to use so you can switch between using babel 6 or 7 through ENV.
Reviewed By: davidaurelio
Differential Revision: D6844862
fbshipit-source-id: 610a60eaf7bf368eddcd015e37f228651e2fd78b
Summary: The type was not imported and this escaped the attention of Flow somehow.
Reviewed By: davidaurelio
Differential Revision: D6834292
fbshipit-source-id: 8a9b5f2ac56fca2d0ff298b52f54935327eb2686
Summary: The type was not imported and this escaped the attention of Flow somehow.
Reviewed By: davidaurelio
Differential Revision: D6834298
fbshipit-source-id: 96f754d5aae9fda661cb18bbbb30ccfd033598a1
Summary: Releasing a new version of metro with an executable CLI
Reviewed By: davidaurelio
Differential Revision: D6808207
fbshipit-source-id: 68f6522924ea8ad7b6f9aaa3e952ebcf23d2cf8b
Summary: To be able to run the metro CLI directly (for example via `yarn run`) we need to add the shebang pointing to the nodejs binary
Reviewed By: davidaurelio
Differential Revision: D6808095
fbshipit-source-id: 89628c07a92266432a404b6bc26eaa412d7859b9
Summary: Tries to adress https://github.com/facebook/metro/issues/65. We need a reasonnable workaround to support modules like `moment.js` that do dynamic requires but only in some cases. By replacing the call by a function that throws, we move the exception at runtime instead of happening at compile time. We don't want to do that for non-node_modules file because they are fixable directly, while `node_modules` are not fixable by people and they get completely blocked by the error at compile time.
Reviewed By: rafeca
Differential Revision: D6736989
fbshipit-source-id: a6e1fd9b56fa83907400884efd8f8594018b7c37
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
Summary:
**Summary**
With RN 0.52, when there was a redbox due to a syntax error in a source file (with regular, non-delta bundler), the redbox would say just "No message provided". The JSON that Metro sent to RN did not include a "message" field because `JSON.stringify(error)` does not include `message`.
**Test Plan**
Add a syntax error to one of the files in RNTester's JS and load the RNTester app (from RN master). See that the redbox now says there was a transform error with the syntax error's location.
Also tested adding a syntax error with HMR enabled and saw that the error `message` field was set in the payload as expected.
Also added a Jest test to Server-test.js.
Closes https://github.com/facebook/metro/pull/124
Differential Revision: D6728310
Pulled By: rafeca
fbshipit-source-id: 9ee3c113767d8c2849bcaac0cb8a9cfa8f2760a6