metro/packages/metro-bundler
Richard Girges c4307d7170 Prevent error on safely-handled requires using non-static arguments
Summary:
**Summary**
This is the workaround that cpojer suggested in #65 and should resolve the biggest pain point that developers are experiencing in that issue: using moment.js in React Native. Hopefully this at least serves as a starting point to reaching a decent solution for libraries using non-static `require()` statements.

**Test plan**
- Expected error when non-static-argument-based `require()` is nested more than one level deep within a `try` statement
- Expected no error when non-static-argument-based `require()` is nested directly within a `try` statement

```bash
ip-192-168-1-10:trueflipapp richard$ react-native bundle --entry-file index.js --platform ios --bundle-output /tmp/test.js --reset-cache
Scanning folders for symlinks in /repo/trueflip/sandbox/code/trueflipapp/node_modules (8ms)
Scanning folders for symlinks in /repo/trueflip/sandbox/code/trueflipapp/node_modules (8ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: start
bundle: finish
bundle: Writing bundle output to: /tmp/test.js
bundle: Done writing bundle output
```

Closes https://github.com/facebook/metro-bundler/pull/69

Differential Revision: D6008567

Pulled By: cpojer

fbshipit-source-id: f9be328cf50dc47c7433ffeb5eb053b398c92122
2017-10-09 08:08:43 -07:00
..
src Prevent error on safely-handled requires using non-static arguments 2017-10-09 08:08:43 -07:00
.eslintrc Add `"node"` env to packager `.eslintrc` 2017-05-19 07:36:26 -07:00
.npmignore npm package has `src/` rather than `build/` 2017-06-23 09:06:33 -07:00
README.md Update README 2017-06-06 03:29:08 -07:00
package.json Bump metro-bundler dependency to 0.19.x 2017-09-27 14:36:30 -07:00
rn-babelrc.json Remove `react-packager` indirection. 2017-02-02 05:34:12 -08:00
yarn.lock metro-bundler: fix Flow errors in OSS 2017-09-08 06:39:36 -07:00

README.md

metro-bundler

🚇 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.