metro-config
Advanced tools
Comparing version 0.80.5 to 0.80.6
{ | ||
"name": "metro-config", | ||
"version": "0.80.5", | ||
"version": "0.80.6", | ||
"description": "🚇 Config parser for Metro.", | ||
@@ -19,6 +19,6 @@ "main": "src/index.js", | ||
"jest-validate": "^29.6.3", | ||
"metro": "0.80.5", | ||
"metro-cache": "0.80.5", | ||
"metro-core": "0.80.5", | ||
"metro-runtime": "0.80.5" | ||
"metro": "0.80.6", | ||
"metro-cache": "0.80.6", | ||
"metro-core": "0.80.6", | ||
"metro-runtime": "0.80.6" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
@@ -1,11 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* | ||
*/ | ||
"use strict"; |
@@ -1,12 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -16,3 +5,2 @@ | ||
exports.assetExts = [ | ||
// Image formats | ||
"bmp", | ||
@@ -26,3 +14,2 @@ "gif", | ||
"webp", | ||
// Video formats | ||
"m4v", | ||
@@ -34,3 +21,2 @@ "mov", | ||
"webm", | ||
// Audio formats | ||
"aac", | ||
@@ -42,3 +28,2 @@ "aiff", | ||
"wav", | ||
// Document formats | ||
"html", | ||
@@ -48,6 +33,4 @@ "pdf", | ||
"yml", | ||
// Font formats | ||
"otf", | ||
"ttf", | ||
// Archives (virtual files) | ||
"zip", | ||
@@ -54,0 +37,0 @@ ]; |
@@ -1,11 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -17,16 +7,5 @@ | ||
if (Object.prototype.toString.call(pattern) === "[object RegExp]") { | ||
// the forward slash may or may not be escaped in regular expression depends | ||
// on if it's in brackets. See this post for details | ||
// https://github.com/nodejs/help/issues/3039. The or condition in string | ||
// replace regexp is to cover both use cases. | ||
// We should replace all forward slashes to proper OS specific separators. | ||
// The separator needs to be escaped in the regular expression source string, | ||
// hence the '\\' prefix. | ||
return pattern.source.replace(/\/|\\\//g, "\\" + path.sep); | ||
} else if (typeof pattern === "string") { | ||
// Make sure all the special characters used by regular expression are properly | ||
// escaped. The string inputs are supposed to match as is. | ||
var escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | ||
// convert the '/' into an escaped local file separator. The separator needs | ||
// to be escaped in the regular expression source string, hence the '\\' prefix. | ||
return escaped.replaceAll("/", "\\" + path.sep); | ||
@@ -33,0 +12,0 @@ } else { |
@@ -1,12 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -116,3 +105,2 @@ | ||
compress: { | ||
// reduce_funcs inlines single-use functions, which cause perf regressions. | ||
reduce_funcs: false, | ||
@@ -123,3 +111,2 @@ }, | ||
optimizationSizeLimit: 150 * 1024, | ||
// 150 KiB. | ||
transformVariants: { | ||
@@ -157,4 +144,2 @@ default: {}, | ||
cacheVersion: "1.0", | ||
// We assume the default project path is two levels up from | ||
// node_modules/metro/ | ||
projectRoot: projectRoot || path.resolve(__dirname, "../../.."), | ||
@@ -170,5 +155,2 @@ stickyWorkers: true, | ||
async function getDefaultConfig(rootPath) { | ||
// We can add more logic here to get a sensible default configuration, for | ||
// now we just return a stub. | ||
return getDefaultValues(rootPath); | ||
@@ -175,0 +157,0 @@ } |
@@ -1,12 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -13,0 +2,0 @@ |
@@ -1,12 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -13,0 +2,0 @@ |
@@ -1,12 +0,1 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
@@ -22,5 +11,2 @@ | ||
const { dirname, join } = require("path"); | ||
/** | ||
* Takes the last argument if multiple of the same argument are given | ||
*/ | ||
function overrideArgument(arg) { | ||
@@ -31,3 +17,2 @@ if (arg == null) { | ||
if (Array.isArray(arg)) { | ||
// $FlowFixMe[incompatible-return] | ||
return arg[arg.length - 1]; | ||
@@ -57,4 +42,2 @@ } | ||
const resolve = (filePath) => { | ||
// Attempt to resolve the path with the node resolution algorithm but fall back to resolving | ||
// the file relative to the current working directory if the input is not an absolute path. | ||
try { | ||
@@ -76,3 +59,2 @@ return require.resolve(filePath); | ||
if (result == null) { | ||
// No config file found, return a default | ||
return { | ||
@@ -87,4 +69,2 @@ isEmpty: true, | ||
function mergeConfig(defaultConfig, ...configs) { | ||
// If the file is a plain object we merge the file with the default config, | ||
// for the function we don't do this since that's the responsibility of the user | ||
return configs.reduce( | ||
@@ -102,3 +82,2 @@ (totalConfig, nextConfig) => ({ | ||
...totalConfig.resolver, | ||
// $FlowFixMe[exponential-spread] | ||
...(nextConfig.resolver || {}), | ||
@@ -108,13 +87,10 @@ dependencyExtractor: | ||
? resolve(nextConfig.resolver.dependencyExtractor) | ||
: // $FlowFixMe[incompatible-use] | ||
totalConfig.resolver.dependencyExtractor, | ||
: totalConfig.resolver.dependencyExtractor, | ||
hasteImplModulePath: | ||
nextConfig.resolver && nextConfig.resolver.hasteImplModulePath != null | ||
? resolve(nextConfig.resolver.hasteImplModulePath) | ||
: // $FlowFixMe[incompatible-use] | ||
totalConfig.resolver.hasteImplModulePath, | ||
: totalConfig.resolver.hasteImplModulePath, | ||
}, | ||
serializer: { | ||
...totalConfig.serializer, | ||
// $FlowFixMe[exponential-spread] | ||
...(nextConfig.serializer || {}), | ||
@@ -124,3 +100,2 @@ }, | ||
...totalConfig.transformer, | ||
// $FlowFixMe[exponential-spread] | ||
...(nextConfig.transformer || {}), | ||
@@ -131,8 +106,6 @@ babelTransformerPath: | ||
? resolve(nextConfig.transformer.babelTransformerPath) | ||
: // $FlowFixMe[incompatible-use] | ||
totalConfig.transformer.babelTransformerPath, | ||
: totalConfig.transformer.babelTransformerPath, | ||
}, | ||
server: { | ||
...totalConfig.server, | ||
// $FlowFixMe[exponential-spread] | ||
...(nextConfig.server || {}), | ||
@@ -142,3 +115,2 @@ }, | ||
...totalConfig.symbolicator, | ||
// $FlowFixMe[exponential-spread] | ||
...(nextConfig.symbolicator || {}), | ||
@@ -148,6 +120,4 @@ }, | ||
...totalConfig.watcher, | ||
// $FlowFixMe[exponential-spread] | ||
...nextConfig.watcher, | ||
watchman: { | ||
// $FlowFixMe[exponential-spread] | ||
...totalConfig.watcher?.watchman, | ||
@@ -157,5 +127,3 @@ ...nextConfig.watcher?.watchman, | ||
healthCheck: { | ||
// $FlowFixMe[exponential-spread] | ||
...totalConfig.watcher?.healthCheck, | ||
// $FlowFixMe: Spreading shapes creates an explosion of union types | ||
...nextConfig.watcher?.healthCheck, | ||
@@ -173,22 +141,10 @@ }, | ||
const defaults = await getDefaultConfig(rootPath); | ||
// $FlowFixMe[incompatible-variance] | ||
// $FlowFixMe[incompatible-call] | ||
const defaultConfig = mergeConfig(defaults, defaultConfigOverrides); | ||
if (typeof configModule === "function") { | ||
// Get a default configuration based on what we know, which we in turn can pass | ||
// to the function. | ||
const resultedConfig = await configModule(defaultConfig); | ||
// $FlowFixMe[incompatible-call] | ||
// $FlowFixMe[incompatible-variance] | ||
return mergeConfig(defaultConfig, resultedConfig); | ||
} | ||
// $FlowFixMe[incompatible-variance] | ||
// $FlowFixMe[incompatible-call] | ||
return mergeConfig(defaultConfig, configModule); | ||
} | ||
function overrideConfigWithArguments(config, argv) { | ||
// We override some config arguments here with the argv | ||
const output = { | ||
@@ -201,4 +157,2 @@ resolver: {}, | ||
if (argv.port != null) { | ||
// $FlowFixMe[incompatible-use] | ||
// $FlowFixMe[cannot-write] | ||
output.server.port = Number(argv.port); | ||
@@ -213,14 +167,8 @@ } | ||
if (argv.assetExts != null) { | ||
// $FlowFixMe[incompatible-use] | ||
// $FlowFixMe[cannot-write] | ||
output.resolver.assetExts = argv.assetExts; | ||
} | ||
if (argv.sourceExts != null) { | ||
// $FlowFixMe[incompatible-use] | ||
// $FlowFixMe[cannot-write] | ||
output.resolver.sourceExts = argv.sourceExts; | ||
} | ||
if (argv.platforms != null) { | ||
// $FlowFixMe[incompatible-use] | ||
// $FlowFixMe[cannot-write] | ||
output.resolver.platforms = argv.platforms; | ||
@@ -232,4 +180,2 @@ } | ||
if (argv.transformer != null) { | ||
// $FlowFixMe[incompatible-use] | ||
// $FlowFixMe[cannot-write] | ||
output.transformer.babelTransformerPath = argv.transformer; | ||
@@ -247,16 +193,5 @@ } | ||
}; | ||
// TODO: Ask if this is the way to go | ||
} | ||
// $FlowFixMe[incompatible-variance] | ||
// $FlowFixMe[incompatible-call] | ||
return mergeConfig(config, output); | ||
} | ||
/** | ||
* Load the metro configuration from disk | ||
* @param {object} argv Arguments coming from the CLI, can be empty | ||
* @param {object} defaultConfigOverrides A configuration that can override the default config | ||
* @return {object} Configuration returned | ||
*/ | ||
async function loadConfig(argvInput = {}, defaultConfigOverrides = {}) { | ||
@@ -281,4 +216,2 @@ const argv = { | ||
}); | ||
// Override the configuration with cli parameters | ||
const configWithArgs = overrideConfigWithArguments(configuration, argv); | ||
@@ -290,8 +223,2 @@ const overriddenConfig = {}; | ||
]; | ||
// Set the watchfolders to include the projectRoot, as Metro assumes that is | ||
// the case | ||
// $FlowFixMe[incompatible-variance] | ||
// $FlowFixMe[incompatible-indexer] | ||
// $FlowFixMe[incompatible-call] | ||
return mergeConfig(configWithArgs, overriddenConfig); | ||
@@ -298,0 +225,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49491
761
+ Addedhermes-estree@0.19.1(transitive)
+ Addedhermes-parser@0.19.1(transitive)
+ Addedmetro@0.80.6(transitive)
+ Addedmetro-babel-transformer@0.80.6(transitive)
+ Addedmetro-cache@0.80.6(transitive)
+ Addedmetro-cache-key@0.80.6(transitive)
+ Addedmetro-core@0.80.6(transitive)
+ Addedmetro-file-map@0.80.6(transitive)
+ Addedmetro-minify-terser@0.80.6(transitive)
+ Addedmetro-resolver@0.80.6(transitive)
+ Addedmetro-runtime@0.80.6(transitive)
+ Addedmetro-source-map@0.80.6(transitive)
+ Addedmetro-symbolicate@0.80.6(transitive)
+ Addedmetro-transform-plugins@0.80.6(transitive)
+ Addedmetro-transform-worker@0.80.6(transitive)
+ Addedob1@0.80.6(transitive)
- Removedhermes-estree@0.18.2(transitive)
- Removedhermes-parser@0.18.2(transitive)
- Removedmetro@0.80.5(transitive)
- Removedmetro-babel-transformer@0.80.5(transitive)
- Removedmetro-cache@0.80.5(transitive)
- Removedmetro-cache-key@0.80.5(transitive)
- Removedmetro-core@0.80.5(transitive)
- Removedmetro-file-map@0.80.5(transitive)
- Removedmetro-minify-terser@0.80.5(transitive)
- Removedmetro-resolver@0.80.5(transitive)
- Removedmetro-runtime@0.80.5(transitive)
- Removedmetro-source-map@0.80.5(transitive)
- Removedmetro-symbolicate@0.80.5(transitive)
- Removedmetro-transform-plugins@0.80.5(transitive)
- Removedmetro-transform-worker@0.80.5(transitive)
- Removedob1@0.80.5(transitive)
Updatedmetro@0.80.6
Updatedmetro-cache@0.80.6
Updatedmetro-core@0.80.6
Updatedmetro-runtime@0.80.6