@expo/config 55.0.4 → 55.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/evalConfig.js +5 -86
- package/build/evalConfig.js.map +1 -1
- package/package.json +5 -8
package/build/evalConfig.js
CHANGED
|
@@ -5,23 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.evalConfig = evalConfig;
|
|
7
7
|
exports.resolveConfigExport = resolveConfigExport;
|
|
8
|
-
function
|
|
9
|
-
const data = require("
|
|
10
|
-
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
function _requireFromString() {
|
|
16
|
-
const data = _interopRequireDefault(require("require-from-string"));
|
|
17
|
-
_requireFromString = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
function _sucrase() {
|
|
23
|
-
const data = require("sucrase");
|
|
24
|
-
_sucrase = function () {
|
|
8
|
+
function _requireUtils() {
|
|
9
|
+
const data = require("@expo/require-utils");
|
|
10
|
+
_requireUtils = function () {
|
|
25
11
|
return data;
|
|
26
12
|
};
|
|
27
13
|
return data;
|
|
@@ -47,7 +33,6 @@ function _environment() {
|
|
|
47
33
|
};
|
|
48
34
|
return data;
|
|
49
35
|
}
|
|
50
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
51
36
|
/**
|
|
52
37
|
* Transpile and evaluate the dynamic config object.
|
|
53
38
|
* This method is shared between the standard reading method in getConfig, and the headless script.
|
|
@@ -56,74 +41,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
56
41
|
* @returns the serialized and evaluated config along with the exported object type (object or function).
|
|
57
42
|
*/
|
|
58
43
|
function evalConfig(configFile, request) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const {
|
|
63
|
-
code
|
|
64
|
-
} = (0, _sucrase().transform)(contents, {
|
|
65
|
-
filePath: configFile,
|
|
66
|
-
transforms: ['typescript', 'imports']
|
|
67
|
-
});
|
|
68
|
-
result = (0, _requireFromString().default)(code, configFile);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
const location = extractLocationFromSyntaxError(error);
|
|
71
|
-
|
|
72
|
-
// Apply a code frame preview to the error if possible, sucrase doesn't do this by default.
|
|
73
|
-
if (location) {
|
|
74
|
-
const {
|
|
75
|
-
codeFrameColumns
|
|
76
|
-
} = require('@babel/code-frame');
|
|
77
|
-
const codeFrame = codeFrameColumns(contents, {
|
|
78
|
-
start: error.loc
|
|
79
|
-
}, {
|
|
80
|
-
highlightCode: true
|
|
81
|
-
});
|
|
82
|
-
error.codeFrame = codeFrame;
|
|
83
|
-
error.message += `\n${codeFrame}`;
|
|
84
|
-
} else {
|
|
85
|
-
const importantStack = extractImportantStackFromNodeError(error);
|
|
86
|
-
if (importantStack) {
|
|
87
|
-
error.message += `\n${importantStack}`;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
return resolveConfigExport(result, configFile, request);
|
|
93
|
-
}
|
|
94
|
-
function extractLocationFromSyntaxError(error) {
|
|
95
|
-
// sucrase provides the `loc` object
|
|
96
|
-
if (error.loc) {
|
|
97
|
-
return error.loc;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// `SyntaxError`s provide the `lineNumber` and `columnNumber` properties
|
|
101
|
-
if ('lineNumber' in error && 'columnNumber' in error) {
|
|
102
|
-
return {
|
|
103
|
-
line: error.lineNumber,
|
|
104
|
-
column: error.columnNumber
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// These kinda errors often come from syntax errors in files that were imported by the main file.
|
|
111
|
-
// An example is a module that includes an import statement.
|
|
112
|
-
function extractImportantStackFromNodeError(error) {
|
|
113
|
-
if (isSyntaxError(error)) {
|
|
114
|
-
const traces = error.stack?.split('\n').filter(line => !line.startsWith(' at '));
|
|
115
|
-
if (!traces) return null;
|
|
116
|
-
|
|
117
|
-
// Remove redundant line
|
|
118
|
-
if (traces[traces.length - 1].startsWith('SyntaxError:')) {
|
|
119
|
-
traces.pop();
|
|
120
|
-
}
|
|
121
|
-
return traces.join('\n');
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
function isSyntaxError(error) {
|
|
126
|
-
return error instanceof SyntaxError || error.constructor.name === 'SyntaxError';
|
|
44
|
+
const mod = (0, _requireUtils().loadModuleSync)(configFile);
|
|
45
|
+
return resolveConfigExport(mod, configFile, request);
|
|
127
46
|
}
|
|
128
47
|
|
|
129
48
|
/**
|
package/build/evalConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evalConfig.js","names":["
|
|
1
|
+
{"version":3,"file":"evalConfig.js","names":["_requireUtils","data","require","_Errors","_Serialize","_environment","evalConfig","configFile","request","mod","loadModuleSync","resolveConfigExport","result","hasBaseStaticConfig","NON_STANDARD_SYMBOL","config","default","exportedObjectType","Promise","ConfigError","mayHaveUnusedStaticConfig","_hasBaseStaticConfig","expo","serializeSkippingMods"],"sources":["../src/evalConfig.ts"],"sourcesContent":["import { loadModuleSync } from '@expo/require-utils';\n\nimport { AppJSONConfig, ConfigContext, ExpoConfig } from './Config.types';\nimport { ConfigError } from './Errors';\nimport { serializeSkippingMods } from './Serialize';\nimport { NON_STANDARD_SYMBOL } from './environment';\n\ntype RawDynamicConfig = AppJSONConfig | Partial<ExpoConfig> | null;\n\nexport type DynamicConfigResults = {\n config: RawDynamicConfig;\n exportedObjectType: string;\n mayHaveUnusedStaticConfig: boolean;\n};\n\n/**\n * Transpile and evaluate the dynamic config object.\n * This method is shared between the standard reading method in getConfig, and the headless script.\n *\n * @param options configFile path to the dynamic app.config.*, request to send to the dynamic config if it exports a function.\n * @returns the serialized and evaluated config along with the exported object type (object or function).\n */\nexport function evalConfig(\n configFile: string,\n request: ConfigContext | null\n): DynamicConfigResults {\n const mod = loadModuleSync(configFile);\n return resolveConfigExport(mod, configFile, request);\n}\n\n/**\n * - Resolve the exported contents of an Expo config (be it default or module.exports)\n * - Assert no promise exports\n * - Return config type\n * - Serialize config\n *\n * @param result\n * @param configFile\n * @param request\n */\nexport function resolveConfigExport(\n result: any,\n configFile: string,\n request: ConfigContext | null\n) {\n // add key to static config that we'll check for after the dynamic is evaluated\n // to see if the static config was used in determining the dynamic\n const hasBaseStaticConfig = NON_STANDARD_SYMBOL;\n if (request?.config) {\n // @ts-ignore\n request.config[hasBaseStaticConfig] = true;\n }\n if (result.default != null) {\n result = result.default;\n }\n const exportedObjectType = typeof result;\n if (typeof result === 'function') {\n result = result(request);\n }\n\n if (result instanceof Promise) {\n throw new ConfigError(`Config file ${configFile} cannot return a Promise.`, 'INVALID_CONFIG');\n }\n\n // If the key is not added, it suggests that the static config was not used as the base for the dynamic.\n // note(Keith): This is the most common way to use static and dynamic config together, but not the only way.\n // Hence, this is only output from getConfig() for informational purposes for use by tools like Expo Doctor\n // to suggest that there *may* be a problem.\n const mayHaveUnusedStaticConfig =\n // @ts-ignore\n request?.config?.[hasBaseStaticConfig] && !result?.[hasBaseStaticConfig];\n if (result) {\n delete result._hasBaseStaticConfig;\n }\n\n // If the expo object exists, ignore all other values.\n if (result?.expo) {\n result = serializeSkippingMods(result.expo);\n } else {\n result = serializeSkippingMods(result);\n }\n\n return { config: result, exportedObjectType, mayHaveUnusedStaticConfig };\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAA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AAGC,mBAAmB,CAAC;EAC1E,IAAID,MAAM,EAAE;IACV,OAAOA,MAAM,CAACS,oBAAoB;EACpC;;EAEA;EACA,IAAIT,MAAM,EAAEU,IAAI,EAAE;IAChBV,MAAM,GAAG,IAAAW,kCAAqB,EAACX,MAAM,CAACU,IAAI,CAAC;EAC7C,CAAC,MAAM;IACLV,MAAM,GAAG,IAAAW,kCAAqB,EAACX,MAAM,CAAC;EACxC;EAEA,OAAO;IAAEG,MAAM,EAAEH,MAAM;IAAEK,kBAAkB;IAAEG;EAA0B,CAAC;AAC1E","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/config",
|
|
3
|
-
"version": "55.0.
|
|
3
|
+
"version": "55.0.5",
|
|
4
4
|
"description": "A library for interacting with the app.json",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,27 +33,24 @@
|
|
|
33
33
|
"paths"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@expo/config-plugins": "~55.0.4",
|
|
36
|
+
"@expo/config-plugins": "~55.0.5",
|
|
38
37
|
"@expo/config-types": "^55.0.4",
|
|
39
38
|
"@expo/json-file": "^10.0.12",
|
|
39
|
+
"@expo/require-utils": "^55.0.0",
|
|
40
40
|
"deepmerge": "^4.3.1",
|
|
41
41
|
"getenv": "^2.0.0",
|
|
42
42
|
"glob": "^13.0.0",
|
|
43
|
-
"require-from-string": "^2.0.2",
|
|
44
43
|
"resolve-from": "^5.0.0",
|
|
45
44
|
"resolve-workspace-root": "^2.0.0",
|
|
46
45
|
"semver": "^7.6.0",
|
|
47
|
-
"slugify": "^1.3.4"
|
|
48
|
-
"sucrase": "~3.35.1"
|
|
46
|
+
"slugify": "^1.3.4"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
49
|
"@types/babel__code-frame": "^7.27.0",
|
|
52
|
-
"@types/require-from-string": "^1.2.1",
|
|
53
50
|
"expo-module-scripts": "^55.0.2"
|
|
54
51
|
},
|
|
55
52
|
"publishConfig": {
|
|
56
53
|
"access": "public"
|
|
57
54
|
},
|
|
58
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "928cc951854450f3c72e00e8e420e567fabd1f8c"
|
|
59
56
|
}
|