mirror of https://github.com/status-im/metro.git
Update node-haste from upstream
Reviewed By: zpao Differential Revision: D2747183 fb-gh-sync-id: f1b963b19cb6ea16945b16370d1bee26110bb329
This commit is contained in:
parent
8bc99d9a53
commit
ff3cac5436
|
@ -1362,19 +1362,19 @@ describe('DependencyGraph', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testBrowserField('browser')
|
testBrowserField('browser');
|
||||||
testBrowserField('react-native')
|
testBrowserField('react-native');
|
||||||
|
|
||||||
function replaceBrowserField (json, fieldName) {
|
function replaceBrowserField(json, fieldName) {
|
||||||
if (fieldName !== 'browser') {
|
if (fieldName !== 'browser') {
|
||||||
json[fieldName] = json.browser
|
json[fieldName] = json.browser;
|
||||||
delete json.browser
|
delete json.browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
return json
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
function testBrowserField (fieldName) {
|
function testBrowserField(fieldName) {
|
||||||
pit('should support simple browser field in packages ("' + fieldName + '")', function() {
|
pit('should support simple browser field in packages ("' + fieldName + '")', function() {
|
||||||
var root = '/root';
|
var root = '/root';
|
||||||
fs.__setMockFilesystem({
|
fs.__setMockFilesystem({
|
||||||
|
@ -1393,8 +1393,8 @@ describe('DependencyGraph', function() {
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'main.js': 'some other code',
|
'main.js': 'some other code',
|
||||||
'client.js': 'some code',
|
'client.js': 'some code',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1448,8 +1448,8 @@ describe('DependencyGraph', function() {
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'main.js': 'some other code',
|
'main.js': 'some other code',
|
||||||
'client.js': 'some code',
|
'client.js': 'some code',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1503,8 +1503,8 @@ describe('DependencyGraph', function() {
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'main.js': 'some other code',
|
'main.js': 'some other code',
|
||||||
'client.js': 'some code',
|
'client.js': 'some code',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1559,8 +1559,8 @@ describe('DependencyGraph', function() {
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'main.js': 'some other code',
|
'main.js': 'some other code',
|
||||||
'client.js': 'some code',
|
'client.js': 'some code',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1630,15 +1630,15 @@ describe('DependencyGraph', function() {
|
||||||
},
|
},
|
||||||
'hello.js': 'hello',
|
'hello.js': 'hello',
|
||||||
'bye.js': 'bye',
|
'bye.js': 'bye',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
const dgraph = new DependencyGraph({
|
||||||
...defaults,
|
...defaults,
|
||||||
roots: [root],
|
roots: [root],
|
||||||
});
|
});
|
||||||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||||
expect(deps)
|
expect(deps)
|
||||||
.toEqual([
|
.toEqual([
|
||||||
{ id: 'index',
|
{ id: 'index',
|
||||||
|
@ -1716,7 +1716,7 @@ describe('DependencyGraph', function() {
|
||||||
name: 'aPackage',
|
name: 'aPackage',
|
||||||
browser: {
|
browser: {
|
||||||
'node-package': 'browser-package',
|
'node-package': 'browser-package',
|
||||||
}
|
},
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'index.js': 'require("node-package")',
|
'index.js': 'require("node-package")',
|
||||||
'node-package': {
|
'node-package': {
|
||||||
|
@ -1731,8 +1731,8 @@ describe('DependencyGraph', function() {
|
||||||
}),
|
}),
|
||||||
'index.js': 'some browser code',
|
'index.js': 'some browser code',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1788,7 +1788,7 @@ describe('DependencyGraph', function() {
|
||||||
name: 'aPackage',
|
name: 'aPackage',
|
||||||
browser: {
|
browser: {
|
||||||
'node-package': 'browser-package',
|
'node-package': 'browser-package',
|
||||||
}
|
},
|
||||||
}, fieldName)),
|
}, fieldName)),
|
||||||
'index.js': 'require("node-package")',
|
'index.js': 'require("node-package")',
|
||||||
'node-package': {
|
'node-package': {
|
||||||
|
@ -1803,8 +1803,8 @@ describe('DependencyGraph', function() {
|
||||||
}),
|
}),
|
||||||
'index.js': 'some browser code',
|
'index.js': 'some browser code',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
@ -1861,13 +1861,13 @@ describe('DependencyGraph', function() {
|
||||||
name: 'aPackage',
|
name: 'aPackage',
|
||||||
'react-native': {
|
'react-native': {
|
||||||
'node-package': 'rn-package',
|
'node-package': 'rn-package',
|
||||||
}
|
},
|
||||||
}),
|
}),
|
||||||
'index.js': 'require("node-package")',
|
'index.js': 'require("node-package")',
|
||||||
'node_modules': {
|
'node_modules': {
|
||||||
'node-package': {
|
'node-package': {
|
||||||
'package.json': JSON.stringify({
|
'package.json': JSON.stringify({
|
||||||
'name': 'node-package'
|
'name': 'node-package',
|
||||||
}),
|
}),
|
||||||
'index.js': 'some node code',
|
'index.js': 'some node code',
|
||||||
},
|
},
|
||||||
|
@ -1875,8 +1875,8 @@ describe('DependencyGraph', function() {
|
||||||
'package.json': JSON.stringify({
|
'package.json': JSON.stringify({
|
||||||
'name': 'rn-package',
|
'name': 'rn-package',
|
||||||
browser: {
|
browser: {
|
||||||
'nested-package': 'nested-browser-package'
|
'nested-package': 'nested-browser-package',
|
||||||
}
|
},
|
||||||
}),
|
}),
|
||||||
'index.js': 'require("nested-package")',
|
'index.js': 'require("nested-package")',
|
||||||
},
|
},
|
||||||
|
@ -1884,11 +1884,11 @@ describe('DependencyGraph', function() {
|
||||||
'package.json': JSON.stringify({
|
'package.json': JSON.stringify({
|
||||||
'name': 'nested-browser-package',
|
'name': 'nested-browser-package',
|
||||||
}),
|
}),
|
||||||
'index.js': 'some code'
|
'index.js': 'some code',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var dgraph = new DependencyGraph({
|
var dgraph = new DependencyGraph({
|
||||||
|
|
|
@ -25,7 +25,7 @@ function extract(contents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var commentStartRe = /^\/\*\*?/;
|
var commentStartRe = /^\/\*\*/;
|
||||||
var commentEndRe = /\*\/$/;
|
var commentEndRe = /\*\/$/;
|
||||||
var wsRe = /[\t ]+/g;
|
var wsRe = /[\t ]+/g;
|
||||||
var stringStartRe = /(\r?\n|^) *\*/g;
|
var stringStartRe = /(\r?\n|^) *\*/g;
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Package {
|
||||||
|
|
||||||
getMain() {
|
getMain() {
|
||||||
return this._read().then(json => {
|
return this._read().then(json => {
|
||||||
var replacements = getReplacements(json)
|
var replacements = getReplacements(json);
|
||||||
if (typeof replacements === 'string') {
|
if (typeof replacements === 'string') {
|
||||||
return path.join(this.root, replacements);
|
return path.join(this.root, replacements);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.IMPORT_RE = /(\bimport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
|
|
||||||
exports.EXPORT_RE = /(\bexport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
|
|
||||||
exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
|
|
||||||
exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
|
|
Loading…
Reference in New Issue