mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Updates from Thu 19 Mar
- [ReactNative] Add root package.json name back | Tadeu Zagallo
- [react-packager] Make sure projectRoots is converted to an array | Amjad Masad
- [ReactNative] Init script that bootstraps new Xcode project | Alex Kotliarskyi
- [ReactNative] New SampleApp | Alex Kotliarskyi
- [ReactNative] Touchable invoke press on longPress when longPress handler missing | Eric Vicenti
- [ReactNative] Commit missing RCTWebSocketDebugger.xcodeproj | Alex Kotliarskyi
- [ReactNative] Add Custom Components folder | Christopher Chedeau
- [react-packager] Hash cache file name information to avoid long names | Amjad Masad
- [ReactNative] Put all iOS-related files in a subfolder | Alex Kotliarskyi
- [react-packager] Fix OOM | Amjad Masad
- [ReactNative] Bring Chrome debugger to OSS. Part 2 | Alex Kotliarskyi
- [ReactNative] Add search to UIExplorer | Tadeu Zagallo
- [ReactNative][RFC] Bring Chrome debugger to OSS. Part 1 | Alex Kotliarskyi
- [ReactNative] Return the appropriate status code from XHR | Tadeu Zagallo
- [ReactNative] Make JS stack traces in Xcode prettier | Alex Kotliarskyi
- [ReactNative] Remove duplicate package.json with the same name | Christopher Chedeau
- [ReactNative] Remove invariant from require('react-native') | Christopher Chedeau
- [ReactNative] Remove ListViewDataSource from require('react-native') | Christopher Chedeau
- [react-packager] Add assetRoots option | Amjad Masad
- Convert UIExplorer to ListView | Christopher Chedeau
- purge rni | Basil Hosmer
- [ReactNative] s/render*View/render/ in <WebView> | Christopher Chedeau
This commit is contained in:
@@ -134,13 +134,12 @@ DependecyGraph.prototype.resolveDependency = function(
|
||||
fromModule,
|
||||
depModuleId
|
||||
) {
|
||||
|
||||
if (this._assetMap != null) {
|
||||
// Process asset requires.
|
||||
var assetMatch = depModuleId.match(/^image!(.+)/);
|
||||
if (assetMatch && assetMatch[1]) {
|
||||
if (!this._assetMap[assetMatch[1]]) {
|
||||
console.warn('Cannot find asset: ' + assetMatch[1]);
|
||||
debug('WARINING: Cannot find asset:', assetMatch[1]);
|
||||
return null;
|
||||
}
|
||||
return this._assetMap[assetMatch[1]];
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var version = require('../../../../package.json').version;
|
||||
var tmpdir = require('os').tmpDir();
|
||||
var isAbsolutePath = require('absolute-path');
|
||||
var _ = require('underscore');
|
||||
var crypto = require('crypto');
|
||||
var declareOpts = require('../lib/declareOpts');
|
||||
var fs = require('fs');
|
||||
var _ = require('underscore');
|
||||
var isAbsolutePath = require('absolute-path');
|
||||
var path = require('path');
|
||||
var q = require('q');
|
||||
var tmpdir = require('os').tmpDir();
|
||||
var version = require('../../../../package.json').version;
|
||||
|
||||
var Promise = q.Promise;
|
||||
|
||||
@@ -146,15 +147,15 @@ function loadCacheSync(cachePath) {
|
||||
}
|
||||
|
||||
function cacheFilePath(options) {
|
||||
var hash = crypto.createHash('md5');
|
||||
hash.update(version);
|
||||
|
||||
var roots = options.projectRoots.join(',').split(path.sep).join('-');
|
||||
hash.update(roots);
|
||||
|
||||
var cacheVersion = options.cacheVersion || '0';
|
||||
return path.join(
|
||||
tmpdir,
|
||||
[
|
||||
'react-packager-cache',
|
||||
version,
|
||||
cacheVersion,
|
||||
roots,
|
||||
].join('-')
|
||||
);
|
||||
hash.update(cacheVersion);
|
||||
|
||||
var name = 'react-packager-cache-' + hash.digest('hex');
|
||||
return path.join(tmpdir, name);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ jest
|
||||
.dontMock('underscore')
|
||||
.dontMock('path')
|
||||
.dontMock('absolute-path')
|
||||
.dontMock('crypto')
|
||||
.dontMock('../Cache');
|
||||
|
||||
var q = require('q');
|
||||
@@ -19,7 +20,7 @@ describe('JSTransformer Cache', function() {
|
||||
Cache = require('../Cache');
|
||||
});
|
||||
|
||||
describe('getting/settig', function() {
|
||||
describe('getting/setting', function() {
|
||||
it('calls loader callback for uncached file', function() {
|
||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||
var loaderCb = jest.genMockFn().mockImpl(function() {
|
||||
|
||||
@@ -59,7 +59,7 @@ function Transformer(options) {
|
||||
this._failedToStart = q.Promise.reject(new Error('No transfrom module'));
|
||||
} else {
|
||||
this._workers = workerFarm(
|
||||
{autoStart: true},
|
||||
{autoStart: true, maxConcurrentCallsPerWorker: 1},
|
||||
options.transformModulePath
|
||||
);
|
||||
}
|
||||
|
||||
25
packager/react-packager/src/Server/index.js
vendored
25
packager/react-packager/src/Server/index.js
vendored
@@ -8,6 +8,7 @@ var Packager = require('../Packager');
|
||||
var Activity = require('../Activity');
|
||||
var setImmediate = require('timers').setImmediate;
|
||||
var q = require('q');
|
||||
var _ = require('underscore');
|
||||
|
||||
module.exports = Server;
|
||||
|
||||
@@ -62,6 +63,12 @@ function Server(options) {
|
||||
|
||||
var onFileChange = this._onFileChange.bind(this);
|
||||
this._fileWatcher.on('all', onFileChange);
|
||||
|
||||
var self = this;
|
||||
this._debouncedFileChangeHandler = _.debounce(function(filePath) {
|
||||
self._rebuildPackages(filePath);
|
||||
self._informChangeWatchers();
|
||||
}, 50, true);
|
||||
}
|
||||
|
||||
Server.prototype._onFileChange = function(type, filepath, root) {
|
||||
@@ -69,8 +76,7 @@ Server.prototype._onFileChange = function(type, filepath, root) {
|
||||
this._packager.invalidateFile(absPath);
|
||||
// Make sure the file watcher event runs through the system before
|
||||
// we rebuild the packages.
|
||||
setImmediate(this._rebuildPackages.bind(this, absPath));
|
||||
setImmediate(this._informChangeWatchers.bind(this));
|
||||
this._debouncedFileChangeHandler(absPath);
|
||||
};
|
||||
|
||||
Server.prototype._rebuildPackages = function() {
|
||||
@@ -78,13 +84,16 @@ Server.prototype._rebuildPackages = function() {
|
||||
var packages = this._packages;
|
||||
Object.keys(packages).forEach(function(key) {
|
||||
var options = getOptionsFromUrl(key);
|
||||
packages[key] = buildPackage(options).then(function(p) {
|
||||
// Make a throwaway call to getSource to cache the source string.
|
||||
p.getSource({
|
||||
inlineSourceMap: options.dev,
|
||||
minify: options.minify,
|
||||
// Wait for a previous build (if exists) to finish.
|
||||
packages[key] = (packages[key] || q()).then(function() {
|
||||
return buildPackage(options).then(function(p) {
|
||||
// Make a throwaway call to getSource to cache the source string.
|
||||
p.getSource({
|
||||
inlineSourceMap: options.dev,
|
||||
minify: options.minify,
|
||||
});
|
||||
return p;
|
||||
});
|
||||
return p;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user