Remove flaky babel 7 test + some small lint fixes

Differential Revision: D6976119

fbshipit-source-id: 0315511e8835e7dcfc796ac7133b24346d805853
This commit is contained in:
Rafael Oleza 2018-02-13 06:16:55 -08:00 committed by Facebook Github Bot
parent 892b4ac9de
commit c955b65b22
9 changed files with 15 additions and 225 deletions

View File

@ -6,9 +6,6 @@
* 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.
*
* eslint-disable no-console
*
*
* @format
* @emails oncall+js_foundation
* @flow
@ -21,6 +18,7 @@ const {
createActionEndEntry,
} = require('../');
/* eslint-disable no-console */
describe('Logger', () => {
const originalConsoleLog = console.log;

View File

@ -17,7 +17,6 @@ const formatBundlingError = require('../lib/formatBundlingError');
const getBundlingOptionsForHmr = require('./getBundlingOptionsForHmr');
const nullthrows = require('fbjs/lib/nullthrows');
const parseCustomTransformOptions = require('../lib/parseCustomTransformOptions');
const querystring = require('querystring');
const url = require('url');
const {

View File

@ -29,7 +29,6 @@ const {isAssetTypeAnImage} = require('../../Bundler/util');
const {basename} = require('path');
import type {Transformer} from '../../JSTransformer/worker';
import type {HasteImpl} from '../../node-haste/Module';
import type {
ImageSize,
TransformedCodeFile,

View File

@ -58,6 +58,7 @@ exports.handler = makeAsyncCommand(async (argv: any) => {
}
if (server) {
// eslint-disable-next-line no-console
console.log('Configuration changed. Restarting the server...');
await promisify(server.close).call(server);
}

View File

@ -358,6 +358,7 @@ exports.runBuild = async ({
platform,
};
// eslint-disable-next-line no-console
await output.save(metroBundle, outputOptions, console.log);
await metroServer.end();

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`basic_bundle bundles package with polyfills (babel v6) 1`] = `
exports[`basic_bundle bundles package with polyfills 1`] = `
"var __DEV__=false,__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now(),process=this.process||{};process.env=process.env||{};process.env.NODE_ENV='production';
(function (global) {
'use strict';
@ -188,200 +188,12 @@ __d(function (global, _require, module, exports, _dependencyMap) {
require(4);"
`;
exports[`basic_bundle bundles package with polyfills (babel v7) 1`] = `
"var __DEV__=false,__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now(),process=this.process||{};process.env=process.env||{};process.env.NODE_ENV='production';
(function (global) {
'use strict';
global.require = require;
global.__d = define;
var modules = Object.create(null);
function define(factory, moduleId, dependencyMap) {
if (moduleId in modules) {
return;
}
modules[moduleId] = {
dependencyMap: dependencyMap,
exports: undefined,
factory: factory,
hasError: false,
isInitialized: false
};
}
function require(moduleId) {
var moduleIdReallyIsNumber = moduleId;
var module = modules[moduleIdReallyIsNumber];
return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module);
}
var inGuard = false;
function guardedLoadModule(moduleId, module) {
if (!inGuard && global.ErrorUtils) {
inGuard = true;
var returnValue;
try {
returnValue = loadModuleImplementation(moduleId, module);
} catch (e) {
global.ErrorUtils.reportFatalError(e);
}
inGuard = false;
return returnValue;
} else {
return loadModuleImplementation(moduleId, module);
}
}
var ID_MASK_SHIFT = 16;
var LOCAL_ID_MASK = ~0 >>> ID_MASK_SHIFT;
function unpackModuleId(moduleId) {
var segmentId = moduleId >>> ID_MASK_SHIFT;
var localId = moduleId & LOCAL_ID_MASK;
return {
segmentId: segmentId,
localId: localId
};
}
require.unpackModuleId = unpackModuleId;
function packModuleId(value) {
return value.segmentId << ID_MASK_SHIFT + value.localId;
}
require.packModuleId = packModuleId;
function loadModuleImplementation(moduleId, module) {
var nativeRequire = global.nativeRequire;
if (!module && nativeRequire) {
var _unpackModuleId = unpackModuleId(moduleId),
_segmentId = _unpackModuleId.segmentId,
_localId = _unpackModuleId.localId;
nativeRequire(_localId, _segmentId);
module = modules[moduleId];
}
if (!module) {
throw unknownModuleError(moduleId);
}
if (module.hasError) {
throw moduleThrewError(moduleId, module.error);
}
module.isInitialized = true;
var exports = module.exports = {};
var _module = module,
factory = _module.factory,
dependencyMap = _module.dependencyMap;
try {
var _moduleObject = {
exports: exports
};
factory(global, require, _moduleObject, exports, dependencyMap);
{
module.factory = undefined;
module.dependencyMap = undefined;
}
return module.exports = _moduleObject.exports;
} catch (e) {
module.hasError = true;
module.error = e;
module.isInitialized = false;
module.exports = undefined;
throw e;
}
}
function unknownModuleError(id) {
var message = 'Requiring unknown module \\"' + id + '\\".';
return Error(message);
}
function moduleThrewError(id, error) {
var displayName = id;
return Error('Requiring module \\"' + displayName + '\\", which threw an exception: ' + error);
}
})(this);
(function (global) {
'use strict';
if (!Object.keys) {
Object.keys = function () {};
}
})(this);
(function (global) {
'use strict';
if (!String.prototype.repeat) {
String.prototype.repeat = function () {};
}
})(this);
__d(function (global, _require, module, exports, _dependencyMap) {
'use strict';
var Bar = _require(_dependencyMap[0]);
var Foo = _require(_dependencyMap[1]);
module.exports = {
Foo: Foo,
Bar: Bar
};
},4,[5,6]);
__d(function (global, _require, module, exports, _dependencyMap) {
'use strict';
var Foo = _require(_dependencyMap[0]);
module.exports = {
type: 'bar',
foo: Foo.type
};
},5,[6]);
__d(function (global, _require, module, exports, _dependencyMap) {
'use strict';
var asset = _require(_dependencyMap[0]);
module.exports = {
type: 'foo',
asset: asset
};
},6,[7]);
__d(function (global, _require, module, exports, _dependencyMap) {
module.exports = _require(_dependencyMap[0]).registerAsset({
\\"__packager_asset\\": true,
\\"httpServerLocation\\": \\"/assets\\",
\\"width\\": 8,
\\"height\\": 8,
\\"scales\\": [1],
\\"hash\\": \\"77d45c1f7fa73c0f6c444a830dc42f67\\",
\\"name\\": \\"test\\",
\\"type\\": \\"png\\"
});
},7,[8]);
__d(function (global, _require, module, exports, _dependencyMap) {
'use strict';
},8,[]);
require(4);"
`;
exports[`basic_bundle bundles package without polyfills 1`] = `
"var __DEV__=false,__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now(),process=this.process||{};process.env=process.env||{};process.env.NODE_ENV='production';
(function (global) {
'use strict';
global.require = require;
global.require = _require;
global.__d = define;
var modules = Object.create(null);
@ -399,7 +211,7 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
};
}
function require(moduleId) {
function _require(moduleId) {
var moduleIdReallyIsNumber = moduleId;
var module = modules[moduleIdReallyIsNumber];
return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module);
@ -410,7 +222,7 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
function guardedLoadModule(moduleId, module) {
if (!inGuard && global.ErrorUtils) {
inGuard = true;
var returnValue;
var returnValue = void 0;
try {
returnValue = loadModuleImplementation(moduleId, module);
@ -437,13 +249,13 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
};
}
require.unpackModuleId = unpackModuleId;
_require.unpackModuleId = unpackModuleId;
function packModuleId(value) {
return value.segmentId << ID_MASK_SHIFT + value.localId;
}
require.packModuleId = packModuleId;
_require.packModuleId = packModuleId;
function loadModuleImplementation(moduleId, module) {
var nativeRequire = global.nativeRequire;
@ -475,7 +287,7 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
var _moduleObject = {
exports: exports
};
factory(global, require, _moduleObject, exports, dependencyMap);
factory(global, _require, _moduleObject, exports, dependencyMap);
{
module.factory = undefined;
module.dependencyMap = undefined;

View File

@ -89,7 +89,7 @@ describe('basic_bundle', () => {
).toMatchSnapshot();
}
it('bundles package with polyfills (babel v6)', async () => {
it('bundles package with polyfills', async () => {
const bundleWithPolyfills = await Metro.build(
{
assetRegistryPath: ASSET_REGISTRY_PATH,
@ -101,30 +101,6 @@ describe('basic_bundle', () => {
transformModulePath: require.resolve('../../transformer'),
nonPersistent: true,
enableBabelRCLookup: false, // dont use metro's own babelrc!
targetBabelVersion: 6,
},
{
dev: false,
entryFile: path.join(INPUT_PATH, 'TestBundle.js'),
platform: 'ios',
},
);
verifyResultCode(bundleWithPolyfills.code);
});
it('bundles package with polyfills (babel v7)', async () => {
const bundleWithPolyfills = await Metro.build(
{
assetRegistryPath: ASSET_REGISTRY_PATH,
dynamicDepsInPackages: 'reject',
getModulesRunBeforeMainModule: () => ['InitializeCore'],
getPolyfills: () => [polyfill1, polyfill2],
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
transformCache: Metro.TransformCaching.none(),
transformModulePath: require.resolve('../../transformer'),
nonPersistent: true,
enableBabelRCLookup: false, // dont use metro's own babelrc!
targetBabelVersion: 7,
},
{
dev: false,

View File

@ -18,6 +18,8 @@ module.exports = function runCommand(cmd, args, cwd) {
const displayArgs =
args.length > 25 ? args.slice(0, 25) + '...' : args.join(' ');
// eslint-disable-next-line no-console
console.log(chalk.dim('$ cd ' + cwd + `\n$ ${cmd} ${displayArgs}\n`));
const result = spawn(cmd, args, {
cwd,

View File

@ -12,6 +12,8 @@
* Watch files for changes and rebuild (copy from 'src/' to `build/`) if changed
*/
// eslint-disable no-console
const fs = require('fs');
const {execSync} = require('child_process');
const path = require('path');