Adds support for ES6 export syntax to the packager's DependencyResolver.

Summary: This PR includes:
- A regex that allows for the `export` syntax.
- Updated tests.
Closes https://github.com/facebook/react-native/pull/3465

Reviewed By: svcscm

Differential Revision: D2550322

Pulled By: vjeux

fb-gh-sync-id: 7d35f436af13cf5b6b1287835a18a9693ec1be8a
This commit is contained in:
Adam Miskiewicz
2015-10-16 10:45:20 -07:00
committed by facebook-github-bot-7
parent da250671e5
commit 24bfdda499
4 changed files with 385 additions and 2 deletions

View File

@@ -159,10 +159,14 @@ function extractRequires(code /*: string*/) /*: Array<string>*/ {
deps.sync.push(dep);
return match;
})
.replace(replacePatterns.EXPORT_RE, (match, pre, quot, dep, post) => {
deps.sync.push(dep);
return match;
})
// Parse the sync dependencies this module has. When the module is
// required, all it's sync dependencies will be loaded into memory.
// Sync dependencies can be defined either using `require` or the ES6
// `import` syntax:
// `import` or `export` syntaxes:
// var dep1 = require('dep1');
.replace(replacePatterns.REQUIRE_RE, (match, pre, quot, dep, post) => {
deps.sync.push(dep);