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