mirror of
https://github.com/status-im/metro.git
synced 2025-01-31 21:34:53 +00:00
Apply @format to root level files
Reviewed By: davidaurelio Differential Revision: D5803464 fbshipit-source-id: e250a3ada33790b989f1e70990438c300bfb6d52
This commit is contained in:
parent
c51161d209
commit
d9ff4fa1dc
@ -5,6 +5,8 @@
|
|||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the BSD-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -35,11 +37,13 @@ function escapeRegExp(pattern) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function blacklist(additionalBlacklist) {
|
function blacklist(additionalBlacklist) {
|
||||||
return new RegExp('(' +
|
return new RegExp(
|
||||||
(additionalBlacklist || []).concat(sharedBlacklist)
|
'(' +
|
||||||
|
(additionalBlacklist || [])
|
||||||
|
.concat(sharedBlacklist)
|
||||||
.map(escapeRegExp)
|
.map(escapeRegExp)
|
||||||
.join('|') +
|
.join('|') +
|
||||||
')$'
|
')$',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @flow
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -7,15 +7,40 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @flow
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.assetExts = [
|
exports.assetExts = [
|
||||||
'bmp', 'gif', 'jpg', 'jpeg', 'png', 'psd', 'svg', 'webp', // Image formats
|
// Image formats
|
||||||
'm4v', 'mov', 'mp4', 'mpeg', 'mpg', 'webm', // Video formats
|
'bmp',
|
||||||
'aac', 'aiff', 'caf', 'm4a', 'mp3', 'wav', // Audio formats
|
'gif',
|
||||||
'html', 'pdf', // Document formats
|
'jpg',
|
||||||
'otf', 'ttf', // Font formats
|
'jpeg',
|
||||||
|
'png',
|
||||||
|
'psd',
|
||||||
|
'svg',
|
||||||
|
'webp',
|
||||||
|
// Video formats
|
||||||
|
'm4v',
|
||||||
|
'mov',
|
||||||
|
'mp4',
|
||||||
|
'mpeg',
|
||||||
|
'mpg',
|
||||||
|
'webm',
|
||||||
|
// Audio formats
|
||||||
|
'aac',
|
||||||
|
'aiff',
|
||||||
|
'caf',
|
||||||
|
'm4a',
|
||||||
|
'mp3',
|
||||||
|
'wav',
|
||||||
|
// Document formats
|
||||||
|
'html',
|
||||||
|
'pdf',
|
||||||
|
// Font formats
|
||||||
|
'otf',
|
||||||
|
'ttf',
|
||||||
];
|
];
|
||||||
|
|
||||||
exports.sourceExts = ['js', 'json'];
|
exports.sourceExts = ['js', 'json'];
|
||||||
@ -24,10 +49,7 @@ exports.moduleSystem = require.resolve('./Resolver/polyfills/require.js');
|
|||||||
|
|
||||||
exports.platforms = ['ios', 'android', 'windows', 'web'];
|
exports.platforms = ['ios', 'android', 'windows', 'web'];
|
||||||
|
|
||||||
exports.providesModuleNodeModules = [
|
exports.providesModuleNodeModules = ['react-native', 'react-native-windows'];
|
||||||
'react-native',
|
|
||||||
'react-native-windows',
|
|
||||||
];
|
|
||||||
|
|
||||||
exports.transformModulePath = require.resolve('./defaultTransform.js');
|
exports.transformModulePath = require.resolve('./defaultTransform.js');
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @flow
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -55,41 +56,76 @@ exports.TransformCaching = TransformCaching;
|
|||||||
* refine these values completely.
|
* refine these values completely.
|
||||||
*/
|
*/
|
||||||
function assertPublicBundleOptions(bo: mixed): PublicBundleOptions {
|
function assertPublicBundleOptions(bo: mixed): PublicBundleOptions {
|
||||||
invariant(typeof bo === 'object' && bo != null, 'bundle options must be an object');
|
invariant(
|
||||||
invariant(bo.dev === undefined || typeof bo.dev === 'boolean', 'bundle options field `dev` must be a boolean');
|
typeof bo === 'object' && bo != null,
|
||||||
|
'bundle options must be an object',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.dev === undefined || typeof bo.dev === 'boolean',
|
||||||
|
'bundle options field `dev` must be a boolean',
|
||||||
|
);
|
||||||
const {entryFile} = bo;
|
const {entryFile} = bo;
|
||||||
invariant(typeof entryFile === 'string', 'bundle options must contain a string field `entryFile`');
|
invariant(
|
||||||
invariant(bo.generateSourceMaps === undefined || typeof bo.generateSourceMaps === 'boolean', 'bundle options field `generateSourceMaps` must be a boolean');
|
typeof entryFile === 'string',
|
||||||
invariant(bo.inlineSourceMap === undefined || typeof bo.inlineSourceMap === 'boolean', 'bundle options field `inlineSourceMap` must be a boolean');
|
'bundle options must contain a string field `entryFile`',
|
||||||
invariant(bo.minify === undefined || typeof bo.minify === 'boolean', 'bundle options field `minify` must be a boolean');
|
);
|
||||||
invariant(bo.platform === undefined || typeof bo.platform === 'string', 'bundle options field `platform` must be a string');
|
invariant(
|
||||||
invariant(bo.runModule === undefined || typeof bo.runModule === 'boolean', 'bundle options field `runModule` must be a boolean');
|
bo.generateSourceMaps === undefined ||
|
||||||
invariant(bo.sourceMapUrl === undefined || typeof bo.sourceMapUrl === 'string', 'bundle options field `sourceMapUrl` must be a boolean');
|
typeof bo.generateSourceMaps === 'boolean',
|
||||||
|
'bundle options field `generateSourceMaps` must be a boolean',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.inlineSourceMap === undefined || typeof bo.inlineSourceMap === 'boolean',
|
||||||
|
'bundle options field `inlineSourceMap` must be a boolean',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.minify === undefined || typeof bo.minify === 'boolean',
|
||||||
|
'bundle options field `minify` must be a boolean',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.platform === undefined || typeof bo.platform === 'string',
|
||||||
|
'bundle options field `platform` must be a string',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.runModule === undefined || typeof bo.runModule === 'boolean',
|
||||||
|
'bundle options field `runModule` must be a boolean',
|
||||||
|
);
|
||||||
|
invariant(
|
||||||
|
bo.sourceMapUrl === undefined || typeof bo.sourceMapUrl === 'string',
|
||||||
|
'bundle options field `sourceMapUrl` must be a boolean',
|
||||||
|
);
|
||||||
return {entryFile, ...bo};
|
return {entryFile, ...bo};
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.buildBundle = function(options: Options, bundleOptions: PublicBundleOptions) {
|
exports.buildBundle = function(
|
||||||
|
options: Options,
|
||||||
|
bundleOptions: PublicBundleOptions,
|
||||||
|
) {
|
||||||
var server = createNonPersistentServer(options);
|
var server = createNonPersistentServer(options);
|
||||||
const ServerClass = require('./Server');
|
const ServerClass = require('./Server');
|
||||||
return server.buildBundle({
|
return server
|
||||||
|
.buildBundle({
|
||||||
...ServerClass.DEFAULT_BUNDLE_OPTIONS,
|
...ServerClass.DEFAULT_BUNDLE_OPTIONS,
|
||||||
...assertPublicBundleOptions(bundleOptions),
|
...assertPublicBundleOptions(bundleOptions),
|
||||||
}).then(p => {
|
})
|
||||||
|
.then(p => {
|
||||||
server.end();
|
server.end();
|
||||||
return p;
|
return p;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getOrderedDependencyPaths = function(options: Options, depOptions: {
|
exports.getOrderedDependencyPaths = function(
|
||||||
|
options: Options,
|
||||||
|
depOptions: {
|
||||||
+entryFile: string,
|
+entryFile: string,
|
||||||
+dev: boolean,
|
+dev: boolean,
|
||||||
+platform: string,
|
+platform: string,
|
||||||
+minify: boolean,
|
+minify: boolean,
|
||||||
+generateSourceMaps: boolean,
|
+generateSourceMaps: boolean,
|
||||||
}) {
|
},
|
||||||
|
) {
|
||||||
var server = createNonPersistentServer(options);
|
var server = createNonPersistentServer(options);
|
||||||
return server.getOrderedDependencyPaths(depOptions)
|
return server.getOrderedDependencyPaths(depOptions).then(function(paths) {
|
||||||
.then(function(paths) {
|
|
||||||
server.end();
|
server.end();
|
||||||
return paths;
|
return paths;
|
||||||
});
|
});
|
||||||
@ -117,7 +153,10 @@ function createServer(options: Options): Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some callsites may not be Flowified yet.
|
// Some callsites may not be Flowified yet.
|
||||||
invariant(options.assetRegistryPath != null, 'createServer() requires assetRegistryPath');
|
invariant(
|
||||||
|
options.assetRegistryPath != null,
|
||||||
|
'createServer() requires assetRegistryPath',
|
||||||
|
);
|
||||||
|
|
||||||
const ServerClass = require('./Server');
|
const ServerClass = require('./Server');
|
||||||
return new ServerClass(toServerOptions(options));
|
return new ServerClass(toServerOptions(options));
|
||||||
@ -155,7 +194,10 @@ function toServerOptions(options: Options): ServerOptions {
|
|||||||
transformCache: options.transformCache || TransformCaching.useTempDir(),
|
transformCache: options.transformCache || TransformCaching.useTempDir(),
|
||||||
transformModulePath: options.transformModulePath,
|
transformModulePath: options.transformModulePath,
|
||||||
useDeltaBundler: options.useDeltaBundler,
|
useDeltaBundler: options.useDeltaBundler,
|
||||||
watch: typeof options.watch === 'boolean' ? options.watch : !!options.nonPersistent,
|
watch:
|
||||||
|
typeof options.watch === 'boolean'
|
||||||
|
? options.watch
|
||||||
|
: !!options.nonPersistent,
|
||||||
workerPath: options.workerPath,
|
workerPath: options.workerPath,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* React Native CLI configuration file
|
* React Native CLI configuration file
|
||||||
|
*
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -46,5 +48,4 @@ module.exports = {
|
|||||||
getTransformModulePath() {
|
getTransformModulePath() {
|
||||||
return require.resolve('./transformer');
|
return require.resolve('./transformer');
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the BSD-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* Note: This is a fork of the fb-specific transform.js
|
* Note: This is a fork of the fb-specific transform.js
|
||||||
*
|
*
|
||||||
* @flow
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -62,13 +63,14 @@ const getBabelRC = (function() {
|
|||||||
// use the Babel config provided with react-native.
|
// use the Babel config provided with react-native.
|
||||||
if (!projectBabelRCPath || !fs.existsSync(projectBabelRCPath)) {
|
if (!projectBabelRCPath || !fs.existsSync(projectBabelRCPath)) {
|
||||||
babelRC = json5.parse(
|
babelRC = json5.parse(
|
||||||
fs.readFileSync(
|
fs.readFileSync(path.resolve(__dirname, '..', 'rn-babelrc.json')),
|
||||||
path.resolve(__dirname, '..', 'rn-babelrc.json'))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Require the babel-preset's listed in the default babel config
|
// Require the babel-preset's listed in the default babel config
|
||||||
|
babelRC.presets = babelRC.presets.map(preset =>
|
||||||
// $FlowFixMe: dynamic require can't be avoided
|
// $FlowFixMe: dynamic require can't be avoided
|
||||||
babelRC.presets = babelRC.presets.map(preset => require('babel-preset-' + preset));
|
require('babel-preset-' + preset),
|
||||||
|
);
|
||||||
babelRC.plugins = resolvePlugins(babelRC.plugins);
|
babelRC.plugins = resolvePlugins(babelRC.plugins);
|
||||||
} else {
|
} else {
|
||||||
// if we find a .babelrc file we tell babel to use it
|
// if we find a .babelrc file we tell babel to use it
|
||||||
@ -87,7 +89,8 @@ function buildBabelConfig(filename, options) {
|
|||||||
const babelRC = getBabelRC(options.projectRoot);
|
const babelRC = getBabelRC(options.projectRoot);
|
||||||
|
|
||||||
const extraConfig = {
|
const extraConfig = {
|
||||||
babelrc: typeof options.enableBabelRCLookup === 'boolean'
|
babelrc:
|
||||||
|
typeof options.enableBabelRCLookup === 'boolean'
|
||||||
? options.enableBabelRCLookup
|
? options.enableBabelRCLookup
|
||||||
: true,
|
: true,
|
||||||
code: false,
|
code: false,
|
||||||
@ -100,7 +103,8 @@ function buildBabelConfig(filename, options) {
|
|||||||
const extraPlugins = [externalHelpersPlugin];
|
const extraPlugins = [externalHelpersPlugin];
|
||||||
|
|
||||||
var inlineRequires = options.inlineRequires;
|
var inlineRequires = options.inlineRequires;
|
||||||
var blacklist = typeof inlineRequires === 'object' ? inlineRequires.blacklist : null;
|
var blacklist =
|
||||||
|
typeof inlineRequires === 'object' ? inlineRequires.blacklist : null;
|
||||||
if (inlineRequires && !(blacklist && filename in blacklist)) {
|
if (inlineRequires && !(blacklist && filename in blacklist)) {
|
||||||
extraPlugins.push(inlineRequiresPlugin);
|
extraPlugins.push(inlineRequiresPlugin);
|
||||||
}
|
}
|
||||||
@ -140,20 +144,26 @@ function transform({filename, options, src}: Params) {
|
|||||||
map: null,
|
map: null,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const result = generate(ast, {
|
const result = generate(
|
||||||
|
ast,
|
||||||
|
{
|
||||||
comments: false,
|
comments: false,
|
||||||
compact: false,
|
compact: false,
|
||||||
filename,
|
filename,
|
||||||
retainLines: !!options.retainLines,
|
retainLines: !!options.retainLines,
|
||||||
sourceFileName: filename,
|
sourceFileName: filename,
|
||||||
sourceMaps: true,
|
sourceMaps: true,
|
||||||
}, src);
|
},
|
||||||
|
src,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ast,
|
ast,
|
||||||
code: result.code,
|
code: result.code,
|
||||||
filename,
|
filename,
|
||||||
map: options.generateSourceMaps ? result.map : result.rawMappings.map(compactMapping),
|
map: options.generateSourceMaps
|
||||||
|
? result.map
|
||||||
|
: result.rawMappings.map(compactMapping),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user