@expo/cli 0.14.0 → 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 +5 -4
- 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/customize/typescript.js +3 -1
- 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/resolveOptions.js +3 -3
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +69 -80
- 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 +4 -4
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +55 -20
- 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 +12 -10
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +9 -7
- 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/writeContents.js +3 -2
- 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/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/prebuildAsync.js +37 -15
- 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/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/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 -23
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +48 -64
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +4 -3
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +62 -45
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- 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/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 +32 -10
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +4 -1
- 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 +261 -201
- 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 +15 -66
- 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/type-generation/__typetests__/fixtures/basic.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 +1 -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 +3 -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/package.json +15 -14
- package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
- package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
- package/build/src/start/server/metro/resolveFromProject.js +0 -90
- package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
|
@@ -8,12 +8,12 @@ exports.shouldAliasAssetRegistryForWeb = shouldAliasAssetRegistryForWeb;
|
|
|
8
8
|
exports.shouldAliasModule = shouldAliasModule;
|
|
9
9
|
exports.withMetroMultiPlatformAsync = withMetroMultiPlatformAsync;
|
|
10
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
var metroResolver = _interopRequireWildcard(require("metro-resolver"));
|
|
11
12
|
var _path = _interopRequireDefault(require("path"));
|
|
12
13
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
13
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");
|
|
@@ -29,22 +29,43 @@ function _interopRequireDefault(obj) {
|
|
|
29
29
|
default: obj
|
|
30
30
|
};
|
|
31
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
|
+
}
|
|
32
53
|
const debug = require("debug")("expo:start:server:metro:multi-platform");
|
|
33
|
-
function withWebPolyfills(config
|
|
54
|
+
function withWebPolyfills(config) {
|
|
34
55
|
const originalGetPolyfills = config.serializer.getPolyfills ? config.serializer.getPolyfills.bind(config.serializer) : ()=>[]
|
|
35
56
|
;
|
|
36
57
|
const getPolyfills = (ctx)=>{
|
|
37
58
|
if (ctx.platform === "web") {
|
|
38
59
|
return [
|
|
39
60
|
// NOTE: We might need this for all platforms
|
|
40
|
-
_path.default.join(projectRoot, _externals.EXTERNAL_REQUIRE_POLYFILL)
|
|
61
|
+
_path.default.join(config.projectRoot, _externals.EXTERNAL_REQUIRE_POLYFILL)
|
|
41
62
|
];
|
|
42
63
|
}
|
|
43
64
|
// Generally uses `rn-get-polyfills`
|
|
44
65
|
const polyfills = originalGetPolyfills(ctx);
|
|
45
66
|
return [
|
|
46
67
|
...polyfills,
|
|
47
|
-
_externals.EXTERNAL_REQUIRE_NATIVE_POLYFILL
|
|
68
|
+
_path.default.join(config.projectRoot, _externals.EXTERNAL_REQUIRE_NATIVE_POLYFILL)
|
|
48
69
|
];
|
|
49
70
|
};
|
|
50
71
|
return {
|
|
@@ -71,26 +92,23 @@ function getNodejsExtensions(srcExts) {
|
|
|
71
92
|
nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);
|
|
72
93
|
return nodejsSourceExtensions;
|
|
73
94
|
}
|
|
74
|
-
function withExtendedResolver(config, {
|
|
75
|
-
var ref2;
|
|
95
|
+
function withExtendedResolver(config, { tsconfig , platforms , isTsconfigPathsEnabled , isFastResolverEnabled , isExporting }) {
|
|
96
|
+
var ref5, ref1, ref2, ref3;
|
|
76
97
|
if (isFastResolverEnabled) {
|
|
77
98
|
_log.Log.warn(`Experimental bundling features are enabled.`);
|
|
78
99
|
}
|
|
79
100
|
// Get the `transformer.assetRegistryPath`
|
|
80
101
|
// this needs to be unified since you can't dynamically
|
|
81
102
|
// swap out the transformer based on platform.
|
|
82
|
-
const assetRegistryPath = _fs.default.realpathSync(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
reactNativeWebAppContainer = _fs.default.realpathSync(// This is the native asset registry alias for native.
|
|
87
|
-
_path.default.resolve((0, _resolveFrom).default(projectRoot, "expo-router/build/fork/react-native-web-container")));
|
|
88
|
-
} catch {}
|
|
89
|
-
const isWebEnabled = platforms.includes("web");
|
|
90
|
-
var ref1;
|
|
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;
|
|
91
106
|
const resolver = isFastResolverEnabled ? (0, _createExpoMetroResolver).createFastResolver({
|
|
92
|
-
preserveSymlinks: (
|
|
93
|
-
|
|
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;
|
|
94
112
|
const extraNodeModules = {};
|
|
95
113
|
const aliases = {
|
|
96
114
|
web: {
|
|
@@ -98,6 +116,8 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
98
116
|
"react-native/index": "react-native-web"
|
|
99
117
|
}
|
|
100
118
|
};
|
|
119
|
+
// TODO: We can probably drop this resolution hack.
|
|
120
|
+
const isWebEnabled = platforms.includes("web");
|
|
101
121
|
if (isWebEnabled) {
|
|
102
122
|
// Allow `react-native-web` to be optional when web is not enabled but path aliases is.
|
|
103
123
|
extraNodeModules["web"] = {
|
|
@@ -119,201 +139,239 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
119
139
|
paths: (_paths1 = tsconfig.paths) != null ? _paths1 : {},
|
|
120
140
|
baseUrl: tsconfig.baseUrl
|
|
121
141
|
}) : null;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
});
|
|
144
167
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
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
|
+
}
|
|
152
175
|
}
|
|
153
176
|
let nodejsSourceExtensions = null;
|
|
154
|
-
const shimsFolder = _path.default.join(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
// Adjust nodejs source extensions to sort mjs after js, including platform variants.
|
|
173
|
-
if (nodejsSourceExtensions === null) {
|
|
174
|
-
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;
|
|
175
194
|
}
|
|
176
|
-
context.sourceExts = nodejsSourceExtensions;
|
|
177
|
-
}
|
|
178
|
-
// Conditionally remap `react-native` to `react-native-web` on web in
|
|
179
|
-
// a way that doesn't require Babel to resolve the alias.
|
|
180
|
-
if (platform && platform in aliases && aliases[platform][moduleName1]) {
|
|
181
|
-
moduleName1 = aliases[platform][moduleName1];
|
|
182
|
-
}
|
|
183
|
-
// TODO: We may be able to remove this in the future, it's doing no harm
|
|
184
|
-
// by staying here.
|
|
185
|
-
// Conditionally remap `react-native` to `react-native-web`
|
|
186
|
-
if (platform && platform in extraNodeModules) {
|
|
187
|
-
context.extraNodeModules = {
|
|
188
|
-
...extraNodeModules[platform],
|
|
189
|
-
...context.extraNodeModules
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
if ((tsconfig == null ? void 0 : tsconfig.baseUrl) && isTsconfigPathsEnabled) {
|
|
193
|
-
context = {
|
|
194
|
-
...context,
|
|
195
|
-
nodeModulesPaths: [
|
|
196
|
-
...immutableContext.nodeModulesPaths,
|
|
197
|
-
// add last to ensure node modules are resolved first
|
|
198
|
-
tsconfig.baseUrl,
|
|
199
|
-
]
|
|
200
|
-
};
|
|
201
195
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
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;
|
|
214
216
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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;
|
|
230
232
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return doResolve(moduleName);
|
|
234
|
-
} catch (error) {
|
|
235
|
-
// If the error is directly related to a resolver not being able to resolve a module, then
|
|
236
|
-
// we can ignore the error and try the next resolver. Otherwise, we should throw the error.
|
|
237
|
-
const isResolutionError = (0, _metroErrors).isFailedToResolveNameError(error) || (0, _metroErrors).isFailedToResolvePathError(error);
|
|
238
|
-
if (!isResolutionError) {
|
|
239
|
-
throw error;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
233
|
+
const moduleId = (0, _externals).isNodeExternal(moduleName);
|
|
234
|
+
if (!moduleId) {
|
|
242
235
|
return null;
|
|
243
236
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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);
|
|
252
250
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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");
|
|
258
262
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return {
|
|
269
|
-
type: "empty"
|
|
270
|
-
};
|
|
271
|
-
}
|
|
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;
|
|
272
272
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
platform,
|
|
287
|
-
result
|
|
288
|
-
}, {
|
|
289
|
-
platform: "web",
|
|
290
|
-
output: "react-native-web/dist/exports/AppRegistry/AppContainer.js"
|
|
291
|
-
})) {
|
|
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)) {
|
|
292
286
|
// @ts-expect-error: `readonly` for some reason.
|
|
293
|
-
result.filePath =
|
|
294
|
-
} else if (platform === "web" && result.filePath.includes("node_modules")) {
|
|
295
|
-
// Replace with static shims
|
|
296
|
-
const normalName = normalizeSlashes(result.filePath)// Drop everything up until the `node_modules` folder.
|
|
297
|
-
.replace(/.*node_modules\//, "");
|
|
298
|
-
const shimPath = _path.default.join(shimsFolder, normalName);
|
|
299
|
-
if (_fs.default.existsSync(shimPath)) {
|
|
300
|
-
// @ts-expect-error: `readonly` for some reason.
|
|
301
|
-
result.filePath = shimPath;
|
|
302
|
-
}
|
|
287
|
+
result.filePath = shimPath;
|
|
303
288
|
}
|
|
304
289
|
}
|
|
305
290
|
return result;
|
|
306
291
|
},
|
|
307
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);
|
|
308
362
|
}
|
|
309
363
|
function shouldAliasAssetRegistryForWeb(platform, result) {
|
|
310
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");
|
|
311
365
|
}
|
|
312
366
|
function shouldAliasModule(input, alias) {
|
|
313
|
-
var ref,
|
|
314
|
-
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);
|
|
315
369
|
}
|
|
316
|
-
async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , webOutput , routerDirectory , isFastResolverEnabled }) {
|
|
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
|
+
}
|
|
317
375
|
// Auto pick app entry for router.
|
|
318
376
|
process.env.EXPO_ROUTER_APP_ROOT = (0, _router).getAppRouterRelativeEntryPath(projectRoot, routerDirectory);
|
|
319
377
|
var _EXPO_PUBLIC_PROJECT_ROOT;
|
|
@@ -326,6 +384,15 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
326
384
|
// Enable static rendering in runtime space.
|
|
327
385
|
process.env.EXPO_PUBLIC_USE_STATIC = "1";
|
|
328
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
|
+
}
|
|
329
396
|
// Ensure the cache is invalidated if these values change.
|
|
330
397
|
// @ts-expect-error
|
|
331
398
|
config.transformer._expoRouterRootDirectory = process.env.EXPO_ROUTER_APP_ROOT;
|
|
@@ -339,16 +406,8 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
339
406
|
if (isTsconfigPathsEnabled) {
|
|
340
407
|
tsconfig = await (0, _loadTsConfigPaths).loadTsConfigPathsAsync(projectRoot);
|
|
341
408
|
}
|
|
409
|
+
await (0, _externals).setupShimFiles(projectRoot);
|
|
342
410
|
await (0, _externals).setupNodeExternals(projectRoot);
|
|
343
|
-
return withMetroMultiPlatform(projectRoot, {
|
|
344
|
-
config,
|
|
345
|
-
platformBundlers,
|
|
346
|
-
tsconfig,
|
|
347
|
-
isTsconfigPathsEnabled,
|
|
348
|
-
isFastResolverEnabled
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , tsconfig , isFastResolverEnabled }) {
|
|
352
411
|
let expoConfigPlatforms = Object.entries(platformBundlers).filter(([, bundler])=>bundler === "metro"
|
|
353
412
|
).map(([platform])=>platform
|
|
354
413
|
);
|
|
@@ -359,16 +418,17 @@ function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsc
|
|
|
359
418
|
}
|
|
360
419
|
// @ts-expect-error: typed as `readonly`.
|
|
361
420
|
config.resolver.platforms = expoConfigPlatforms;
|
|
362
|
-
|
|
363
|
-
config = withWebPolyfills(config, projectRoot);
|
|
364
|
-
}
|
|
421
|
+
config = withWebPolyfills(config);
|
|
365
422
|
return withExtendedResolver(config, {
|
|
366
|
-
projectRoot,
|
|
367
423
|
tsconfig,
|
|
424
|
+
isExporting,
|
|
368
425
|
isTsconfigPathsEnabled,
|
|
369
426
|
platforms: expoConfigPlatforms,
|
|
370
427
|
isFastResolverEnabled
|
|
371
428
|
});
|
|
372
429
|
}
|
|
430
|
+
function isDirectoryIn(a, b) {
|
|
431
|
+
return b.startsWith(a) && b.length > a.length;
|
|
432
|
+
}
|
|
373
433
|
|
|
374
434
|
//# sourceMappingURL=withMetroMultiPlatform.js.map
|