Fix lint errors 1/n
Reviewed By: davidaurelio Differential Revision: D4627645 fbshipit-source-id: 3cf368c6a24a555b7d0a39045f6ba6fd92ae34e1
This commit is contained in:
parent
05c36b463b
commit
5403946f09
|
@ -38,8 +38,8 @@ describe('AssetServer', () => {
|
|||
imgs: {
|
||||
'b.png': 'b image',
|
||||
'b@2x.png': 'b2 image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
|
@ -65,8 +65,8 @@ describe('AssetServer', () => {
|
|||
'b.android.png': 'b android image',
|
||||
'c.png': 'c general image',
|
||||
'c.android.png': 'c android image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
|
@ -100,8 +100,8 @@ describe('AssetServer', () => {
|
|||
imgs: {
|
||||
'b.png': 'png image',
|
||||
'b.jpg': 'jpeg image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
|
@ -128,8 +128,8 @@ describe('AssetServer', () => {
|
|||
'b@2x.png': 'b2 image',
|
||||
'b@4x.png': 'b4 image',
|
||||
'b@4.5x.png': 'b4.5 image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return server.get('imgs/b@3x.png').then(data =>
|
||||
|
@ -154,8 +154,8 @@ describe('AssetServer', () => {
|
|||
'b@2x.ios.png': 'b2 ios image',
|
||||
'b@4x.ios.png': 'b4 ios image',
|
||||
'b@4.5x.ios.png': 'b4.5 ios image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
|
@ -209,8 +209,8 @@ describe('AssetServer', () => {
|
|||
'b@2x.png': 'b2 image',
|
||||
'b@4x.png': 'b4 image',
|
||||
'b@4.5x.png': 'b4.5 image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return server.getAssetData('imgs/b.png').then(data => {
|
||||
|
@ -241,8 +241,8 @@ describe('AssetServer', () => {
|
|||
'b@2x.jpg': 'b2 image',
|
||||
'b@4x.jpg': 'b4 image',
|
||||
'b@4.5x.jpg': 'b4.5 image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return server.getAssetData('imgs/b.jpg').then(data => {
|
||||
|
@ -275,11 +275,11 @@ describe('AssetServer', () => {
|
|||
'b@2x.jpg': 'b2 image',
|
||||
'b@4x.jpg': 'b4 image',
|
||||
'b@4.5x.jpg': 'b4.5 image',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
fs.__setMockFilesystem(mockFS);
|
||||
fs.__setMockFilesystem(mockFS);
|
||||
});
|
||||
|
||||
it('uses the file contents to build the hash', () => {
|
||||
|
|
|
@ -15,14 +15,14 @@ const fs = require('fs');
|
|||
const getAssetDataFromName = require('../node-haste').getAssetDataFromName;
|
||||
const path = require('path');
|
||||
|
||||
const createTimeoutPromise = (timeout) => new Promise((resolve, reject) => {
|
||||
const createTimeoutPromise = timeout => new Promise((resolve, reject) => {
|
||||
setTimeout(reject, timeout, 'fs operation timeout');
|
||||
});
|
||||
function timeoutableDenodeify(fsFunc, timeout) {
|
||||
return function raceWrapper(...args) {
|
||||
return Promise.race([
|
||||
createTimeoutPromise(timeout),
|
||||
denodeify(fsFunc).apply(this, args)
|
||||
denodeify(fsFunc).apply(this, args),
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class AssetServer {
|
|||
const map = this._buildAssetMap(dir, files, platform);
|
||||
|
||||
let record;
|
||||
if (platform != null){
|
||||
if (platform != null) {
|
||||
record = map[getAssetKey(assetData.assetName, platform)] ||
|
||||
map[assetData.assetName];
|
||||
} else {
|
||||
|
|
|
@ -229,7 +229,7 @@ class Bundle extends BundleBase {
|
|||
}
|
||||
|
||||
result.sections.push({
|
||||
offset: { line: line, column: 0 },
|
||||
offset: {line, column: 0},
|
||||
map: (map: MixedSourceMap),
|
||||
});
|
||||
line += module.code.split('\n').length;
|
||||
|
@ -324,11 +324,11 @@ function generateSourceMapForVirtualModule(module): SourceMap {
|
|||
|
||||
return {
|
||||
version: 3,
|
||||
sources: [ module.sourcePath ],
|
||||
sources: [module.sourcePath],
|
||||
names: [],
|
||||
mappings: mappings,
|
||||
mappings,
|
||||
file: module.sourcePath,
|
||||
sourcesContent: [ module.sourceCode ],
|
||||
sourcesContent: [module.sourceCode],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class BundleBase {
|
|||
return this._source;
|
||||
}
|
||||
|
||||
this._source = this._modules.map((module) => module.code).join('\n');
|
||||
this._source = this._modules.map(module => module.code).join('\n');
|
||||
return this._source;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ const ModuleTransport = require('../lib/ModuleTransport');
|
|||
class HMRBundle extends BundleBase {
|
||||
constructor({sourceURLFn, sourceMappingURLFn}) {
|
||||
super();
|
||||
this._sourceURLFn = sourceURLFn
|
||||
this._sourceURLFn = sourceURLFn;
|
||||
this._sourceMappingURLFn = sourceMappingURLFn;
|
||||
this._sourceURLs = [];
|
||||
this._sourceMappingURLs = [];
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('Bundle', () => {
|
|||
expect(bundle.getSource({dev: true})).toBe([
|
||||
'transformed foo;',
|
||||
'transformed bar;',
|
||||
'\/\/# sourceMappingURL=test_url'
|
||||
'\/\/# sourceMappingURL=test_url',
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ describe('Bundle', () => {
|
|||
const resolver = {
|
||||
wrapModule({name}) {
|
||||
return new Promise(resolve => resolves[name] = resolve);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const promise = Promise.all(
|
||||
|
@ -180,49 +180,49 @@ describe('Bundle', () => {
|
|||
file: 'test_url',
|
||||
version: 3,
|
||||
sections: [
|
||||
{ offset: { line: 0, column: 0 }, map: { name: 'sourcemap foo' } },
|
||||
{ offset: { line: 2, column: 0 }, map: { name: 'sourcemap bar' } },
|
||||
{offset: {line: 0, column: 0}, map: {name: 'sourcemap foo'}},
|
||||
{offset: {line: 2, column: 0}, map: {name: 'sourcemap bar'}},
|
||||
{
|
||||
offset: {
|
||||
column: 0,
|
||||
line: 4
|
||||
line: 4,
|
||||
},
|
||||
map: {
|
||||
file: 'image.png',
|
||||
mappings: 'AAAA;AACA;',
|
||||
names: [],
|
||||
sources: [ 'image.png' ],
|
||||
sources: ['image.png'],
|
||||
sourcesContent: ['image module;\nimage module;'],
|
||||
version: 3,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
offset: {
|
||||
column: 0,
|
||||
line: 6
|
||||
line: 6,
|
||||
},
|
||||
map: {
|
||||
file: 'require-InitializeCore.js',
|
||||
mappings: 'AAAA;',
|
||||
names: [],
|
||||
sources: [ 'require-InitializeCore.js' ],
|
||||
sources: ['require-InitializeCore.js'],
|
||||
sourcesContent: [';require("InitializeCore");'],
|
||||
version: 3,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
offset: {
|
||||
column: 0,
|
||||
line: 7
|
||||
line: 7,
|
||||
},
|
||||
map: {
|
||||
file: 'require-foo.js',
|
||||
mappings: 'AAAA;',
|
||||
names: [],
|
||||
sources: [ 'require-foo.js' ],
|
||||
sources: ['require-foo.js'],
|
||||
sourcesContent: [';require("foo");'],
|
||||
version: 3,
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -342,7 +342,7 @@ describe('Bundle', () => {
|
|||
const {groups} = bundle.getUnbundle();
|
||||
expect(groups).toEqual(new Map([[
|
||||
idFor('Product1'),
|
||||
new Set(['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor))
|
||||
new Set(['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor)),
|
||||
]]));
|
||||
});
|
||||
|
||||
|
|
|
@ -82,14 +82,14 @@ describe('Bundler', function() {
|
|||
|
||||
Resolver.mockImplementation(function() {
|
||||
return {
|
||||
getDependencies: getDependencies,
|
||||
getModuleSystemDependencies: getModuleSystemDependencies,
|
||||
getDependencies,
|
||||
getModuleSystemDependencies,
|
||||
};
|
||||
});
|
||||
|
||||
fs.statSync.mockImplementation(function() {
|
||||
return {
|
||||
isDirectory: () => true
|
||||
isDirectory: () => true,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -104,7 +104,7 @@ describe('Bundler', function() {
|
|||
bundler = new Bundler({
|
||||
...commonOptions,
|
||||
projectRoots,
|
||||
assetServer: assetServer,
|
||||
assetServer,
|
||||
});
|
||||
|
||||
modules = [
|
||||
|
@ -115,7 +115,7 @@ describe('Bundler', function() {
|
|||
path: '/root/img/new_image.png',
|
||||
isAsset: true,
|
||||
resolution: 2,
|
||||
dependencies: []
|
||||
dependencies: [],
|
||||
}),
|
||||
createModule({
|
||||
id: 'package/file.json',
|
||||
|
@ -140,14 +140,14 @@ describe('Bundler', function() {
|
|||
});
|
||||
|
||||
sizeOf.mockImplementation(function(path, cb) {
|
||||
cb(null, { width: 50, height: 100 });
|
||||
cb(null, {width: 50, height: 100});
|
||||
});
|
||||
});
|
||||
|
||||
it('create a bundle', function() {
|
||||
assetServer.getAssetData.mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
scales: [1,2,3],
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/img.png',
|
||||
'/root/img/img@2x.png',
|
||||
|
@ -165,39 +165,39 @@ describe('Bundler', function() {
|
|||
runModule: true,
|
||||
sourceMapUrl: 'source_map_url',
|
||||
}).then(bundle => {
|
||||
const ithAddedModule = (i) => bundle.addModule.mock.calls[i][2].path;
|
||||
const ithAddedModule = i => bundle.addModule.mock.calls[i][2].path;
|
||||
|
||||
expect(ithAddedModule(0)).toEqual('/root/foo.js');
|
||||
expect(ithAddedModule(1)).toEqual('/root/bar.js');
|
||||
expect(ithAddedModule(2)).toEqual('/root/img/new_image.png');
|
||||
expect(ithAddedModule(3)).toEqual('/root/file.json');
|
||||
expect(ithAddedModule(0)).toEqual('/root/foo.js');
|
||||
expect(ithAddedModule(1)).toEqual('/root/bar.js');
|
||||
expect(ithAddedModule(2)).toEqual('/root/img/new_image.png');
|
||||
expect(ithAddedModule(3)).toEqual('/root/file.json');
|
||||
|
||||
expect(bundle.finalize.mock.calls[0]).toEqual([{
|
||||
runModule: true,
|
||||
runBeforeMainModule: [],
|
||||
allowUpdates: false,
|
||||
}]);
|
||||
expect(bundle.finalize.mock.calls[0]).toEqual([{
|
||||
runModule: true,
|
||||
runBeforeMainModule: [],
|
||||
allowUpdates: false,
|
||||
}]);
|
||||
|
||||
expect(bundle.addAsset.mock.calls[0]).toEqual([{
|
||||
__packager_asset: true,
|
||||
fileSystemLocation: '/root/img',
|
||||
httpServerLocation: '/assets/img',
|
||||
width: 50,
|
||||
height: 100,
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/img.png',
|
||||
'/root/img/img@2x.png',
|
||||
'/root/img/img@3x.png',
|
||||
],
|
||||
hash: 'i am a hash',
|
||||
name: 'img',
|
||||
type: 'png',
|
||||
}]);
|
||||
expect(bundle.addAsset.mock.calls[0]).toEqual([{
|
||||
__packager_asset: true,
|
||||
fileSystemLocation: '/root/img',
|
||||
httpServerLocation: '/assets/img',
|
||||
width: 50,
|
||||
height: 100,
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/img.png',
|
||||
'/root/img/img@2x.png',
|
||||
'/root/img/img@3x.png',
|
||||
],
|
||||
hash: 'i am a hash',
|
||||
name: 'img',
|
||||
type: 'png',
|
||||
}]);
|
||||
|
||||
// TODO(amasad) This fails with 0 != 5 in OSS
|
||||
//expect(ProgressBar.prototype.tick.mock.calls.length).toEqual(modules.length);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('loads and runs asset plugins', function() {
|
||||
|
@ -211,7 +211,7 @@ describe('Bundler', function() {
|
|||
jest.mock('asyncMockPlugin2', () => {
|
||||
return asset => {
|
||||
expect(asset.extraReverseHash).toBeDefined();
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(resolve => {
|
||||
asset.extraPixelCount = asset.width * asset.height;
|
||||
resolve(asset);
|
||||
});
|
||||
|
@ -219,7 +219,7 @@ describe('Bundler', function() {
|
|||
}, {virtual: true});
|
||||
|
||||
const mockAsset = {
|
||||
scales: [1,2,3],
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/img.png',
|
||||
'/root/img/img@2x.png',
|
||||
|
@ -265,15 +265,15 @@ describe('Bundler', function() {
|
|||
// jest calledWith does not support jasmine.any
|
||||
expect(getDependencies.mock.calls[0].slice(0, -2)).toEqual([
|
||||
'/root/foo.js',
|
||||
{ dev: true, recursive: true },
|
||||
{ minify: false,
|
||||
{dev: true, recursive: true},
|
||||
{minify: false,
|
||||
dev: true,
|
||||
transform: {
|
||||
dev: true,
|
||||
hot: false,
|
||||
generateSourceMaps: false,
|
||||
projectRoots,
|
||||
}
|
||||
},
|
||||
},
|
||||
])
|
||||
);
|
||||
|
@ -284,7 +284,7 @@ describe('Bundler', function() {
|
|||
const b = new Bundler({
|
||||
...commonOptions,
|
||||
projectRoots,
|
||||
assetServer: assetServer,
|
||||
assetServer,
|
||||
platforms: ['android', 'vr'],
|
||||
});
|
||||
expect(b._opts.platforms).toEqual(['android', 'vr']);
|
||||
|
@ -295,7 +295,7 @@ describe('Bundler', function() {
|
|||
assetServer.getAssetData.mockImplementation(function(relPath) {
|
||||
if (relPath === 'img/new_image.png') {
|
||||
return Promise.resolve({
|
||||
scales: [1,2,3],
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/new_image.png',
|
||||
'/root/img/new_image@2x.png',
|
||||
|
@ -307,7 +307,7 @@ describe('Bundler', function() {
|
|||
});
|
||||
} else if (relPath === 'img/new_image2.png') {
|
||||
return Promise.resolve({
|
||||
scales: [1,2,3],
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/new_image2.png',
|
||||
'/root/img/new_image2@2x.png',
|
||||
|
@ -330,12 +330,12 @@ describe('Bundler', function() {
|
|||
path: '/root/img/new_image2.png',
|
||||
isAsset: true,
|
||||
resolution: 2,
|
||||
dependencies: []
|
||||
dependencies: [],
|
||||
}),
|
||||
);
|
||||
|
||||
return bundler.getOrderedDependencyPaths('/root/foo.js', true)
|
||||
.then((paths) => expect(paths).toEqual([
|
||||
.then(paths => expect(paths).toEqual([
|
||||
'/root/foo.js',
|
||||
'/root/bar.js',
|
||||
'/root/img/new_image.png',
|
||||
|
|
|
@ -552,13 +552,13 @@ class Bundler {
|
|||
});
|
||||
}
|
||||
|
||||
getOrderedDependencyPaths({ entryFile, dev, platform }: {
|
||||
getOrderedDependencyPaths({entryFile, dev, platform}: {
|
||||
entryFile: string,
|
||||
dev: boolean,
|
||||
platform: string,
|
||||
}) {
|
||||
return this.getDependencies({entryFile, dev, platform}).then(
|
||||
({ dependencies }) => {
|
||||
({dependencies}) => {
|
||||
const ret = [];
|
||||
const promises = [];
|
||||
const placeHolder = {};
|
||||
|
@ -578,7 +578,7 @@ class Bundler {
|
|||
});
|
||||
|
||||
return Promise.all(promises).then(assetsData => {
|
||||
assetsData.forEach(({ files }) => {
|
||||
assetsData.forEach(({files}) => {
|
||||
const index = ret.indexOf(placeHolder);
|
||||
ret.splice(index, 1, ...files);
|
||||
});
|
||||
|
@ -636,7 +636,7 @@ class Bundler {
|
|||
map,
|
||||
meta: {dependencies, dependencyOffsets, preloaded, dependencyPairs},
|
||||
sourceCode: source,
|
||||
sourcePath: module.path
|
||||
sourcePath: module.path,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -657,12 +657,12 @@ class Bundler {
|
|||
// Test extension against all types supported by image-size module.
|
||||
// If it's not one of these, we won't treat it as an image.
|
||||
const isImage = [
|
||||
'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'
|
||||
'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff',
|
||||
].indexOf(extname(module.path).slice(1)) !== -1;
|
||||
|
||||
return this._assetServer.getAssetData(relPath, platform).then((assetData) => {
|
||||
return this._assetServer.getAssetData(relPath, platform).then(assetData => {
|
||||
return Promise.all([isImage ? sizeOf(assetData.files[0]) : null, assetData]);
|
||||
}).then((res) => {
|
||||
}).then(res => {
|
||||
const dimensions = res[0];
|
||||
const assetData = res[1];
|
||||
const scale = assetData.scales[0];
|
||||
|
@ -680,7 +680,7 @@ class Bundler {
|
|||
};
|
||||
|
||||
return this._applyAssetPlugins(assetPlugins, asset);
|
||||
}).then((asset) => {
|
||||
}).then(asset => {
|
||||
const json = JSON.stringify(filterObject(asset, assetPropertyBlacklist));
|
||||
const assetRegistryPath = 'react-native/Libraries/Image/AssetRegistry';
|
||||
const code =
|
||||
|
@ -691,7 +691,7 @@ class Bundler {
|
|||
return {
|
||||
asset,
|
||||
code,
|
||||
meta: {dependencies, dependencyOffsets}
|
||||
meta: {dependencies, dependencyOffsets},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ class Bundler {
|
|||
name,
|
||||
id: moduleId,
|
||||
code,
|
||||
meta: meta,
|
||||
meta,
|
||||
sourceCode: code,
|
||||
sourcePath: module.path,
|
||||
virtual: true,
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('build map from raw mappings', () => {
|
|||
[1, 2],
|
||||
[3, 4, 5, 6, 'apples'],
|
||||
[7, 8, 9, 10],
|
||||
[11, 12, 13, 14, 'pears']
|
||||
[11, 12, 13, 14, 'pears'],
|
||||
],
|
||||
sourceCode: 'code1',
|
||||
sourcePath: 'path1',
|
||||
|
@ -65,7 +65,7 @@ describe('build map from raw mappings', () => {
|
|||
[11, 12],
|
||||
[13, 14, 15, 16, 'bananas'],
|
||||
[17, 18, 19, 110],
|
||||
[21, 112, 113, 114, 'pears']
|
||||
[21, 112, 113, 114, 'pears'],
|
||||
],
|
||||
sourceCode: 'code3',
|
||||
sourcePath: 'path3',
|
||||
|
|
|
@ -110,11 +110,11 @@ function encode(value: number, buffer: Buffer, position: number): number {
|
|||
let digit, vlq = toVLQSigned(value);
|
||||
do {
|
||||
digit = vlq & VLQ_BASE_MASK;
|
||||
vlq = vlq >>> VLQ_BASE_SHIFT;
|
||||
vlq >>>= VLQ_BASE_SHIFT;
|
||||
if (vlq > 0) {
|
||||
// There are still more digits in this value, so we must make sure the
|
||||
// continuation bit is marked.
|
||||
digit = digit | VLQ_CONTINUATION_BIT;
|
||||
digit |= VLQ_CONTINUATION_BIT;
|
||||
}
|
||||
buffer[position++] = CHAR_MAP[digit];
|
||||
} while (vlq > 0);
|
||||
|
|
|
@ -44,7 +44,7 @@ function fromRawMappings(modules: Array<ModuleTransport>): Generator {
|
|||
);
|
||||
}
|
||||
|
||||
carryOver = carryOver + countLines(code);
|
||||
carryOver += countLines(code);
|
||||
}
|
||||
|
||||
return generator;
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
module.exports = function (data, callback) {
|
||||
module.exports = function(data, callback) {
|
||||
callback(null, {});
|
||||
};
|
||||
|
|
|
@ -57,7 +57,7 @@ function makeFarm(worker, methods, timeout) {
|
|||
{
|
||||
autoStart: true,
|
||||
maxConcurrentCallsPerWorker: 1,
|
||||
maxConcurrentWorkers: maxConcurrentWorkers,
|
||||
maxConcurrentWorkers,
|
||||
maxCallsPerWorker: MAX_CALLS_PER_WORKER,
|
||||
maxCallTime: timeout,
|
||||
maxRetries: MAX_RETRIES,
|
||||
|
|
|
@ -59,7 +59,7 @@ describe('code transformation worker:', () => {
|
|||
it('calls back with the result of the transform in the cache', done => {
|
||||
const result = {
|
||||
code: 'some.other(code)',
|
||||
map: {}
|
||||
map: {},
|
||||
};
|
||||
|
||||
transformCode(transformer, 'filename', result.code, {}, (error, data) => {
|
||||
|
@ -76,10 +76,10 @@ describe('code transformation worker:', () => {
|
|||
const code = '{a:1,b:2}';
|
||||
const filePath = 'arbitrary/file.json';
|
||||
transformCode(transformer, filePath, code, {}, (error, data) => {
|
||||
expect(error).toBeNull();
|
||||
expect(data.result.code).toEqual(code);
|
||||
done();
|
||||
},
|
||||
expect(error).toBeNull();
|
||||
expect(data.result.code).toEqual(code);
|
||||
done();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
|
@ -115,7 +115,7 @@ describe('code transformation worker:', () => {
|
|||
it('passes the transformed code the `extractDependencies`', done => {
|
||||
const code = 'arbitrary(code)';
|
||||
|
||||
transformCode(transformer, 'filename', code, {}, (error) => {
|
||||
transformCode(transformer, 'filename', code, {}, error => {
|
||||
expect(error).toBeNull();
|
||||
expect(extractDependencies).toBeCalledWith(code);
|
||||
done();
|
||||
|
@ -143,25 +143,25 @@ describe('code transformation worker:', () => {
|
|||
it('does not extract requires if files are marked as "extern"', done => {
|
||||
const opts = {extern: true};
|
||||
transformCode(transformer, 'filename', 'code', opts, (error, data) => {
|
||||
expect(error).toBeNull();
|
||||
const {dependencies, dependencyOffsets} = data.result;
|
||||
expect(extractDependencies).not.toBeCalled();
|
||||
expect(dependencies).toEqual([]);
|
||||
expect(dependencyOffsets).toEqual([]);
|
||||
done();
|
||||
expect(error).toBeNull();
|
||||
const {dependencies, dependencyOffsets} = data.result;
|
||||
expect(extractDependencies).not.toBeCalled();
|
||||
expect(dependencies).toEqual([]);
|
||||
expect(dependencyOffsets).toEqual([]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not extract requires of JSON files', done => {
|
||||
const jsonStr = '{"arbitrary":"json"}';
|
||||
transformCode(transformer, 'arbitrary.json', jsonStr, {}, (error, data) => {
|
||||
expect(error).toBeNull();
|
||||
const {dependencies, dependencyOffsets} = data.result;
|
||||
expect(extractDependencies).not.toBeCalled();
|
||||
expect(dependencies).toEqual([]);
|
||||
expect(dependencyOffsets).toEqual([]);
|
||||
done();
|
||||
}
|
||||
expect(error).toBeNull();
|
||||
const {dependencies, dependencyOffsets} = data.result;
|
||||
expect(extractDependencies).not.toBeCalled();
|
||||
expect(dependencies).toEqual([]);
|
||||
expect(dependencyOffsets).toEqual([]);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -182,7 +182,7 @@ describe('code transformation worker:', () => {
|
|||
options = {minify: true, transform: {generateSourceMaps: true}};
|
||||
dependencyData = {
|
||||
dependencies: ['a', 'b', 'c'],
|
||||
dependencyOffsets: [100, 120, 140]
|
||||
dependencyOffsets: [100, 120, 140],
|
||||
};
|
||||
|
||||
extractDependencies.mockImplementation(
|
||||
|
|
|
@ -57,7 +57,7 @@ const plugin = {
|
|||
path.replaceWith(value ? node.right : left);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
UnaryExpression: {
|
||||
exit(path) {
|
||||
|
@ -65,7 +65,7 @@ const plugin = {
|
|||
if (node.operator === '!' && t.isLiteral(node.argument)) {
|
||||
path.replaceWith(t.valueToNode(!node.argument.value));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ function extractDependencies(code: string) {
|
|||
}
|
||||
dependencyOffsets.push(arg.start);
|
||||
dependencies.add(arg.value);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return {dependencyOffsets, dependencies: Array.from(dependencies)};
|
||||
|
|
|
@ -32,7 +32,7 @@ const dev = {name: '__DEV__'};
|
|||
|
||||
const importMap = new Map([['ReactNative', 'react-native']]);
|
||||
|
||||
const isGlobal = (binding) => !binding;
|
||||
const isGlobal = binding => !binding;
|
||||
|
||||
const isToplevelBinding = (binding, isWrappedModule) =>
|
||||
isGlobal(binding) ||
|
||||
|
@ -141,7 +141,7 @@ const inlinePlugin = {
|
|||
|
||||
path.replaceWith(replacement);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ function transformCode(
|
|||
action_name: 'Transforming file',
|
||||
action_phase: 'end',
|
||||
file_name: filename,
|
||||
duration_ms: duration_ms,
|
||||
duration_ms,
|
||||
log_entry_label: 'Transforming file',
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('Graph:', () => {
|
|||
});
|
||||
|
||||
it('calls back an error when called without any entry point', done => {
|
||||
graph([], anyPlatform, {log: quiet}, (error) => {
|
||||
graph([], anyPlatform, {log: quiet}, error => {
|
||||
expect(error).toEqual(any(Error));
|
||||
done();
|
||||
});
|
||||
|
@ -214,11 +214,11 @@ describe('Graph:', () => {
|
|||
|
||||
const ids = [
|
||||
'a',
|
||||
'b',
|
||||
'c', 'd',
|
||||
'e',
|
||||
'f', 'g',
|
||||
'h',
|
||||
'b',
|
||||
'c', 'd',
|
||||
'e',
|
||||
'f', 'g',
|
||||
'h',
|
||||
];
|
||||
ids.forEach(id => {
|
||||
const path = idToPath(id);
|
||||
|
@ -367,7 +367,7 @@ function createFile(id) {
|
|||
function createModule(id, dependencies = []): Module {
|
||||
return {
|
||||
file: createFile(id),
|
||||
dependencies: dependencies.map(createDependency)
|
||||
dependencies: dependencies.map(createDependency),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -126,14 +126,14 @@ function getReplacements(pkg) {
|
|||
|
||||
const main = getMain(pkg);
|
||||
if (typeof rn !== 'object') {
|
||||
rn = { [main]: rn };
|
||||
rn = {[main]: rn};
|
||||
}
|
||||
|
||||
if (typeof browser !== 'object') {
|
||||
browser = { [main]: browser };
|
||||
browser = {[main]: browser};
|
||||
}
|
||||
|
||||
// merge with "browser" as default,
|
||||
// "react-native" as override
|
||||
return { ...browser, ...rn };
|
||||
return {...browser, ...rn};
|
||||
}
|
||||
|
|
|
@ -11,90 +11,90 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import type { // eslint-disable-line sort-requires
|
||||
import type { // eslint-disable-line sort-requires
|
||||
Extensions,
|
||||
Path,
|
||||
} from './node-haste.flow';
|
||||
|
||||
import type {
|
||||
import type {
|
||||
ResolveFn,
|
||||
TransformedFile,
|
||||
} from '../types.flow';
|
||||
|
||||
const DependencyGraphHelpers = require('../../node-haste/DependencyGraph/DependencyGraphHelpers');
|
||||
const HasteFS = require('./HasteFS');
|
||||
const HasteMap = require('../../node-haste/DependencyGraph/HasteMap');
|
||||
const Module = require('./Module');
|
||||
const ModuleCache = require('./ModuleCache');
|
||||
const ResolutionRequest = require('../../node-haste/DependencyGraph/ResolutionRequest');
|
||||
const DependencyGraphHelpers = require('../../node-haste/DependencyGraph/DependencyGraphHelpers');
|
||||
const HasteFS = require('./HasteFS');
|
||||
const HasteMap = require('../../node-haste/DependencyGraph/HasteMap');
|
||||
const Module = require('./Module');
|
||||
const ModuleCache = require('./ModuleCache');
|
||||
const ResolutionRequest = require('../../node-haste/DependencyGraph/ResolutionRequest');
|
||||
|
||||
const defaults = require('../../../defaults');
|
||||
const defaults = require('../../../defaults');
|
||||
|
||||
type ResolveOptions = {|
|
||||
type ResolveOptions = {|
|
||||
assetExts: Extensions,
|
||||
extraNodeModules: {[id: string]: string},
|
||||
transformedFiles: {[path: Path]: TransformedFile},
|
||||
|};
|
||||
|
||||
const platforms = new Set(defaults.platforms);
|
||||
const platforms = new Set(defaults.platforms);
|
||||
|
||||
exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
||||
const {
|
||||
exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
||||
const {
|
||||
assetExts,
|
||||
extraNodeModules,
|
||||
transformedFiles,
|
||||
} = options;
|
||||
const files = Object.keys(transformedFiles);
|
||||
const getTransformedFile =
|
||||
const files = Object.keys(transformedFiles);
|
||||
const getTransformedFile =
|
||||
path => Promise.resolve(
|
||||
transformedFiles[path] || Promise.reject(new Error(`"${path} does not exist`))
|
||||
);
|
||||
|
||||
const helpers = new DependencyGraphHelpers({
|
||||
assetExts,
|
||||
providesModuleNodeModules: defaults.providesModuleNodeModules,
|
||||
});
|
||||
const helpers = new DependencyGraphHelpers({
|
||||
assetExts,
|
||||
providesModuleNodeModules: defaults.providesModuleNodeModules,
|
||||
});
|
||||
|
||||
const hasteFS = new HasteFS(files);
|
||||
const moduleCache = new ModuleCache(
|
||||
const hasteFS = new HasteFS(files);
|
||||
const moduleCache = new ModuleCache(
|
||||
filePath => hasteFS.closest(filePath, 'package.json'),
|
||||
getTransformedFile,
|
||||
);
|
||||
const hasteMap = new HasteMap({
|
||||
extensions: ['js', 'json'],
|
||||
files,
|
||||
helpers,
|
||||
moduleCache,
|
||||
platforms,
|
||||
preferNativePlatform: true,
|
||||
});
|
||||
const hasteMap = new HasteMap({
|
||||
extensions: ['js', 'json'],
|
||||
files,
|
||||
helpers,
|
||||
moduleCache,
|
||||
platforms,
|
||||
preferNativePlatform: true,
|
||||
});
|
||||
|
||||
const hasteMapBuilt = hasteMap.build();
|
||||
const resolutionRequests = {};
|
||||
return (id, source, platform, _, callback) => {
|
||||
let resolutionRequest = resolutionRequests[platform];
|
||||
if (!resolutionRequest) {
|
||||
resolutionRequest = resolutionRequests[platform] = new ResolutionRequest({
|
||||
dirExists: filePath => hasteFS.dirExists(filePath),
|
||||
entryPath: '',
|
||||
extraNodeModules,
|
||||
hasteFS,
|
||||
hasteMap,
|
||||
helpers,
|
||||
moduleCache,
|
||||
platform,
|
||||
platforms,
|
||||
preferNativePlatform: true,
|
||||
});
|
||||
}
|
||||
const hasteMapBuilt = hasteMap.build();
|
||||
const resolutionRequests = {};
|
||||
return (id, source, platform, _, callback) => {
|
||||
let resolutionRequest = resolutionRequests[platform];
|
||||
if (!resolutionRequest) {
|
||||
resolutionRequest = resolutionRequests[platform] = new ResolutionRequest({
|
||||
dirExists: filePath => hasteFS.dirExists(filePath),
|
||||
entryPath: '',
|
||||
extraNodeModules,
|
||||
hasteFS,
|
||||
hasteMap,
|
||||
helpers,
|
||||
moduleCache,
|
||||
platform,
|
||||
platforms,
|
||||
preferNativePlatform: true,
|
||||
});
|
||||
}
|
||||
|
||||
const from = new Module(source, moduleCache, getTransformedFile(source));
|
||||
hasteMapBuilt
|
||||
const from = new Module(source, moduleCache, getTransformedFile(source));
|
||||
hasteMapBuilt
|
||||
.then(() => resolutionRequest.resolveDependency(from, id))
|
||||
.then(
|
||||
// nextTick to escape promise error handling
|
||||
module => process.nextTick(callback, null, module.path),
|
||||
error => process.nextTick(callback, error),
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = (
|
|||
if (file.map) {
|
||||
sections.push({
|
||||
map: file.map,
|
||||
offset: {column: 0, line}
|
||||
offset: {column: 0, line},
|
||||
});
|
||||
}
|
||||
line += countLines(moduleCode);
|
||||
|
|
|
@ -80,6 +80,6 @@ function virtualModule(code: string) {
|
|||
code,
|
||||
path: '',
|
||||
type: 'script',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ describe('optimizing JS modules', () => {
|
|||
const result = optimizeModule(transformResult, optimizationOptions);
|
||||
optimized = result.transformed.default;
|
||||
injectedVars = optimized.code.match(/function\(([^)]*)/)[1].split(',');
|
||||
[,requireName,,, dependencyMapName] = injectedVars;
|
||||
[, requireName,,, dependencyMapName] = injectedVars;
|
||||
});
|
||||
|
||||
it('optimizes code', () => {
|
||||
|
|
|
@ -224,7 +224,7 @@ function createTestData() {
|
|||
if (path.node.callee.name === 'some') {
|
||||
path.replaceWith(path.node.arguments[0]);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return {
|
||||
bodyAst: fileAst.program.body,
|
||||
|
|
|
@ -101,8 +101,8 @@ describe('Resolver', function() {
|
|||
.getDependencies(entry, {platform}, transformOptions);
|
||||
expect(DependencyGraph.prototype.getDependencies).toBeCalledWith({
|
||||
entryPath: entry,
|
||||
platform: platform,
|
||||
transformOptions: transformOptions,
|
||||
platform,
|
||||
transformOptions,
|
||||
recursive: true,
|
||||
});
|
||||
});
|
||||
|
@ -134,7 +134,7 @@ describe('Resolver', function() {
|
|||
return depResolver
|
||||
.getDependencies(
|
||||
'/root/index.js',
|
||||
{ dev: false },
|
||||
{dev: false},
|
||||
undefined,
|
||||
undefined,
|
||||
createGetModuleId()
|
||||
|
@ -147,34 +147,34 @@ describe('Resolver', function() {
|
|||
.createPolyfill
|
||||
.mock
|
||||
.calls
|
||||
.map((call) => call[0]))
|
||||
.map(call => call[0]))
|
||||
.toEqual([
|
||||
{ id: 'polyfills/Object.es6.js',
|
||||
{id: 'polyfills/Object.es6.js',
|
||||
file: 'polyfills/Object.es6.js',
|
||||
dependencies: []
|
||||
dependencies: [],
|
||||
},
|
||||
{ id: 'polyfills/console.js',
|
||||
{id: 'polyfills/console.js',
|
||||
file: 'polyfills/console.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js'
|
||||
'polyfills/Object.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/error-guard.js',
|
||||
{id: 'polyfills/error-guard.js',
|
||||
file: 'polyfills/error-guard.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
'polyfills/console.js'
|
||||
'polyfills/console.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/Number.es6.js',
|
||||
{id: 'polyfills/Number.es6.js',
|
||||
file: 'polyfills/Number.es6.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
'polyfills/console.js',
|
||||
'polyfills/error-guard.js'
|
||||
'polyfills/error-guard.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/String.prototype.es6.js',
|
||||
{id: 'polyfills/String.prototype.es6.js',
|
||||
file: 'polyfills/String.prototype.es6.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -183,7 +183,7 @@ describe('Resolver', function() {
|
|||
'polyfills/Number.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/Array.prototype.es6.js',
|
||||
{id: 'polyfills/Array.prototype.es6.js',
|
||||
file: 'polyfills/Array.prototype.es6.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -193,7 +193,7 @@ describe('Resolver', function() {
|
|||
'polyfills/String.prototype.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/Array.es6.js',
|
||||
{id: 'polyfills/Array.es6.js',
|
||||
file: 'polyfills/Array.es6.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -204,7 +204,7 @@ describe('Resolver', function() {
|
|||
'polyfills/Array.prototype.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/Object.es7.js',
|
||||
{id: 'polyfills/Object.es7.js',
|
||||
file: 'polyfills/Object.es7.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -216,7 +216,7 @@ describe('Resolver', function() {
|
|||
'polyfills/Array.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/babelHelpers.js',
|
||||
{id: 'polyfills/babelHelpers.js',
|
||||
file: 'polyfills/babelHelpers.js',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -232,7 +232,7 @@ describe('Resolver', function() {
|
|||
].map(({id, file, dependencies}) => ({
|
||||
id: pathJoin(__dirname, '..', id),
|
||||
file: pathJoin(__dirname, '..', file),
|
||||
dependencies: dependencies.map((d => pathJoin(__dirname, '..', d))),
|
||||
dependencies: dependencies.map(d => pathJoin(__dirname, '..', d)),
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
@ -257,7 +257,7 @@ describe('Resolver', function() {
|
|||
return depResolver
|
||||
.getDependencies(
|
||||
'/root/index.js',
|
||||
{ dev: true },
|
||||
{dev: true},
|
||||
undefined,
|
||||
undefined,
|
||||
createGetModuleId()
|
||||
|
@ -290,14 +290,14 @@ describe('Resolver', function() {
|
|||
return depResolver
|
||||
.getDependencies(
|
||||
'/root/index.js',
|
||||
{ dev: false },
|
||||
{dev: false},
|
||||
undefined,
|
||||
undefined,
|
||||
createGetModuleId()
|
||||
).then((result) => {
|
||||
).then(result => {
|
||||
expect(result.mainModuleId).toEqual('index');
|
||||
expect(DependencyGraph.prototype.createPolyfill.mock.calls[result.dependencies.length - 2]).toEqual([
|
||||
{ file: 'some module',
|
||||
{file: 'some module',
|
||||
id: 'some module',
|
||||
dependencies: [
|
||||
'polyfills/Object.es6.js',
|
||||
|
@ -309,7 +309,7 @@ describe('Resolver', function() {
|
|||
'polyfills/Array.es6.js',
|
||||
'polyfills/Object.es7.js',
|
||||
'polyfills/babelHelpers.js',
|
||||
].map(d => pathJoin(__dirname, '..', d))
|
||||
].map(d => pathJoin(__dirname, '..', d)),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -64,7 +64,7 @@ class Resolver {
|
|||
forceNodeFilesystemAPI: false,
|
||||
getTransformCacheKey: opts.getTransformCacheKey,
|
||||
globalTransformCache: opts.globalTransformCache,
|
||||
ignoreFilePath: function(filepath) {
|
||||
ignoreFilePath(filepath) {
|
||||
return filepath.indexOf('__tests__') !== -1 ||
|
||||
(opts.blacklistRE != null && opts.blacklistRE.test(filepath));
|
||||
},
|
||||
|
@ -253,7 +253,7 @@ function defineModuleCode(moduleName, code, verboseName = '', dev = true) {
|
|||
return [
|
||||
`__d(/* ${verboseName} */`,
|
||||
'function(global, require, module, exports) {', // module factory
|
||||
code,
|
||||
code,
|
||||
'\n}, ',
|
||||
`${JSON.stringify(moduleName)}`, // module id, null = id map. used in ModuleGraph
|
||||
dev ? `, null, ${JSON.stringify(verboseName)}` : '',
|
||||
|
|
|
@ -31,19 +31,19 @@ let _globalHandler = function onError(e) {
|
|||
* set) globally before requiring anything.
|
||||
*/
|
||||
const ErrorUtils = {
|
||||
setGlobalHandler: function(fun) {
|
||||
setGlobalHandler(fun) {
|
||||
_globalHandler = fun;
|
||||
},
|
||||
getGlobalHandler: function() {
|
||||
getGlobalHandler() {
|
||||
return _globalHandler;
|
||||
},
|
||||
reportError: function(error) {
|
||||
reportError(error) {
|
||||
_globalHandler && _globalHandler(error);
|
||||
},
|
||||
reportFatalError: function(error) {
|
||||
reportFatalError(error) {
|
||||
_globalHandler && _globalHandler(error, true);
|
||||
},
|
||||
applyWithGuard: function(fun, context, args) {
|
||||
applyWithGuard(fun, context, args) {
|
||||
try {
|
||||
_inGuard++;
|
||||
return fun.apply(context, args);
|
||||
|
@ -53,17 +53,17 @@ const ErrorUtils = {
|
|||
_inGuard--;
|
||||
}
|
||||
},
|
||||
applyWithGuardIfNeeded: function(fun, context, args) {
|
||||
applyWithGuardIfNeeded(fun, context, args) {
|
||||
if (ErrorUtils.inGuard()) {
|
||||
return fun.apply(context, args);
|
||||
} else {
|
||||
ErrorUtils.applyWithGuard(fun, context, args);
|
||||
}
|
||||
},
|
||||
inGuard: function() {
|
||||
inGuard() {
|
||||
return _inGuard;
|
||||
},
|
||||
guard: function(fun, name, context) {
|
||||
guard(fun, name, context) {
|
||||
if (typeof fun !== 'function') {
|
||||
console.warn('A function must be passed to ErrorUtils.guard, got ', fun);
|
||||
return null;
|
||||
|
@ -82,7 +82,7 @@ const ErrorUtils = {
|
|||
}
|
||||
|
||||
return guarded;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
global.ErrorUtils = ErrorUtils;
|
||||
|
|
|
@ -12,28 +12,28 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
declare var __DEV__: boolean;
|
||||
declare var __DEV__: boolean;
|
||||
|
||||
type DependencyMap = Array<ModuleID>;
|
||||
type Exports = any;
|
||||
type FactoryFn = (
|
||||
type DependencyMap = Array<ModuleID>;
|
||||
type Exports = any;
|
||||
type FactoryFn = (
|
||||
global: Object,
|
||||
require: RequireFn,
|
||||
moduleObject: {exports: {}},
|
||||
exports: {},
|
||||
dependencyMap: ?DependencyMap,
|
||||
) => void;
|
||||
type HotModuleReloadingAcceptFn = Function;
|
||||
type HotModuleReloadingData = {|
|
||||
type HotModuleReloadingAcceptFn = Function;
|
||||
type HotModuleReloadingData = {|
|
||||
acceptCallback: ?HotModuleReloadingAcceptFn,
|
||||
accept: (callback: HotModuleReloadingAcceptFn) => void,
|
||||
|};
|
||||
type Module = {
|
||||
type Module = {
|
||||
exports: Exports,
|
||||
hot?: HotModuleReloadingData,
|
||||
};
|
||||
type ModuleID = number;
|
||||
type ModuleDefinition = {|
|
||||
type ModuleID = number;
|
||||
type ModuleDefinition = {|
|
||||
dependencyMap: ?DependencyMap,
|
||||
exports: Exports,
|
||||
factory: FactoryFn,
|
||||
|
@ -42,246 +42,246 @@ type ModuleDefinition = {|
|
|||
isInitialized: boolean,
|
||||
verboseName?: string,
|
||||
|};
|
||||
type ModuleMap =
|
||||
type ModuleMap =
|
||||
{[key: ModuleID]: (ModuleDefinition)};
|
||||
type RequireFn = (id: ModuleID | VerboseModuleNameForDev) => Exports;
|
||||
type VerboseModuleNameForDev = string;
|
||||
type RequireFn = (id: ModuleID | VerboseModuleNameForDev) => Exports;
|
||||
type VerboseModuleNameForDev = string;
|
||||
|
||||
global.require = require;
|
||||
global.__d = define;
|
||||
global.require = require;
|
||||
global.__d = define;
|
||||
|
||||
const modules: ModuleMap = Object.create(null);
|
||||
if (__DEV__) {
|
||||
var verboseNamesToModuleIds: {[key: string]: number} = Object.create(null);
|
||||
}
|
||||
const modules: ModuleMap = Object.create(null);
|
||||
if (__DEV__) {
|
||||
var verboseNamesToModuleIds: {[key: string]: number} = Object.create(null);
|
||||
}
|
||||
|
||||
function define(
|
||||
function define(
|
||||
factory: FactoryFn,
|
||||
moduleId: number,
|
||||
dependencyMap?: DependencyMap,
|
||||
) {
|
||||
if (moduleId in modules) {
|
||||
if (moduleId in modules) {
|
||||
// prevent repeated calls to `global.nativeRequire` to overwrite modules
|
||||
// that are already loaded
|
||||
return;
|
||||
}
|
||||
modules[moduleId] = {
|
||||
dependencyMap,
|
||||
exports: undefined,
|
||||
factory,
|
||||
hasError: false,
|
||||
isInitialized: false,
|
||||
};
|
||||
if (__DEV__) {
|
||||
return;
|
||||
}
|
||||
modules[moduleId] = {
|
||||
dependencyMap,
|
||||
exports: undefined,
|
||||
factory,
|
||||
hasError: false,
|
||||
isInitialized: false,
|
||||
};
|
||||
if (__DEV__) {
|
||||
// HMR
|
||||
modules[moduleId].hot = createHotReloadingObject();
|
||||
modules[moduleId].hot = createHotReloadingObject();
|
||||
|
||||
// DEBUGGABLE MODULES NAMES
|
||||
// we take `verboseName` from `arguments` to avoid an unused named parameter
|
||||
// in `define` in production.
|
||||
const verboseName: string | void = arguments[3];
|
||||
if (verboseName) {
|
||||
modules[moduleId].verboseName = verboseName;
|
||||
verboseNamesToModuleIds[verboseName] = moduleId;
|
||||
}
|
||||
}
|
||||
}
|
||||
const verboseName: string | void = arguments[3];
|
||||
if (verboseName) {
|
||||
modules[moduleId].verboseName = verboseName;
|
||||
verboseNamesToModuleIds[verboseName] = moduleId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function require(moduleId: ModuleID | VerboseModuleNameForDev) {
|
||||
if (__DEV__ && typeof moduleId === 'string') {
|
||||
const verboseName = moduleId;
|
||||
moduleId = verboseNamesToModuleIds[moduleId];
|
||||
if (moduleId == null) {
|
||||
throw new Error(`Unknown named module: '${verboseName}'`);
|
||||
} else {
|
||||
console.warn(
|
||||
function require(moduleId: ModuleID | VerboseModuleNameForDev) {
|
||||
if (__DEV__ && typeof moduleId === 'string') {
|
||||
const verboseName = moduleId;
|
||||
moduleId = verboseNamesToModuleIds[moduleId];
|
||||
if (moduleId == null) {
|
||||
throw new Error(`Unknown named module: '${verboseName}'`);
|
||||
} else {
|
||||
console.warn(
|
||||
`Requiring module '${verboseName}' by name is only supported for ` +
|
||||
'debugging purposes and will BREAK IN PRODUCTION!'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$FlowFixMe: at this point we know that moduleId is a number
|
||||
const moduleIdReallyIsNumber: number = moduleId;
|
||||
const module = modules[moduleIdReallyIsNumber];
|
||||
return module && module.isInitialized
|
||||
const moduleIdReallyIsNumber: number = moduleId;
|
||||
const module = modules[moduleIdReallyIsNumber];
|
||||
return module && module.isInitialized
|
||||
? module.exports
|
||||
: guardedLoadModule(moduleIdReallyIsNumber, module);
|
||||
}
|
||||
}
|
||||
|
||||
let inGuard = false;
|
||||
function guardedLoadModule(moduleId: ModuleID , module) {
|
||||
if (!inGuard && global.ErrorUtils) {
|
||||
inGuard = true;
|
||||
let returnValue;
|
||||
try {
|
||||
returnValue = loadModuleImplementation(moduleId, module);
|
||||
} catch (e) {
|
||||
global.ErrorUtils.reportFatalError(e);
|
||||
}
|
||||
inGuard = false;
|
||||
return returnValue;
|
||||
} else {
|
||||
return loadModuleImplementation(moduleId, module);
|
||||
}
|
||||
}
|
||||
let inGuard = false;
|
||||
function guardedLoadModule(moduleId: ModuleID, module) {
|
||||
if (!inGuard && global.ErrorUtils) {
|
||||
inGuard = true;
|
||||
let returnValue;
|
||||
try {
|
||||
returnValue = loadModuleImplementation(moduleId, module);
|
||||
} catch (e) {
|
||||
global.ErrorUtils.reportFatalError(e);
|
||||
}
|
||||
inGuard = false;
|
||||
return returnValue;
|
||||
} else {
|
||||
return loadModuleImplementation(moduleId, module);
|
||||
}
|
||||
}
|
||||
|
||||
function loadModuleImplementation(moduleId, module) {
|
||||
const nativeRequire = global.nativeRequire;
|
||||
if (!module && nativeRequire) {
|
||||
nativeRequire(moduleId);
|
||||
module = modules[moduleId];
|
||||
}
|
||||
function loadModuleImplementation(moduleId, module) {
|
||||
const nativeRequire = global.nativeRequire;
|
||||
if (!module && nativeRequire) {
|
||||
nativeRequire(moduleId);
|
||||
module = modules[moduleId];
|
||||
}
|
||||
|
||||
if (!module) {
|
||||
throw unknownModuleError(moduleId);
|
||||
}
|
||||
if (!module) {
|
||||
throw unknownModuleError(moduleId);
|
||||
}
|
||||
|
||||
if (module.hasError) {
|
||||
throw moduleThrewError(moduleId);
|
||||
}
|
||||
if (module.hasError) {
|
||||
throw moduleThrewError(moduleId);
|
||||
}
|
||||
|
||||
// `require` calls int the require polyfill itself are not analyzed and
|
||||
// replaced so that they use numeric module IDs.
|
||||
// The systrace module will expose itself on the require function so that
|
||||
// it can be used here.
|
||||
// TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
|
||||
if (__DEV__) {
|
||||
var {Systrace} = require;
|
||||
}
|
||||
if (__DEV__) {
|
||||
var {Systrace} = require;
|
||||
}
|
||||
|
||||
// We must optimistically mark module as initialized before running the
|
||||
// factory to keep any require cycles inside the factory from causing an
|
||||
// infinite require loop.
|
||||
module.isInitialized = true;
|
||||
const exports = module.exports = {};
|
||||
const {factory, dependencyMap} = module;
|
||||
try {
|
||||
if (__DEV__) {
|
||||
module.isInitialized = true;
|
||||
const exports = module.exports = {};
|
||||
const {factory, dependencyMap} = module;
|
||||
try {
|
||||
if (__DEV__) {
|
||||
// $FlowFixMe: we know that __DEV__ is const and `Systrace` exists
|
||||
Systrace.beginEvent('JS_require_' + (module.verboseName || moduleId));
|
||||
}
|
||||
Systrace.beginEvent('JS_require_' + (module.verboseName || moduleId));
|
||||
}
|
||||
|
||||
const moduleObject: Module = {exports};
|
||||
if (__DEV__ && module.hot) {
|
||||
moduleObject.hot = module.hot;
|
||||
}
|
||||
const moduleObject: Module = {exports};
|
||||
if (__DEV__ && module.hot) {
|
||||
moduleObject.hot = module.hot;
|
||||
}
|
||||
|
||||
// keep args in sync with with defineModuleCode in
|
||||
// packager/src//Resolver/index.js
|
||||
// and packager/src//ModuleGraph/worker.js
|
||||
factory(global, require, moduleObject, exports, dependencyMap);
|
||||
factory(global, require, moduleObject, exports, dependencyMap);
|
||||
|
||||
// avoid removing factory in DEV mode as it breaks HMR
|
||||
if (!__DEV__) {
|
||||
if (!__DEV__) {
|
||||
// $FlowFixMe: This is only sound because we never access `factory` again
|
||||
module.factory = undefined;
|
||||
}
|
||||
module.factory = undefined;
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
if (__DEV__) {
|
||||
// $FlowFixMe: we know that __DEV__ is const and `Systrace` exists
|
||||
Systrace.endEvent();
|
||||
}
|
||||
return (module.exports = moduleObject.exports);
|
||||
} catch (e) {
|
||||
module.hasError = true;
|
||||
module.isInitialized = false;
|
||||
module.exports = undefined;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
Systrace.endEvent();
|
||||
}
|
||||
return (module.exports = moduleObject.exports);
|
||||
} catch (e) {
|
||||
module.hasError = true;
|
||||
module.isInitialized = false;
|
||||
module.exports = undefined;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function unknownModuleError(id) {
|
||||
let message = 'Requiring unknown module "' + id + '".';
|
||||
if (__DEV__) {
|
||||
message +=
|
||||
function unknownModuleError(id) {
|
||||
let message = 'Requiring unknown module "' + id + '".';
|
||||
if (__DEV__) {
|
||||
message +=
|
||||
'If you are sure the module is there, try restarting the packager or running "npm install".';
|
||||
}
|
||||
return Error(message);
|
||||
}
|
||||
}
|
||||
return Error(message);
|
||||
}
|
||||
|
||||
function moduleThrewError(id) {
|
||||
return Error('Requiring module "' + id + '", which threw an exception.');
|
||||
}
|
||||
function moduleThrewError(id) {
|
||||
return Error('Requiring module "' + id + '", which threw an exception.');
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
require.Systrace = { beginEvent: () => {}, endEvent: () => {} };
|
||||
if (__DEV__) {
|
||||
require.Systrace = {beginEvent: () => {}, endEvent: () => {}};
|
||||
|
||||
// HOT MODULE RELOADING
|
||||
var createHotReloadingObject = function() {
|
||||
const hot: HotModuleReloadingData = {
|
||||
acceptCallback: null,
|
||||
accept: callback => { hot.acceptCallback = callback; },
|
||||
};
|
||||
return hot;
|
||||
};
|
||||
var createHotReloadingObject = function() {
|
||||
const hot: HotModuleReloadingData = {
|
||||
acceptCallback: null,
|
||||
accept: callback => { hot.acceptCallback = callback; },
|
||||
};
|
||||
return hot;
|
||||
};
|
||||
|
||||
const acceptAll = function(
|
||||
const acceptAll = function(
|
||||
dependentModules,
|
||||
inverseDependencies,
|
||||
) {
|
||||
if (!dependentModules || dependentModules.length === 0) {
|
||||
return true;
|
||||
}
|
||||
if (!dependentModules || dependentModules.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const notAccepted = dependentModules.filter(
|
||||
const notAccepted = dependentModules.filter(
|
||||
module => !accept(module, /*factory*/ undefined, inverseDependencies));
|
||||
|
||||
const parents = [];
|
||||
for (let i = 0; i < notAccepted.length; i++) {
|
||||
const parents = [];
|
||||
for (let i = 0; i < notAccepted.length; i++) {
|
||||
// if the module has no parents then the change cannot be hot loaded
|
||||
if (inverseDependencies[notAccepted[i]].length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (inverseDependencies[notAccepted[i]].length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
parents.push(...inverseDependencies[notAccepted[i]]);
|
||||
}
|
||||
parents.push(...inverseDependencies[notAccepted[i]]);
|
||||
}
|
||||
|
||||
return acceptAll(parents, inverseDependencies);
|
||||
};
|
||||
return acceptAll(parents, inverseDependencies);
|
||||
};
|
||||
|
||||
const accept = function(
|
||||
const accept = function(
|
||||
id: ModuleID,
|
||||
factory?: FactoryFn,
|
||||
inverseDependencies: {[key: ModuleID]: Array<ModuleID>},
|
||||
) {
|
||||
const mod = modules[id];
|
||||
const mod = modules[id];
|
||||
|
||||
if (!mod && factory) { // new modules need a factory
|
||||
define(factory, id);
|
||||
return true; // new modules don't need to be accepted
|
||||
}
|
||||
if (!mod && factory) { // new modules need a factory
|
||||
define(factory, id);
|
||||
return true; // new modules don't need to be accepted
|
||||
}
|
||||
|
||||
const {hot} = mod;
|
||||
if (!hot) {
|
||||
console.warn(
|
||||
const {hot} = mod;
|
||||
if (!hot) {
|
||||
console.warn(
|
||||
'Cannot accept module because Hot Module Replacement ' +
|
||||
'API was not installed.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// replace and initialize factory
|
||||
if (factory) {
|
||||
mod.factory = factory;
|
||||
}
|
||||
mod.hasError = false;
|
||||
mod.isInitialized = false;
|
||||
require(id);
|
||||
if (factory) {
|
||||
mod.factory = factory;
|
||||
}
|
||||
mod.hasError = false;
|
||||
mod.isInitialized = false;
|
||||
require(id);
|
||||
|
||||
if (hot.acceptCallback) {
|
||||
hot.acceptCallback();
|
||||
return true;
|
||||
} else {
|
||||
if (hot.acceptCallback) {
|
||||
hot.acceptCallback();
|
||||
return true;
|
||||
} else {
|
||||
// need to have inverseDependencies to bubble up accept
|
||||
if (!inverseDependencies) {
|
||||
throw new Error('Undefined `inverseDependencies`');
|
||||
}
|
||||
if (!inverseDependencies) {
|
||||
throw new Error('Undefined `inverseDependencies`');
|
||||
}
|
||||
|
||||
// accept parent modules recursively up until all siblings are accepted
|
||||
return acceptAll(inverseDependencies[id], inverseDependencies);
|
||||
}
|
||||
};
|
||||
return acceptAll(inverseDependencies[id], inverseDependencies);
|
||||
}
|
||||
};
|
||||
|
||||
global.__accept = accept;
|
||||
}
|
||||
global.__accept = accept;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class MultipartResponse {
|
|||
|
||||
static serializeHeaders(headers) {
|
||||
return Object.keys(headers)
|
||||
.map((key) => `${key}: ${headers[key]}`)
|
||||
.map(key => `${key}: ${headers[key]}`)
|
||||
.join(CRLF);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,8 +133,8 @@ function mockNodeResponse() {
|
|||
headers = {...headers, ...hdrs};
|
||||
}),
|
||||
setHeader: jest.fn((key, val) => { headers[key] = val; }),
|
||||
write: jest.fn((data) => { body += data; }),
|
||||
end: jest.fn((data) => { body += (data || ''); }),
|
||||
write: jest.fn(data => { body += data; }),
|
||||
end: jest.fn(data => { body += (data || ''); }),
|
||||
|
||||
// For testing only
|
||||
toString() {
|
||||
|
@ -144,7 +144,6 @@ function mockNodeResponse() {
|
|||
'',
|
||||
body,
|
||||
].join('\r\n');
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
jest.disableAutomock();
|
||||
|
||||
jest.mock('worker-farm', () => () => () => {})
|
||||
.mock('timers', () => ({ setImmediate: (fn) => setTimeout(fn, 0) }))
|
||||
.mock('timers', () => ({setImmediate: fn => setTimeout(fn, 0)}))
|
||||
.mock('uglify-js')
|
||||
.mock('crypto')
|
||||
.mock(
|
||||
|
@ -39,16 +39,16 @@ describe('processRequest', () => {
|
|||
let server;
|
||||
|
||||
const options = {
|
||||
projectRoots: ['root'],
|
||||
blacklistRE: null,
|
||||
cacheVersion: null,
|
||||
polyfillModuleNames: null,
|
||||
reporter: require('../../lib/reporting').nullReporter,
|
||||
projectRoots: ['root'],
|
||||
blacklistRE: null,
|
||||
cacheVersion: null,
|
||||
polyfillModuleNames: null,
|
||||
reporter: require('../../lib/reporting').nullReporter,
|
||||
};
|
||||
|
||||
const makeRequest = (reqHandler, requrl, reqOptions) => new Promise(resolve =>
|
||||
reqHandler(
|
||||
{ url: requrl, headers:{}, ...reqOptions },
|
||||
{url: requrl, headers:{}, ...reqOptions},
|
||||
{
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
|
@ -60,7 +60,7 @@ describe('processRequest', () => {
|
|||
resolve(this);
|
||||
},
|
||||
},
|
||||
{ next: () => {} },
|
||||
{next: () => {}},
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -122,7 +122,7 @@ describe('processRequest', () => {
|
|||
return makeRequest(
|
||||
requestHandler,
|
||||
'mybundle.bundle?runModule=true',
|
||||
{ headers : { 'if-none-match' : 'this is an etag' } }
|
||||
{headers : {'if-none-match' : 'this is an etag'}}
|
||||
).then(response => {
|
||||
expect(response.statusCode).toEqual(304);
|
||||
});
|
||||
|
@ -328,7 +328,7 @@ describe('processRequest', () => {
|
|||
expect(bundleFunc.mock.calls.length).toBe(2);
|
||||
});
|
||||
jest.runAllTicks();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('/onchange endpoint', () => {
|
||||
|
@ -342,7 +342,7 @@ describe('processRequest', () => {
|
|||
req.url = '/onchange';
|
||||
res = {
|
||||
writeHead: jest.fn(),
|
||||
end: jest.fn()
|
||||
end: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -422,7 +422,7 @@ describe('processRequest', () => {
|
|||
describe('buildbundle(options)', () => {
|
||||
it('Calls the bundler with the correct args', () => {
|
||||
return server.buildBundle({
|
||||
entryFile: 'foo file'
|
||||
entryFile: 'foo file',
|
||||
}).then(() =>
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith({
|
||||
entryFile: 'foo file',
|
||||
|
@ -510,7 +510,7 @@ describe('processRequest', () => {
|
|||
return makeRequest(
|
||||
requestHandler,
|
||||
'/symbolicate',
|
||||
{ rawBody: body }
|
||||
{rawBody: body}
|
||||
).then(response => {
|
||||
expect(response.statusCode).toEqual(500);
|
||||
expect(JSON.parse(response.body)).toEqual({
|
||||
|
|
|
@ -44,7 +44,7 @@ const {
|
|||
|
||||
function debounceAndBatch(fn, delay) {
|
||||
let timeout, args = [];
|
||||
return (value) => {
|
||||
return value => {
|
||||
args.push(value);
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
|
@ -434,7 +434,7 @@ class Server {
|
|||
|
||||
watchers.forEach(function(w) {
|
||||
w.res.writeHead(205, headers);
|
||||
w.res.end(JSON.stringify({ changed: true }));
|
||||
w.res.end(JSON.stringify({changed: true}));
|
||||
});
|
||||
|
||||
this._changeWatchers = [];
|
||||
|
@ -474,8 +474,8 @@ class Server {
|
|||
const watchers = this._changeWatchers;
|
||||
|
||||
watchers.push({
|
||||
req: req,
|
||||
res: res,
|
||||
req,
|
||||
res,
|
||||
});
|
||||
|
||||
req.on('close', () => {
|
||||
|
@ -548,7 +548,7 @@ class Server {
|
|||
|
||||
optionsHash(options: {}) {
|
||||
// onProgress is a function, can't be serialized
|
||||
return JSON.stringify(Object.assign({}, options, { onProgress: null }));
|
||||
return JSON.stringify(Object.assign({}, options, {onProgress: null}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -670,11 +670,11 @@ class Server {
|
|||
|
||||
debug('Successfully updated existing bundle');
|
||||
return bundle;
|
||||
});
|
||||
}).catch(e => {
|
||||
debug('Failed to update existing bundle, rebuilding...', e.stack || e.message);
|
||||
return bundleFromScratch();
|
||||
});
|
||||
}).catch(e => {
|
||||
debug('Failed to update existing bundle, rebuilding...', e.stack || e.message);
|
||||
return bundleFromScratch();
|
||||
});
|
||||
return this._reportBundlePromise(options, bundlePromise);
|
||||
} else {
|
||||
debug('Using cached bundle');
|
||||
|
@ -834,7 +834,7 @@ class Server {
|
|||
}).then(
|
||||
stack => {
|
||||
debug('Symbolication done');
|
||||
res.end(JSON.stringify({stack: stack}));
|
||||
res.end(JSON.stringify({stack}));
|
||||
process.nextTick(() => {
|
||||
log(createActionEndEntry(symbolicatingLogEntry));
|
||||
});
|
||||
|
@ -941,7 +941,7 @@ class Server {
|
|||
query: urlObj.query,
|
||||
search: urlObj.search,
|
||||
}),
|
||||
entryFile: entryFile,
|
||||
entryFile,
|
||||
dev,
|
||||
minify,
|
||||
hot: this._getBoolOptionFromQuery(urlObj.query, 'hot', false),
|
||||
|
@ -951,7 +951,7 @@ class Server {
|
|||
'inlineSourceMap',
|
||||
false
|
||||
),
|
||||
platform: platform,
|
||||
platform,
|
||||
entryModuleOnly: this._getBoolOptionFromQuery(
|
||||
urlObj.query,
|
||||
'entryModuleOnly',
|
||||
|
|
|
@ -53,7 +53,7 @@ function startupChild(socket) {
|
|||
child.removeAllListeners();
|
||||
resolve(child);
|
||||
});
|
||||
child.send(socket);
|
||||
child.send(socket);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -43,23 +43,23 @@ function symbolicateStack(data) {
|
|||
}
|
||||
|
||||
function mapFrame(frame, consumers) {
|
||||
const sourceUrl = frame.file;
|
||||
const consumer = consumers.get(sourceUrl);
|
||||
if (consumer == null) {
|
||||
return frame;
|
||||
}
|
||||
const original = consumer.originalPositionFor({
|
||||
line: frame.lineNumber,
|
||||
column: frame.column,
|
||||
});
|
||||
if (!original) {
|
||||
return frame;
|
||||
}
|
||||
return Object.assign({}, frame, {
|
||||
file: original.source,
|
||||
lineNumber: original.line,
|
||||
column: original.column,
|
||||
});
|
||||
const sourceUrl = frame.file;
|
||||
const consumer = consumers.get(sourceUrl);
|
||||
if (consumer == null) {
|
||||
return frame;
|
||||
}
|
||||
const original = consumer.originalPositionFor({
|
||||
line: frame.lineNumber,
|
||||
column: frame.column,
|
||||
});
|
||||
if (!original) {
|
||||
return frame;
|
||||
}
|
||||
return Object.assign({}, frame, {
|
||||
file: original.source,
|
||||
lineNumber: original.line,
|
||||
column: original.column,
|
||||
});
|
||||
}
|
||||
|
||||
function makeErrorMessage(error) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class TerminalReporter {
|
|||
constructor() {
|
||||
this._dependencyGraphHasLoaded = false;
|
||||
this._activeBundles = new Map();
|
||||
this._scheduleUpdateBundleProgress = throttle((data) => {
|
||||
this._scheduleUpdateBundleProgress = throttle(data => {
|
||||
this.update({...data, type: 'bundle_transform_progressed_throttled'});
|
||||
}, 200);
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ export type GetTransformCacheKey = (sourceCode: string, filename: string, option
|
|||
* will be, for example, installed in a different `node_modules/` folder for
|
||||
* different projects.
|
||||
*/
|
||||
const getCacheDirPath = (function () {
|
||||
const getCacheDirPath = (function() {
|
||||
let dirPath;
|
||||
return function () {
|
||||
return function() {
|
||||
if (dirPath == null) {
|
||||
dirPath = path.join(
|
||||
require('os').tmpdir(),
|
||||
|
@ -351,5 +351,5 @@ module.exports = {
|
|||
const msg = result ? 'Cache hit: ' : 'Cache miss: ';
|
||||
debugRead(msg + props.filePath);
|
||||
return result;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ const mock = {
|
|||
},
|
||||
};
|
||||
|
||||
const transformCacheKeyOf = (props) =>
|
||||
const transformCacheKeyOf = props =>
|
||||
props.filePath + '-' + imurmurhash(props.sourceCode)
|
||||
.hash(props.getTransformCacheKey(props.sourceCode, props.filePath, props.transformOptions))
|
||||
.hash(jsonStableStringify(props.transformOptions || {}))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
module.exports = function(declared) {
|
||||
return function(opts) {
|
||||
for (var p in declared) {
|
||||
if (opts[p] == null && declared[p].default != null){
|
||||
if (opts[p] == null && declared[p].default != null) {
|
||||
opts[p] = declared[p].default;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('BatchProcessor', () => {
|
|||
const batches = [];
|
||||
let concurrency = 0;
|
||||
let maxConcurrency = 0;
|
||||
const bp = new BatchProcessor(options, (items) => new Promise(resolve => {
|
||||
const bp = new BatchProcessor(options, items => new Promise(resolve => {
|
||||
++concurrency;
|
||||
expect(concurrency).toBeLessThanOrEqual(options.concurrency);
|
||||
maxConcurrency = Math.max(maxConcurrency, concurrency);
|
||||
|
@ -55,7 +55,7 @@ describe('BatchProcessor', () => {
|
|||
|
||||
it('report errors', async () => {
|
||||
const error = new Error('oh noes');
|
||||
const bp = new BatchProcessor(options, (items) => new Promise((_, reject) => {
|
||||
const bp = new BatchProcessor(options, items => new Promise((_, reject) => {
|
||||
setTimeout(reject.bind(null, error), 0);
|
||||
}));
|
||||
let receivedError;
|
||||
|
|
|
@ -30,7 +30,7 @@ jest.mock('fs', () => ({
|
|||
readdirSync(dirPath) {
|
||||
// Not required for it to work.
|
||||
return [];
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('write-file-atomic', () => ({
|
||||
|
|
|
@ -22,13 +22,13 @@ describe('declareOpts', function() {
|
|||
age: {
|
||||
type: 'number',
|
||||
default: 21,
|
||||
}
|
||||
},
|
||||
});
|
||||
var opts = validate({ name: 'fooer' });
|
||||
var opts = validate({name: 'fooer'});
|
||||
|
||||
expect(opts).toEqual({
|
||||
name: 'fooer',
|
||||
age: 21
|
||||
age: 21,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -41,12 +41,12 @@ describe('declareOpts', function() {
|
|||
stuff: {
|
||||
type: 'object',
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var opts = validate({ things: [1, 2, 3], stuff: {hai: 1} });
|
||||
var opts = validate({things: [1, 2, 3], stuff: {hai: 1}});
|
||||
expect(opts).toEqual({
|
||||
things: [1,2,3],
|
||||
things: [1, 2, 3],
|
||||
stuff: {hai: 1},
|
||||
});
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ describe('declareOpts', function() {
|
|||
foo: {
|
||||
required: true,
|
||||
type: 'number',
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
|
@ -68,8 +68,8 @@ describe('declareOpts', function() {
|
|||
var validate = declareOpts({
|
||||
foo: {
|
||||
required: true,
|
||||
type: 'number'
|
||||
}
|
||||
type: 'number',
|
||||
},
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
|
@ -82,7 +82,7 @@ describe('declareOpts', function() {
|
|||
foo: {
|
||||
required: true,
|
||||
type: 'number',
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
const path = require('path');
|
||||
|
||||
import type { MixedSourceMap } from './SourceMap';
|
||||
import type {MixedSourceMap} from './SourceMap';
|
||||
|
||||
function relativizeSourceMapInternal(sourceMap: any, sourcesRoot: string) {
|
||||
if (sourceMap.sections) {
|
||||
|
|
|
@ -26,7 +26,7 @@ class AssetModule extends Module {
|
|||
|
||||
constructor(args: ConstructorArgs & {dependencies: Array<string>}, platforms: Set<string>) {
|
||||
super(args);
|
||||
const { resolution, name, type } = getAssetDataFromName(this.path, platforms);
|
||||
const {resolution, name, type} = getAssetDataFromName(this.path, platforms);
|
||||
this.resolution = resolution;
|
||||
this._name = name;
|
||||
this._type = type;
|
||||
|
|
|
@ -268,7 +268,7 @@ describe('Cache', () => {
|
|||
});
|
||||
|
||||
describe('writing cache to disk', () => {
|
||||
it('should write cache to disk', (done) => {
|
||||
it('should write cache to disk', done => {
|
||||
var index = 0;
|
||||
var mtimes = [10, 20, 30];
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class DependencyGraphHelpers {
|
|||
_providesModuleNodeModules: Array<string>;
|
||||
_assetExts: Array<string>;
|
||||
|
||||
constructor({ providesModuleNodeModules, assetExts }: {
|
||||
constructor({providesModuleNodeModules, assetExts}: {
|
||||
providesModuleNodeModules: Array<string>,
|
||||
assetExts: Array<string>,
|
||||
}) {
|
||||
|
|
|
@ -83,7 +83,7 @@ class ResolutionRequest {
|
|||
}
|
||||
|
||||
_tryResolve(action: () => Promise<string>, secondaryAction: () => ?Promise<string>) {
|
||||
return action().catch((error) => {
|
||||
return action().catch(error => {
|
||||
if (error.type !== 'UnableToResolveError') {
|
||||
throw error;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class ResolutionRequest {
|
|||
return Promise.resolve(this._immediateResolutionCache[resHash]);
|
||||
}
|
||||
|
||||
const cacheResult = (result) => {
|
||||
const cacheResult = result => {
|
||||
this._immediateResolutionCache[resHash] = result;
|
||||
return result;
|
||||
};
|
||||
|
@ -229,7 +229,7 @@ class ResolutionRequest {
|
|||
p = Promise.resolve(toModuleName);
|
||||
}
|
||||
|
||||
return p.then((realModuleName) => {
|
||||
return p.then(realModuleName => {
|
||||
let dep = this._hasteMap.getModule(realModuleName, this._platform);
|
||||
if (dep && dep.type === 'Module') {
|
||||
return dep;
|
||||
|
@ -453,7 +453,7 @@ class ResolutionRequest {
|
|||
if (this._hasteFS.exists(packageJsonPath)) {
|
||||
return this._moduleCache.getPackage(packageJsonPath)
|
||||
.getMain().then(
|
||||
(main) => this._tryResolve(
|
||||
main => this._tryResolve(
|
||||
() => this._loadAsFile(main, fromModule, toModule),
|
||||
() => this._loadAsDir(main, fromModule, toModule)
|
||||
)
|
||||
|
|
|
@ -152,19 +152,19 @@ function getReplacements(pkg) {
|
|||
if (typeof rn === 'string') {
|
||||
/* $FlowFixMe: It is likely unsafe to assume all packages would
|
||||
* contain a "main" */
|
||||
rn = { [pkg.main]: rn };
|
||||
rn = {[pkg.main]: rn};
|
||||
}
|
||||
|
||||
if (typeof browser === 'string') {
|
||||
/* $FlowFixMe: It is likely unsafe to assume all packages would
|
||||
* contain a "main" */
|
||||
browser = { [pkg.main]: browser };
|
||||
browser = {[pkg.main]: browser};
|
||||
}
|
||||
|
||||
// merge with "browser" as default,
|
||||
// "react-native" as override
|
||||
// $FlowFixMe(>=0.35.0) browser and rn should be objects
|
||||
return { ...browser, ...rn };
|
||||
return {...browser, ...rn};
|
||||
}
|
||||
|
||||
module.exports = Package;
|
||||
|
|
|
@ -39,7 +39,7 @@ fs.realpath.mockImplementation((filepath, callback) => {
|
|||
callback(null, filepath);
|
||||
});
|
||||
|
||||
fs.readdirSync.mockImplementation((filepath) => Object.keys(getToNode(filepath)));
|
||||
fs.readdirSync.mockImplementation(filepath => Object.keys(getToNode(filepath)));
|
||||
|
||||
fs.readdir.mockImplementation((filepath, callback) => {
|
||||
callback = asyncCallback(callback);
|
||||
|
@ -213,7 +213,7 @@ fs.createReadStream.mockImplementation(filepath => {
|
|||
read() {
|
||||
this.push(file, 'utf8');
|
||||
this.push(null);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -226,7 +226,7 @@ fs.createWriteStream.mockImplementation(file => {
|
|||
const writeStream = new stream.Writable({
|
||||
write(chunk) {
|
||||
this.__chunks.push(chunk);
|
||||
}
|
||||
},
|
||||
});
|
||||
writeStream.__file = file;
|
||||
writeStream.__chunks = [];
|
||||
|
@ -240,7 +240,7 @@ fs.createWriteStream.mockImplementation(file => {
|
|||
});
|
||||
fs.createWriteStream.mock.returned = [];
|
||||
|
||||
fs.__setMockFilesystem = (object) => (filesystem = object);
|
||||
fs.__setMockFilesystem = object => (filesystem = object);
|
||||
|
||||
function getToNode(filepath) {
|
||||
// Ignore the drive for Windows paths.
|
||||
|
@ -256,7 +256,7 @@ function getToNode(filepath) {
|
|||
throw new Error('Make sure all paths are absolute.');
|
||||
}
|
||||
let node = filesystem;
|
||||
parts.slice(1).forEach((part) => {
|
||||
parts.slice(1).forEach(part => {
|
||||
if (node && node.SYMLINK) {
|
||||
node = getToNode(node.SYMLINK);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('DependencyGraph', function() {
|
|||
function getOrderedDependenciesAsJSON(dgraph, entryPath, platform, recursive = true) {
|
||||
return dgraph.getDependencies({entryPath, platform, recursive})
|
||||
.then(response => response.finalize())
|
||||
.then(({ dependencies }) => Promise.all(dependencies.map(dep => Promise.all([
|
||||
.then(({dependencies}) => Promise.all(dependencies.map(dep => Promise.all([
|
||||
dep.getName(),
|
||||
dep.getDependencies(),
|
||||
]).then(([name, moduleDependencies]) => ({
|
||||
|
@ -273,7 +273,7 @@ describe('DependencyGraph', function() {
|
|||
...defaults,
|
||||
roots: [root],
|
||||
});
|
||||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js', null, false).then((deps) => {
|
||||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js', null, false).then(deps => {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{
|
||||
|
@ -1472,7 +1472,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/client.js',
|
||||
{id: 'aPackage/client.js',
|
||||
path: '/root/aPackage/client.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -1585,7 +1585,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -1593,7 +1593,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/client.js',
|
||||
{id: 'aPackage/client.js',
|
||||
path: '/root/aPackage/client.js',
|
||||
dependencies: ['./node', './dir/server.js'],
|
||||
isAsset: false,
|
||||
|
@ -1601,7 +1601,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/not-node.js',
|
||||
{id: 'aPackage/not-node.js',
|
||||
path: '/root/aPackage/not-node.js',
|
||||
dependencies: ['./not-browser'],
|
||||
isAsset: false,
|
||||
|
@ -1609,7 +1609,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/browser.js',
|
||||
{id: 'aPackage/browser.js',
|
||||
path: '/root/aPackage/browser.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -1680,7 +1680,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -1688,7 +1688,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['node-package'],
|
||||
isAsset: false,
|
||||
|
@ -1696,7 +1696,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'browser-package/index.js',
|
||||
{id: 'browser-package/index.js',
|
||||
path: '/root/aPackage/browser-package/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -1747,7 +1747,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -1755,7 +1755,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['./dir/ooga'],
|
||||
isAsset: false,
|
||||
|
@ -1763,7 +1763,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/dir/ooga.js',
|
||||
{id: 'aPackage/dir/ooga.js',
|
||||
path: '/root/aPackage/dir/ooga.js',
|
||||
dependencies: ['node-package'],
|
||||
isAsset: false,
|
||||
|
@ -1771,7 +1771,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/dir/browser.js',
|
||||
{id: 'aPackage/dir/browser.js',
|
||||
path: '/root/aPackage/dir/browser.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -1824,7 +1824,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -1832,7 +1832,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['node-package'],
|
||||
isAsset: false,
|
||||
|
@ -1840,7 +1840,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'browser-package/index.js',
|
||||
{id: 'browser-package/index.js',
|
||||
path: '/root/aPackage/browser-package/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -1889,7 +1889,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -1897,7 +1897,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['booga'],
|
||||
isAsset: false,
|
||||
|
@ -2035,7 +2035,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -2043,7 +2043,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['node-package'],
|
||||
isAsset: false,
|
||||
|
@ -2051,7 +2051,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'rn-package/index.js',
|
||||
{id: 'rn-package/index.js',
|
||||
path: '/root/aPackage/node_modules/rn-package/index.js',
|
||||
dependencies: ['nested-package'],
|
||||
isAsset: false,
|
||||
|
@ -2059,7 +2059,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'nested-browser-package/index.js',
|
||||
{id: 'nested-browser-package/index.js',
|
||||
path: '/root/aPackage/node_modules/nested-browser-package/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -2198,7 +2198,7 @@ describe('DependencyGraph', function() {
|
|||
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{ id: 'index',
|
||||
{id: 'index',
|
||||
path: '/root/index.js',
|
||||
dependencies: ['aPackage'],
|
||||
isAsset: false,
|
||||
|
@ -2206,7 +2206,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'aPackage/index.js',
|
||||
{id: 'aPackage/index.js',
|
||||
path: '/root/aPackage/index.js',
|
||||
dependencies: ['node-package-a', 'node-package-b', 'node-package-c'],
|
||||
isAsset: false,
|
||||
|
@ -2214,7 +2214,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'rn-package-a/index.js',
|
||||
{id: 'rn-package-a/index.js',
|
||||
path: '/root/aPackage/node_modules/rn-package-a/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -2222,7 +2222,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'rn-package-b/index.js',
|
||||
{id: 'rn-package-b/index.js',
|
||||
path: '/root/aPackage/node_modules/rn-package-b/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -2230,7 +2230,7 @@ describe('DependencyGraph', function() {
|
|||
isPolyfill: false,
|
||||
resolution: undefined,
|
||||
},
|
||||
{ id: 'rn-package-d/index.js',
|
||||
{id: 'rn-package-d/index.js',
|
||||
path: '/root/aPackage/node_modules/rn-package-d/index.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
|
@ -2308,8 +2308,8 @@ describe('DependencyGraph', function() {
|
|||
setMockFileSystem({
|
||||
[root.slice(1)]: {
|
||||
'index.js': 'require("bar")',
|
||||
'node_modules': { 'bar.js': '' },
|
||||
'provides-bar': { 'index.js': '' },
|
||||
'node_modules': {'bar.js': ''},
|
||||
'provides-bar': {'index.js': ''},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -2437,7 +2437,7 @@ describe('DependencyGraph', function() {
|
|||
...defaults,
|
||||
roots: [root],
|
||||
});
|
||||
return getOrderedDependenciesAsJSON(dgraph, 'C:\\root\\index.js').then((deps) => {
|
||||
return getOrderedDependenciesAsJSON(dgraph, 'C:\\root\\index.js').then(deps => {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{
|
||||
|
@ -3175,7 +3175,7 @@ describe('DependencyGraph', function() {
|
|||
resolution: undefined,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ describe('Module', () => {
|
|||
});
|
||||
|
||||
let transformCacheKey;
|
||||
const createModule = (options) =>
|
||||
const createModule = options =>
|
||||
new Module({
|
||||
options: {
|
||||
cacheTransformResults: true,
|
||||
|
@ -75,7 +75,7 @@ describe('Module', () => {
|
|||
});
|
||||
|
||||
const createJSONModule =
|
||||
(options) => createModule({...options, file: '/root/package.json'});
|
||||
options => createModule({...options, file: '/root/package.json'});
|
||||
|
||||
beforeEach(function() {
|
||||
process.platform = 'linux';
|
||||
|
@ -284,7 +284,7 @@ describe('Module', () => {
|
|||
};
|
||||
const module = createModule({transformCode});
|
||||
|
||||
return module.read().then((result) => {
|
||||
return module.read().then(result => {
|
||||
expect(result).toEqual(jasmine.objectContaining(transformResult));
|
||||
});
|
||||
});
|
||||
|
@ -302,7 +302,7 @@ describe('Module', () => {
|
|||
cacheTransformResults: false,
|
||||
}});
|
||||
|
||||
return module.read().then((result) => {
|
||||
return module.read().then(result => {
|
||||
expect(result).toEqual({
|
||||
dependencies: ['foo', 'bar'],
|
||||
});
|
||||
|
@ -320,8 +320,8 @@ describe('Module', () => {
|
|||
};
|
||||
const module = createModule({transformCode, options: undefined});
|
||||
|
||||
return module.read().then((result) => {
|
||||
expect(result).toEqual({ ...transformResult, source: 'arbitrary(code);'});
|
||||
return module.read().then(result => {
|
||||
expect(result).toEqual({...transformResult, source: 'arbitrary(code);'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class DependencyGraph {
|
|||
dir = path.dirname(dir);
|
||||
} while (dir !== '.' && dir !== root);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}, this._opts.platforms);
|
||||
|
||||
this._hasteMap = new HasteMap({
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('getInverseDependencies', () => {
|
|||
|
||||
const resolutionResponse = {
|
||||
dependencies: [module1, module2, module3, module4],
|
||||
getResolvedDependencyPairs: (module) => {
|
||||
getResolvedDependencyPairs: module => {
|
||||
return modulePairs[module.hash()];
|
||||
},
|
||||
};
|
||||
|
|
|
@ -45,8 +45,8 @@ function getAssetDataFromName(filename, platforms) {
|
|||
assetName = decodeURIComponent(assetName);
|
||||
|
||||
return {
|
||||
resolution: resolution,
|
||||
assetName: assetName,
|
||||
resolution,
|
||||
assetName,
|
||||
type: ext.slice(1),
|
||||
name: path.basename(assetName, ext),
|
||||
platform: platformExt,
|
||||
|
|
Loading…
Reference in New Issue