@expo/config
Advanced tools
Comparing version 8.3.1 to 8.4.0
@@ -194,3 +194,3 @@ "use strict"; | ||
const [packageJson, packageJsonPath] = getPackageJsonAndPath(projectRoot); | ||
function fillAndReturnConfig(config, dynamicConfigObjectType) { | ||
function fillAndReturnConfig(config, dynamicConfigObjectType, mayHaveUnusedStaticConfig = false) { | ||
const configWithDefaultValues = { | ||
@@ -209,3 +209,4 @@ ...ensureConfigHasDefaultValues({ | ||
dynamicConfigPath: paths.dynamicConfigPath, | ||
staticConfigPath: paths.staticConfigPath | ||
staticConfigPath: paths.staticConfigPath, | ||
hasUnusedStaticConfig: !!paths.staticConfigPath && !!paths.dynamicConfigPath && mayHaveUnusedStaticConfig | ||
}; | ||
@@ -260,3 +261,4 @@ if (options.isModdedConfig) { | ||
exportedObjectType, | ||
config: rawDynamicConfig | ||
config: rawDynamicConfig, | ||
mayHaveUnusedStaticConfig | ||
} = (0, _getConfig().getDynamicConfig)(paths.dynamicConfigPath, { | ||
@@ -271,3 +273,3 @@ projectRoot, | ||
const dynamicConfig = reduceExpoObject(rawDynamicConfig) || {}; | ||
return fillAndReturnConfig(dynamicConfig, exportedObjectType); | ||
return fillAndReturnConfig(dynamicConfig, exportedObjectType, mayHaveUnusedStaticConfig); | ||
} | ||
@@ -274,0 +276,0 @@ |
@@ -44,2 +44,14 @@ import { ModConfig } from '@expo/config-plugins'; | ||
dynamicConfigObjectType: string | null; | ||
/** | ||
* Returns true if both a static and dynamic config are present, and the dynamic config is applied on top of the static. | ||
* This is only used for expo-doctor diagnostic warnings. This flag may be true even in cases where all static config values are used. | ||
* It only checks against a typical pattern for layering static and dynamic config, e.g.,: | ||
* module.exports = ({ config }) => { | ||
return { | ||
...config, | ||
name: 'name overridden by dynamic config', | ||
}; | ||
}; | ||
*/ | ||
hasUnusedStaticConfig: boolean; | ||
} | ||
@@ -124,3 +136,3 @@ export type AppJSONConfig = { | ||
export type ProjectTarget = 'managed' | 'bare'; | ||
export type ConfigErrorCode = 'NO_APP_JSON' | 'NOT_OBJECT' | 'NO_EXPO' | 'MODULE_NOT_FOUND' | 'DEPRECATED' | 'INVALID_MODE' | 'INVALID_FORMAT' | 'INVALID_PLUGIN' | 'INVALID_CONFIG'; | ||
export type ConfigErrorCode = 'NO_APP_JSON' | 'NOT_OBJECT' | 'NO_EXPO' | 'MODULE_NOT_FOUND' | 'DEPRECATED' | 'INVALID_MODE' | 'INVALID_FORMAT' | 'INVALID_PLUGIN' | 'INVALID_CONFIG' | 'ENTRY_NOT_FOUND'; | ||
export type ConfigContext = { | ||
@@ -127,0 +139,0 @@ projectRoot: string; |
@@ -6,2 +6,3 @@ import { AppJSONConfig, ConfigContext, ExpoConfig } from './Config.types'; | ||
exportedObjectType: string; | ||
mayHaveUnusedStaticConfig: boolean; | ||
}; | ||
@@ -29,3 +30,4 @@ /** | ||
exportedObjectType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; | ||
mayHaveUnusedStaticConfig: any; | ||
}; | ||
export {}; |
@@ -43,2 +43,9 @@ "use strict"; | ||
} | ||
function _environment() { | ||
const data = require("./environment"); | ||
_environment = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -135,3 +142,10 @@ /** | ||
function resolveConfigExport(result, configFile, request) { | ||
var _result; | ||
var _request$config, _result, _result2; | ||
// add key to static config that we'll check for after the dynamic is evaluated | ||
// to see if the static config was used in determining the dynamic | ||
const hasBaseStaticConfig = _environment().NON_STANDARD_SYMBOL; | ||
if (request !== null && request !== void 0 && request.config) { | ||
// @ts-ignore | ||
request.config[hasBaseStaticConfig] = true; | ||
} | ||
if (result.default != null) { | ||
@@ -148,4 +162,15 @@ result = result.default; | ||
// If the key is not added, it suggests that the static config was not used as the base for the dynamic. | ||
// note(Keith): This is the most common way to use static and dynamic config together, but not the only way. | ||
// Hence, this is only output from getConfig() for informational purposes for use by tools like Expo Doctor | ||
// to suggest that there *may* be a problem. | ||
const mayHaveUnusedStaticConfig = | ||
// @ts-ignore | ||
(request === null || request === void 0 ? void 0 : (_request$config = request.config) === null || _request$config === void 0 ? void 0 : _request$config[hasBaseStaticConfig]) && !((_result = result) !== null && _result !== void 0 && _result[hasBaseStaticConfig]); | ||
if (result) { | ||
delete result._hasBaseStaticConfig; | ||
} | ||
// If the expo object exists, ignore all other values. | ||
if ((_result = result) !== null && _result !== void 0 && _result.expo) { | ||
if ((_result2 = result) !== null && _result2 !== void 0 && _result2.expo) { | ||
result = (0, _Serialize().serializeSkippingMods)(result.expo); | ||
@@ -157,5 +182,6 @@ } else { | ||
config: result, | ||
exportedObjectType | ||
exportedObjectType, | ||
mayHaveUnusedStaticConfig | ||
}; | ||
} | ||
//# sourceMappingURL=evalConfig.js.map |
@@ -1,11 +0,9 @@ | ||
import { ProjectConfig } from '../Config.types'; | ||
import { PackageJSONConfig } from '../Config.types'; | ||
export declare function ensureSlash(inputPath: string, needsSlash: boolean): string; | ||
export declare function getPossibleProjectRoot(): string; | ||
export declare function resolveEntryPoint(projectRoot: string, { platform, projectConfig }: { | ||
platform: string; | ||
projectConfig?: Partial<ProjectConfig>; | ||
}): string | null; | ||
export declare function getEntryPoint(projectRoot: string, entryFiles: string[], platforms: string[], projectConfig?: Partial<ProjectConfig>): string | null; | ||
export declare function getEntryPointWithExtensions(projectRoot: string, entryFiles: string[], extensions: string[], projectConfig?: Partial<ProjectConfig>): string; | ||
export declare function resolveFromSilentWithExtensions(fromDirectory: string, moduleId: string, extensions: string[]): string | null; | ||
/** @returns the absolute entry file for an Expo project. */ | ||
export declare function resolveEntryPoint(projectRoot: string, { platform, pkg, }?: { | ||
platform?: string; | ||
pkg?: PackageJSONConfig; | ||
}): string; | ||
export declare function getFileWithExtensions(fromDirectory: string, moduleId: string, extensions: string[]): string | null; |
@@ -7,8 +7,5 @@ "use strict"; | ||
exports.ensureSlash = ensureSlash; | ||
exports.getEntryPoint = getEntryPoint; | ||
exports.getEntryPointWithExtensions = getEntryPointWithExtensions; | ||
exports.getFileWithExtensions = getFileWithExtensions; | ||
exports.getPossibleProjectRoot = getPossibleProjectRoot; | ||
exports.resolveEntryPoint = resolveEntryPoint; | ||
exports.resolveFromSilentWithExtensions = resolveFromSilentWithExtensions; | ||
function _fs() { | ||
@@ -49,2 +46,9 @@ const data = _interopRequireDefault(require("fs")); | ||
} | ||
function _Errors() { | ||
const data = require("../Errors"); | ||
_Errors = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -66,53 +70,30 @@ // https://github.com/facebook/create-react-app/blob/9750738cce89a967cc71f28390daf5d4311b193c/packages/react-scripts/config/paths.js#L22 | ||
const nativePlatforms = ['ios', 'android']; | ||
/** @returns the absolute entry file for an Expo project. */ | ||
function resolveEntryPoint(projectRoot, { | ||
platform, | ||
projectConfig | ||
}) { | ||
const platforms = nativePlatforms.includes(platform) ? [platform, 'native'] : [platform]; | ||
return getEntryPoint(projectRoot, ['./index'], platforms, projectConfig); | ||
} | ||
function getEntryPoint(projectRoot, entryFiles, platforms, projectConfig) { | ||
pkg = (0, _Config().getPackageJson)(projectRoot) | ||
} = {}) { | ||
const platforms = !platform ? [] : nativePlatforms.includes(platform) ? [platform, 'native'] : [platform]; | ||
const extensions = (0, _extensions().getBareExtensions)(platforms); | ||
return getEntryPointWithExtensions(projectRoot, entryFiles, extensions, projectConfig); | ||
} | ||
// Used to resolve the main entry file for a project. | ||
function getEntryPointWithExtensions(projectRoot, entryFiles, extensions, projectConfig) { | ||
if (!projectConfig) { | ||
// drop all logging abilities | ||
const original = process.stdout.write; | ||
process.stdout.write = () => true; | ||
try { | ||
projectConfig = (0, _Config().getConfig)(projectRoot, { | ||
skipSDKVersionRequirement: true | ||
}); | ||
} finally { | ||
process.stdout.write = original; | ||
} | ||
} | ||
// If the config doesn't define a custom entry then we want to look at the `package.json`s `main` field, and try again. | ||
const { | ||
pkg | ||
} = projectConfig; | ||
if (pkg) { | ||
// If the config doesn't define a custom entry then we want to look at the `package.json`s `main` field, and try again. | ||
const { | ||
main | ||
} = pkg; | ||
if (main && typeof main === 'string') { | ||
// Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path. | ||
let entry = getFileWithExtensions(projectRoot, main, extensions); | ||
if (!entry) { | ||
// Allow for paths like: `{ "main": "expo/AppEntry" }` | ||
entry = resolveFromSilentWithExtensions(projectRoot, main, extensions); | ||
if (!entry) throw new Error(`Cannot resolve entry file: The \`main\` field defined in your \`package.json\` points to a non-existent path.`); | ||
} | ||
return entry; | ||
main | ||
} = pkg; | ||
if (main && typeof main === 'string') { | ||
// Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path. | ||
let entry = getFileWithExtensions(projectRoot, main, extensions); | ||
if (!entry) { | ||
// Allow for paths like: `{ "main": "expo/AppEntry" }` | ||
entry = resolveFromSilentWithExtensions(projectRoot, main, extensions); | ||
if (!entry) throw new (_Errors().ConfigError)(`Cannot resolve entry file: The \`main\` field defined in your \`package.json\` points to an unresolvable or non-existent path.`, 'ENTRY_NOT_FOUND'); | ||
} | ||
return entry; | ||
} | ||
// Now we will start looking for a default entry point using the provided `entryFiles` argument. | ||
// This will add support for create-react-app (src/index.js) and react-native-cli (index.js) which don't define a main. | ||
for (const fileName of entryFiles) { | ||
const entry = resolveFromSilentWithExtensions(projectRoot, fileName, extensions); | ||
if (entry) return entry; | ||
// Check for a root index.* file in the project root. | ||
const entry = resolveFromSilentWithExtensions(projectRoot, './index', extensions); | ||
if (entry) { | ||
return entry; | ||
} | ||
@@ -127,3 +108,3 @@ try { | ||
} catch { | ||
throw new Error(`The project entry file could not be resolved. Please define it in the \`main\` field of the \`package.json\`, create an \`index.js\`, or install the \`expo\` package.`); | ||
throw new (_Errors().ConfigError)(`The project entry file could not be resolved. Define it in the \`main\` field of the \`package.json\`, create an \`index.js\`, or install the \`expo\` package.`, 'ENTRY_NOT_FOUND'); | ||
} | ||
@@ -136,3 +117,3 @@ } | ||
const modulePath = _resolveFrom().default.silent(fromDirectory, `${moduleId}.${extension}`); | ||
if (modulePath && modulePath.endsWith(extension)) { | ||
if (modulePath !== null && modulePath !== void 0 && modulePath.endsWith(extension)) { | ||
return modulePath; | ||
@@ -139,0 +120,0 @@ } |
@@ -57,4 +57,3 @@ "use strict"; | ||
} else if (typeof val === 'function') { | ||
var _val$name; | ||
return (_val$name = val.name) !== null && _val$name !== void 0 ? _val$name : 'withAnonymous'; | ||
return val.name || 'withAnonymous'; | ||
} else if (Array.isArray(val)) { | ||
@@ -61,0 +60,0 @@ return val.map(serializeAndEvaluatePlugin); |
{ | ||
"name": "@expo/config", | ||
"version": "8.3.1", | ||
"version": "8.4.0", | ||
"description": "A library for interacting with the app.json", | ||
@@ -36,3 +36,3 @@ "main": "build/index.js", | ||
"@babel/code-frame": "~7.10.4", | ||
"@expo/config-plugins": "~7.5.0", | ||
"@expo/config-plugins": "~7.6.0", | ||
"@expo/config-types": "^50.0.0-alpha.1", | ||
@@ -54,3 +54,3 @@ "@expo/json-file": "^8.2.37", | ||
}, | ||
"gitHead": "ff40b4b373ce2944d1541f70969db65e3e5c1999" | ||
"gitHead": "ee7897097f5f946ad7fcb94447eed789b984dd02" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
153552
56
1831
11
+ Added@expo/config-plugins@7.6.0(transitive)
+ Added@expo/fingerprint@0.4.1(transitive)
- Removed@expo/config-plugins@7.5.0(transitive)
- Removed@expo/fingerprint@0.2.0(transitive)
Updated@expo/config-plugins@~7.6.0