@expo/cli 0.13.2 → 0.15.0
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/bin/cli +30 -27
- package/build/bin/cli.map +1 -1
- package/build/src/api/getVersions.js.map +1 -1
- package/build/src/api/rest/cache/response.js.map +1 -1
- package/build/src/api/rest/client.js +2 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/config/index.js +2 -2
- package/build/src/config/index.js.map +1 -1
- package/build/src/customize/generate.js +1 -1
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/typescript.js +6 -4
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/createMetadataJson.js +3 -2
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +44 -17
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +4 -4
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +3 -3
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +74 -83
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +81 -21
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +24 -14
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +109 -58
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +2 -2
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +56 -23
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +11 -9
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js +101 -0
- package/build/src/export/metroAssetLocalPath.js.map +1 -0
- package/build/src/export/persistMetroAssets.js +94 -21
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -1
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +9 -48
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/web/index.js +2 -2
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/export/writeContents.js +6 -3
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/applyPlugins.js +52 -0
- package/build/src/install/applyPlugins.js.map +1 -0
- package/build/src/install/checkPackages.js +2 -2
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/fixPackages.js +84 -0
- package/build/src/install/fixPackages.js.map +1 -0
- package/build/src/install/installAsync.js +32 -61
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/installExpoPackage.js +79 -0
- package/build/src/install/installExpoPackage.js.map +1 -0
- package/build/src/login/index.js +1 -1
- package/build/src/login/index.js.map +1 -1
- package/build/src/logout/index.js +1 -1
- package/build/src/logout/index.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +1 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +3 -3
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +21 -30
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +3 -3
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +39 -17
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +2 -2
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -6
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +49 -36
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
- package/build/src/register/index.js +1 -1
- package/build/src/register/index.js.map +1 -1
- package/build/src/run/android/index.js +2 -2
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/index.js +2 -2
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/index.js +3 -3
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +30 -11
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +14 -10
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +6 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +63 -0
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/getStaticRenderFunctions.js +21 -20
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +67 -64
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +4 -19
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +187 -0
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
- package/build/src/start/server/metro/createJResolver.js +149 -0
- package/build/src/start/server/metro/createJResolver.js.map +1 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/externals.js +25 -3
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js +72 -0
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +37 -16
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +3 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +6 -3
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +19 -10
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +43 -0
- package/build/src/start/server/metro/serializeHtml.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +268 -191
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +114 -40
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +45 -68
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +123 -0
- package/build/src/start/server/middleware/metroOptions.js.map +1 -0
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +1 -1
- package/build/src/start/server/type-generation/expo-env.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +1 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
- package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -2
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/args.js +4 -2
- package/build/src/utils/args.js.map +1 -1
- package/build/src/utils/cocoapods.js +2 -1
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +18 -8
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +6 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/getOrPromptApplicationId.js +2 -4
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
- package/build/src/utils/prompts.js +1 -28
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/whoami/index.js +1 -1
- package/build/src/whoami/index.js.map +1 -1
- package/package.json +16 -16
- package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
- package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
- package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
- package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
- package/build/src/export/createBundles.js +0 -37
- package/build/src/export/createBundles.js.map +0 -1
- package/build/src/start/server/metro/resolveFromProject.js +0 -90
- package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
|
@@ -7,13 +7,13 @@ exports.withExtendedResolver = withExtendedResolver;
|
|
|
7
7
|
exports.shouldAliasAssetRegistryForWeb = shouldAliasAssetRegistryForWeb;
|
|
8
8
|
exports.shouldAliasModule = shouldAliasModule;
|
|
9
9
|
exports.withMetroMultiPlatformAsync = withMetroMultiPlatformAsync;
|
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
var metroResolver = _interopRequireWildcard(require("metro-resolver"));
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
13
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
14
|
+
var _createExpoMetroResolver = require("./createExpoMetroResolver");
|
|
14
15
|
var _externals = require("./externals");
|
|
15
16
|
var _metroErrors = require("./metroErrors");
|
|
16
|
-
var _resolveFromProject = require("./resolveFromProject");
|
|
17
17
|
var _router = require("./router");
|
|
18
18
|
var _withMetroResolvers = require("./withMetroResolvers");
|
|
19
19
|
var _log = require("../../../log");
|
|
@@ -21,7 +21,6 @@ var _fileNotifier = require("../../../utils/FileNotifier");
|
|
|
21
21
|
var _env = require("../../../utils/env");
|
|
22
22
|
var _exit = require("../../../utils/exit");
|
|
23
23
|
var _interactive = require("../../../utils/interactive");
|
|
24
|
-
var _link = require("../../../utils/link");
|
|
25
24
|
var _loadTsConfigPaths = require("../../../utils/tsconfig/loadTsConfigPaths");
|
|
26
25
|
var _resolveWithTsConfigPaths = require("../../../utils/tsconfig/resolveWithTsConfigPaths");
|
|
27
26
|
var _webSupportProjectPrerequisite = require("../../doctor/web/WebSupportProjectPrerequisite");
|
|
@@ -30,22 +29,43 @@ function _interopRequireDefault(obj) {
|
|
|
30
29
|
default: obj
|
|
31
30
|
};
|
|
32
31
|
}
|
|
32
|
+
function _interopRequireWildcard(obj) {
|
|
33
|
+
if (obj && obj.__esModule) {
|
|
34
|
+
return obj;
|
|
35
|
+
} else {
|
|
36
|
+
var newObj = {};
|
|
37
|
+
if (obj != null) {
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
41
|
+
if (desc.get || desc.set) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
newObj.default = obj;
|
|
50
|
+
return newObj;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
33
53
|
const debug = require("debug")("expo:start:server:metro:multi-platform");
|
|
34
|
-
function withWebPolyfills(config
|
|
54
|
+
function withWebPolyfills(config) {
|
|
35
55
|
const originalGetPolyfills = config.serializer.getPolyfills ? config.serializer.getPolyfills.bind(config.serializer) : ()=>[]
|
|
36
56
|
;
|
|
37
57
|
const getPolyfills = (ctx)=>{
|
|
38
58
|
if (ctx.platform === "web") {
|
|
39
59
|
return [
|
|
40
60
|
// NOTE: We might need this for all platforms
|
|
41
|
-
_path.default.join(projectRoot, _externals.EXTERNAL_REQUIRE_POLYFILL)
|
|
61
|
+
_path.default.join(config.projectRoot, _externals.EXTERNAL_REQUIRE_POLYFILL)
|
|
42
62
|
];
|
|
43
63
|
}
|
|
44
64
|
// Generally uses `rn-get-polyfills`
|
|
45
65
|
const polyfills = originalGetPolyfills(ctx);
|
|
46
66
|
return [
|
|
47
67
|
...polyfills,
|
|
48
|
-
_externals.EXTERNAL_REQUIRE_NATIVE_POLYFILL
|
|
68
|
+
_path.default.join(config.projectRoot, _externals.EXTERNAL_REQUIRE_NATIVE_POLYFILL)
|
|
49
69
|
];
|
|
50
70
|
};
|
|
51
71
|
return {
|
|
@@ -72,19 +92,23 @@ function getNodejsExtensions(srcExts) {
|
|
|
72
92
|
nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);
|
|
73
93
|
return nodejsSourceExtensions;
|
|
74
94
|
}
|
|
75
|
-
function withExtendedResolver(config, {
|
|
95
|
+
function withExtendedResolver(config, { tsconfig , platforms , isTsconfigPathsEnabled , isFastResolverEnabled , isExporting }) {
|
|
96
|
+
var ref5, ref1, ref2, ref3;
|
|
97
|
+
if (isFastResolverEnabled) {
|
|
98
|
+
_log.Log.warn(`Experimental bundling features are enabled.`);
|
|
99
|
+
}
|
|
76
100
|
// Get the `transformer.assetRegistryPath`
|
|
77
101
|
// this needs to be unified since you can't dynamically
|
|
78
102
|
// swap out the transformer based on platform.
|
|
79
|
-
const assetRegistryPath = _fs.default.realpathSync(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
const assetRegistryPath = _fs.default.realpathSync(_path.default.resolve((0, _resolveFrom).default(config.projectRoot, "@react-native/assets-registry/registry.js")));
|
|
104
|
+
const defaultResolver = metroResolver.resolve;
|
|
105
|
+
var ref4;
|
|
106
|
+
const resolver = isFastResolverEnabled ? (0, _createExpoMetroResolver).createFastResolver({
|
|
107
|
+
preserveSymlinks: (ref4 = (ref5 = config.resolver) == null ? void 0 : ref5.unstable_enableSymlinks) != null ? ref4 : false,
|
|
108
|
+
blockList: Array.isArray((ref1 = config.resolver) == null ? void 0 : ref1.blockList) ? (ref2 = config.resolver) == null ? void 0 : ref2.blockList : [
|
|
109
|
+
(ref3 = config.resolver) == null ? void 0 : ref3.blockList
|
|
110
|
+
]
|
|
111
|
+
}) : defaultResolver;
|
|
88
112
|
const extraNodeModules = {};
|
|
89
113
|
const aliases = {
|
|
90
114
|
web: {
|
|
@@ -92,6 +116,8 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
92
116
|
"react-native/index": "react-native-web"
|
|
93
117
|
}
|
|
94
118
|
};
|
|
119
|
+
// TODO: We can probably drop this resolution hack.
|
|
120
|
+
const isWebEnabled = platforms.includes("web");
|
|
95
121
|
if (isWebEnabled) {
|
|
96
122
|
// Allow `react-native-web` to be optional when web is not enabled but path aliases is.
|
|
97
123
|
extraNodeModules["web"] = {
|
|
@@ -113,191 +139,239 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
113
139
|
paths: (_paths1 = tsconfig.paths) != null ? _paths1 : {},
|
|
114
140
|
baseUrl: tsconfig.baseUrl
|
|
115
141
|
}) : null;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
// TODO: Move this to be a transform key for invalidation.
|
|
143
|
+
if (!isExporting && (0, _interactive).isInteractive()) {
|
|
144
|
+
if (isTsconfigPathsEnabled) {
|
|
145
|
+
// TODO: We should track all the files that used imports and invalidate them
|
|
146
|
+
// currently the user will need to save all the files that use imports to
|
|
147
|
+
// use the new aliases.
|
|
148
|
+
const configWatcher = new _fileNotifier.FileNotifier(config.projectRoot, [
|
|
149
|
+
"./tsconfig.json",
|
|
150
|
+
"./jsconfig.json",
|
|
151
|
+
]);
|
|
152
|
+
configWatcher.startObserving(()=>{
|
|
153
|
+
debug("Reloading tsconfig.json");
|
|
154
|
+
(0, _loadTsConfigPaths).loadTsConfigPathsAsync(config.projectRoot).then((tsConfigPaths)=>{
|
|
155
|
+
if ((tsConfigPaths == null ? void 0 : tsConfigPaths.paths) && !!Object.keys(tsConfigPaths.paths).length) {
|
|
156
|
+
debug("Enabling tsconfig.json paths support");
|
|
157
|
+
var _paths;
|
|
158
|
+
tsConfigResolve = _resolveWithTsConfigPaths.resolveWithTsConfigPaths.bind(_resolveWithTsConfigPaths.resolveWithTsConfigPaths, {
|
|
159
|
+
paths: (_paths = tsConfigPaths.paths) != null ? _paths : {},
|
|
160
|
+
baseUrl: tsConfigPaths.baseUrl
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
debug("Disabling tsconfig.json paths support");
|
|
164
|
+
tsConfigResolve = null;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
138
167
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
168
|
+
// TODO: This probably prevents the process from exiting.
|
|
169
|
+
(0, _exit).installExitHooks(()=>{
|
|
170
|
+
configWatcher.stopObserving();
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
debug("Skipping tsconfig.json paths support");
|
|
174
|
+
}
|
|
146
175
|
}
|
|
147
176
|
let nodejsSourceExtensions = null;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// Adjust nodejs source extensions to sort mjs after js, including platform variants.
|
|
166
|
-
if (nodejsSourceExtensions === null) {
|
|
167
|
-
nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);
|
|
177
|
+
const shimsFolder = _path.default.join(config.projectRoot, _externals.METRO_SHIMS_FOLDER);
|
|
178
|
+
function getStrictResolver({ resolveRequest , ...context }, platform) {
|
|
179
|
+
return function doResolve(moduleName) {
|
|
180
|
+
return resolver(context, moduleName, platform);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function getOptionalResolver(context, platform) {
|
|
184
|
+
const doResolve = getStrictResolver(context, platform);
|
|
185
|
+
return function optionalResolve(moduleName) {
|
|
186
|
+
try {
|
|
187
|
+
return doResolve(moduleName);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
// If the error is directly related to a resolver not being able to resolve a module, then
|
|
190
|
+
// we can ignore the error and try the next resolver. Otherwise, we should throw the error.
|
|
191
|
+
const isResolutionError = (0, _metroErrors).isFailedToResolveNameError(error) || (0, _metroErrors).isFailedToResolvePathError(error);
|
|
192
|
+
if (!isResolutionError) {
|
|
193
|
+
throw error;
|
|
168
194
|
}
|
|
169
|
-
context.sourceExts = nodejsSourceExtensions;
|
|
170
|
-
}
|
|
171
|
-
// Conditionally remap `react-native` to `react-native-web` on web in
|
|
172
|
-
// a way that doesn't require Babel to resolve the alias.
|
|
173
|
-
if (platform && platform in aliases && aliases[platform][moduleName1]) {
|
|
174
|
-
moduleName1 = aliases[platform][moduleName1];
|
|
175
|
-
}
|
|
176
|
-
// TODO: We may be able to remove this in the future, it's doing no harm
|
|
177
|
-
// by staying here.
|
|
178
|
-
// Conditionally remap `react-native` to `react-native-web`
|
|
179
|
-
if (platform && platform in extraNodeModules) {
|
|
180
|
-
context.extraNodeModules = {
|
|
181
|
-
...extraNodeModules[platform],
|
|
182
|
-
...context.extraNodeModules
|
|
183
|
-
};
|
|
184
195
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
} else if (platform && platform in preferredMainFields) {
|
|
206
|
-
mainFields = preferredMainFields[platform];
|
|
196
|
+
return null;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const metroConfigWithCustomResolver = (0, _withMetroResolvers).withMetroResolvers(config, [
|
|
200
|
+
// tsconfig paths
|
|
201
|
+
(context, moduleName, platform)=>{
|
|
202
|
+
var ref;
|
|
203
|
+
return (ref = tsConfigResolve == null ? void 0 : tsConfigResolve({
|
|
204
|
+
originModulePath: context.originModulePath,
|
|
205
|
+
moduleName
|
|
206
|
+
}, getOptionalResolver(context, platform))) != null ? ref : null;
|
|
207
|
+
},
|
|
208
|
+
// Node.js built-ins get empty externals on web
|
|
209
|
+
(context, moduleName, platform)=>{
|
|
210
|
+
var // Skip when targeting server runtimes
|
|
211
|
+
ref;
|
|
212
|
+
if (isFastResolverEnabled || // is web
|
|
213
|
+
platform !== "web" || ((ref = context.customResolverOptions) == null ? void 0 : ref.environment) === "node" || // This transform only applies to Node.js built-ins
|
|
214
|
+
!(0, _externals).isNodeExternal(moduleName)) {
|
|
215
|
+
return null;
|
|
207
216
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
217
|
+
// Perform optional resolve first. If the module doesn't exist (no module in the node_modules)
|
|
218
|
+
// then we can mock the file to use an empty module.
|
|
219
|
+
const result = getOptionalResolver(context, platform)(moduleName);
|
|
220
|
+
return result != null ? result : {
|
|
221
|
+
// In this case, mock the file to use an empty module.
|
|
222
|
+
type: "empty"
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
// Node.js externals support
|
|
226
|
+
(context, moduleName, platform)=>{
|
|
227
|
+
var // Only apply to server runtimes
|
|
228
|
+
ref;
|
|
229
|
+
if (// is web
|
|
230
|
+
platform !== "web" || ((ref = context.customResolverOptions) == null ? void 0 : ref.environment) !== "node") {
|
|
231
|
+
return null;
|
|
223
232
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return doResolve(moduleName);
|
|
227
|
-
} catch (error) {
|
|
228
|
-
// If the error is directly related to a resolver not being able to resolve a module, then
|
|
229
|
-
// we can ignore the error and try the next resolver. Otherwise, we should throw the error.
|
|
230
|
-
const isResolutionError = (0, _metroErrors).isFailedToResolveNameError(error) || (0, _metroErrors).isFailedToResolvePathError(error);
|
|
231
|
-
if (!isResolutionError) {
|
|
232
|
-
throw error;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
233
|
+
const moduleId = (0, _externals).isNodeExternal(moduleName);
|
|
234
|
+
if (!moduleId) {
|
|
235
235
|
return null;
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
const redirectedModuleName = (0, _externals).getNodeExternalModuleId(context.originModulePath, moduleId);
|
|
238
|
+
debug(`Redirecting Node.js external "${moduleId}" to "${redirectedModuleName}"`);
|
|
239
|
+
const doResolve = getStrictResolver(context, platform);
|
|
240
|
+
return doResolve(redirectedModuleName);
|
|
241
|
+
},
|
|
242
|
+
// Basic moduleId aliases
|
|
243
|
+
(context, moduleName, platform)=>{
|
|
244
|
+
// Conditionally remap `react-native` to `react-native-web` on web in
|
|
245
|
+
// a way that doesn't require Babel to resolve the alias.
|
|
246
|
+
if (platform && platform in aliases && aliases[platform][moduleName]) {
|
|
247
|
+
const redirectedModuleName = aliases[platform][moduleName];
|
|
248
|
+
const doResolve = getStrictResolver(context, platform);
|
|
249
|
+
return doResolve(redirectedModuleName);
|
|
245
250
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
return null;
|
|
252
|
+
},
|
|
253
|
+
// HACK(EvanBacon):
|
|
254
|
+
// React Native uses `event-target-shim` incorrectly and this causes the native runtime
|
|
255
|
+
// to fail to load. This is a temporary workaround until we can fix this upstream.
|
|
256
|
+
// https://github.com/facebook/react-native/pull/38628
|
|
257
|
+
(context, moduleName, platform)=>{
|
|
258
|
+
if (platform !== "web" && moduleName === "event-target-shim") {
|
|
259
|
+
debug("For event-target-shim to use js:", context.originModulePath);
|
|
260
|
+
const doResolve = getStrictResolver(context, platform);
|
|
261
|
+
return doResolve("event-target-shim/dist/event-target-shim.js");
|
|
251
262
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
type: "empty"
|
|
263
|
-
};
|
|
264
|
-
}
|
|
263
|
+
return null;
|
|
264
|
+
},
|
|
265
|
+
// TODO: Reduce these as much as possible in the future.
|
|
266
|
+
// Complex post-resolution rewrites.
|
|
267
|
+
(context, moduleName, platform)=>{
|
|
268
|
+
const doResolve = getStrictResolver(context, platform);
|
|
269
|
+
const result = doResolve(moduleName);
|
|
270
|
+
if (result.type !== "sourceFile") {
|
|
271
|
+
return result;
|
|
265
272
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
platform,
|
|
280
|
-
result
|
|
281
|
-
}, {
|
|
282
|
-
platform: "web",
|
|
283
|
-
output: "react-native-web/dist/exports/AppRegistry/AppContainer.js"
|
|
284
|
-
})) {
|
|
273
|
+
// Replace the web resolver with the original one.
|
|
274
|
+
// This is basically an alias for web-only.
|
|
275
|
+
// TODO: Drop this in favor of the standalone asset registry module.
|
|
276
|
+
if (shouldAliasAssetRegistryForWeb(platform, result)) {
|
|
277
|
+
// @ts-expect-error: `readonly` for some reason.
|
|
278
|
+
result.filePath = assetRegistryPath;
|
|
279
|
+
}
|
|
280
|
+
if (platform === "web" && result.filePath.includes("node_modules")) {
|
|
281
|
+
// Replace with static shims
|
|
282
|
+
const normalName = normalizeSlashes(result.filePath)// Drop everything up until the `node_modules` folder.
|
|
283
|
+
.replace(/.*node_modules\//, "");
|
|
284
|
+
const shimPath = _path.default.join(shimsFolder, normalName);
|
|
285
|
+
if (_fs.default.existsSync(shimPath)) {
|
|
285
286
|
// @ts-expect-error: `readonly` for some reason.
|
|
286
|
-
result.filePath =
|
|
287
|
+
result.filePath = shimPath;
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
return result;
|
|
290
291
|
},
|
|
291
292
|
]);
|
|
293
|
+
// Ensure we mutate the resolution context to include the custom resolver options for server and web.
|
|
294
|
+
const metroConfigWithCustomContext = (0, _withMetroResolvers).withMetroMutatedResolverContext(metroConfigWithCustomResolver, (immutableContext, moduleName, platform)=>{
|
|
295
|
+
var ref;
|
|
296
|
+
const context = {
|
|
297
|
+
...immutableContext
|
|
298
|
+
};
|
|
299
|
+
if (((ref = context.customResolverOptions) == null ? void 0 : ref.environment) === "node") {
|
|
300
|
+
// Adjust nodejs source extensions to sort mjs after js, including platform variants.
|
|
301
|
+
if (nodejsSourceExtensions === null) {
|
|
302
|
+
nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);
|
|
303
|
+
}
|
|
304
|
+
context.sourceExts = nodejsSourceExtensions;
|
|
305
|
+
context.unstable_enablePackageExports = true;
|
|
306
|
+
context.unstable_conditionNames = [
|
|
307
|
+
"node",
|
|
308
|
+
"require"
|
|
309
|
+
];
|
|
310
|
+
context.unstable_conditionsByPlatform = {};
|
|
311
|
+
// Node.js runtimes should only be importing main at the moment.
|
|
312
|
+
// This is a temporary fix until we can support the package.json exports.
|
|
313
|
+
context.mainFields = [
|
|
314
|
+
"main",
|
|
315
|
+
"module"
|
|
316
|
+
];
|
|
317
|
+
} else {
|
|
318
|
+
// Non-server changes
|
|
319
|
+
if (!_env.env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE && platform && platform in preferredMainFields) {
|
|
320
|
+
context.mainFields = preferredMainFields[platform];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// TODO: We may be able to remove this in the future, it's doing no harm
|
|
324
|
+
// by staying here.
|
|
325
|
+
// Conditionally remap `react-native` to `react-native-web`
|
|
326
|
+
if (platform && platform in extraNodeModules) {
|
|
327
|
+
context.extraNodeModules = {
|
|
328
|
+
...extraNodeModules[platform],
|
|
329
|
+
...context.extraNodeModules
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
if ((tsconfig == null ? void 0 : tsconfig.baseUrl) && isTsconfigPathsEnabled) {
|
|
333
|
+
const nodeModulesPaths = [
|
|
334
|
+
...immutableContext.nodeModulesPaths
|
|
335
|
+
];
|
|
336
|
+
if (isFastResolverEnabled) {
|
|
337
|
+
// add last to ensure node modules are resolved first
|
|
338
|
+
nodeModulesPaths.push(_path.default.isAbsolute(tsconfig.baseUrl) ? tsconfig.baseUrl : _path.default.join(config.projectRoot, tsconfig.baseUrl));
|
|
339
|
+
} else {
|
|
340
|
+
// add last to ensure node modules are resolved first
|
|
341
|
+
nodeModulesPaths.push(tsconfig.baseUrl);
|
|
342
|
+
}
|
|
343
|
+
context.nodeModulesPaths = nodeModulesPaths;
|
|
344
|
+
}
|
|
345
|
+
// TODO: We can drop this in the next version upgrade (SDK 50).
|
|
346
|
+
const mainFields = context.mainFields;
|
|
347
|
+
return {
|
|
348
|
+
...context,
|
|
349
|
+
preferNativePlatform: platform !== "web",
|
|
350
|
+
// Passing `mainFields` directly won't be considered (in certain version of Metro)
|
|
351
|
+
// we need to extend the `getPackageMainPath` directly to
|
|
352
|
+
// use platform specific `mainFields`.
|
|
353
|
+
// @ts-ignore
|
|
354
|
+
getPackageMainPath (packageJsonPath) {
|
|
355
|
+
// @ts-expect-error: mainFields is not on type
|
|
356
|
+
const package_ = context.moduleCache.getPackage(packageJsonPath);
|
|
357
|
+
return package_.getMain(mainFields);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
return (0, _withMetroResolvers).withMetroErrorReportingResolver(metroConfigWithCustomContext);
|
|
292
362
|
}
|
|
293
363
|
function shouldAliasAssetRegistryForWeb(platform, result) {
|
|
294
364
|
return platform === "web" && (result == null ? void 0 : result.type) === "sourceFile" && typeof (result == null ? void 0 : result.filePath) === "string" && normalizeSlashes(result.filePath).endsWith("react-native-web/dist/modules/AssetRegistry/index.js");
|
|
295
365
|
}
|
|
296
366
|
function shouldAliasModule(input, alias) {
|
|
297
|
-
var ref,
|
|
298
|
-
return input.platform === alias.platform && ((ref = input.result) == null ? void 0 : ref.type) === "sourceFile" && typeof ((
|
|
367
|
+
var ref, ref6;
|
|
368
|
+
return input.platform === alias.platform && ((ref = input.result) == null ? void 0 : ref.type) === "sourceFile" && typeof ((ref6 = input.result) == null ? void 0 : ref6.filePath) === "string" && normalizeSlashes(input.result.filePath).endsWith(alias.output);
|
|
299
369
|
}
|
|
300
|
-
async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , webOutput , routerDirectory }) {
|
|
370
|
+
async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , webOutput , routerDirectory , isFastResolverEnabled , isExporting }) {
|
|
371
|
+
if (!config.projectRoot) {
|
|
372
|
+
// @ts-expect-error: read-only types
|
|
373
|
+
config.projectRoot = projectRoot;
|
|
374
|
+
}
|
|
301
375
|
// Auto pick app entry for router.
|
|
302
376
|
process.env.EXPO_ROUTER_APP_ROOT = (0, _router).getAppRouterRelativeEntryPath(projectRoot, routerDirectory);
|
|
303
377
|
var _EXPO_PUBLIC_PROJECT_ROOT;
|
|
@@ -310,6 +384,15 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
310
384
|
// Enable static rendering in runtime space.
|
|
311
385
|
process.env.EXPO_PUBLIC_USE_STATIC = "1";
|
|
312
386
|
}
|
|
387
|
+
// This is used for running Expo CLI in development against projects outside the monorepo.
|
|
388
|
+
if (!isDirectoryIn(__dirname, projectRoot)) {
|
|
389
|
+
if (!config.watchFolders) {
|
|
390
|
+
// @ts-expect-error: watchFolders is readonly
|
|
391
|
+
config.watchFolders = [];
|
|
392
|
+
}
|
|
393
|
+
// @ts-expect-error: watchFolders is readonly
|
|
394
|
+
config.watchFolders.push(_path.default.join(require.resolve("metro-runtime/package.json"), "../.."));
|
|
395
|
+
}
|
|
313
396
|
// Ensure the cache is invalidated if these values change.
|
|
314
397
|
// @ts-expect-error
|
|
315
398
|
config.transformer._expoRouterRootDirectory = process.env.EXPO_ROUTER_APP_ROOT;
|
|
@@ -321,18 +404,10 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
321
404
|
}
|
|
322
405
|
let tsconfig = null;
|
|
323
406
|
if (isTsconfigPathsEnabled) {
|
|
324
|
-
_log.Log.warn(_chalk.default.yellow`Experimental path aliases feature is enabled. ` + (0, _link).learnMore("https://docs.expo.dev/guides/typescript/#path-aliases"));
|
|
325
407
|
tsconfig = await (0, _loadTsConfigPaths).loadTsConfigPathsAsync(projectRoot);
|
|
326
408
|
}
|
|
409
|
+
await (0, _externals).setupShimFiles(projectRoot);
|
|
327
410
|
await (0, _externals).setupNodeExternals(projectRoot);
|
|
328
|
-
return withMetroMultiPlatform(projectRoot, {
|
|
329
|
-
config,
|
|
330
|
-
platformBundlers,
|
|
331
|
-
tsconfig,
|
|
332
|
-
isTsconfigPathsEnabled
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , tsconfig }) {
|
|
336
411
|
let expoConfigPlatforms = Object.entries(platformBundlers).filter(([, bundler])=>bundler === "metro"
|
|
337
412
|
).map(([platform])=>platform
|
|
338
413
|
);
|
|
@@ -343,15 +418,17 @@ function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsc
|
|
|
343
418
|
}
|
|
344
419
|
// @ts-expect-error: typed as `readonly`.
|
|
345
420
|
config.resolver.platforms = expoConfigPlatforms;
|
|
346
|
-
|
|
347
|
-
config = withWebPolyfills(config, projectRoot);
|
|
348
|
-
}
|
|
421
|
+
config = withWebPolyfills(config);
|
|
349
422
|
return withExtendedResolver(config, {
|
|
350
|
-
projectRoot,
|
|
351
423
|
tsconfig,
|
|
424
|
+
isExporting,
|
|
352
425
|
isTsconfigPathsEnabled,
|
|
353
|
-
platforms: expoConfigPlatforms
|
|
426
|
+
platforms: expoConfigPlatforms,
|
|
427
|
+
isFastResolverEnabled
|
|
354
428
|
});
|
|
355
429
|
}
|
|
430
|
+
function isDirectoryIn(a, b) {
|
|
431
|
+
return b.startsWith(a) && b.length > a.length;
|
|
432
|
+
}
|
|
356
433
|
|
|
357
434
|
//# sourceMappingURL=withMetroMultiPlatform.js.map
|