@expo/metro-config 0.2.8 → 0.3.3

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.
@@ -11,6 +11,8 @@ const chalk_1 = __importDefault(require("chalk"));
11
11
  const getenv_1 = require("getenv");
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const resolve_from_1 = __importDefault(require("resolve-from"));
14
+ const getModulesPaths_1 = require("./getModulesPaths");
15
+ const getWatchFolders_1 = require("./getWatchFolders");
14
16
  const importMetroFromProject_1 = require("./importMetroFromProject");
15
17
  exports.EXPO_DEBUG = getenv_1.boolish('EXPO_DEBUG', false);
16
18
  const EXPO_USE_EXOTIC = getenv_1.boolish('EXPO_USE_EXOTIC', false);
@@ -58,6 +60,23 @@ function getProjectBabelConfigFile(projectRoot) {
58
60
  resolve_from_1.default.silent(projectRoot, './.babelrc') ||
59
61
  resolve_from_1.default.silent(projectRoot, './.babelrc.js'));
60
62
  }
63
+ function getAssetPlugins(projectRoot) {
64
+ const assetPlugins = [];
65
+ let hashAssetFilesPath;
66
+ try {
67
+ hashAssetFilesPath = resolve_from_1.default(projectRoot, 'expo-asset/tools/hashAssetFiles');
68
+ }
69
+ catch {
70
+ // TODO: we should warn/throw an error if the user has expo-updates installed but does not
71
+ // have hashAssetFiles available, or if the user is in managed workflow and does not have
72
+ // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,
73
+ // it is not needed
74
+ }
75
+ if (hashAssetFilesPath) {
76
+ assetPlugins.push(hashAssetFilesPath);
77
+ }
78
+ return assetPlugins;
79
+ }
61
80
  let hasWarnedAboutExotic = false;
62
81
  function getDefaultConfig(projectRoot, options = {}) {
63
82
  const isExotic = options.mode === 'exotic' || EXPO_USE_EXOTIC;
@@ -77,16 +96,6 @@ function getDefaultConfig(projectRoot, options = {}) {
77
96
  catch {
78
97
  // noop -- falls back to a hardcoded value.
79
98
  }
80
- let hashAssetFilesPath;
81
- try {
82
- hashAssetFilesPath = resolve_from_1.default(projectRoot, 'expo-asset/tools/hashAssetFiles');
83
- }
84
- catch {
85
- // TODO: we should warn/throw an error if the user has expo-updates installed but does not
86
- // have hashAssetFiles available, or if the user is in managed workflow and does not have
87
- // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,
88
- // it is not needed
89
- }
90
99
  const isLegacy = readIsLegacyImportsEnabled(projectRoot);
91
100
  // Deprecated -- SDK 41 --
92
101
  if (options.target) {
@@ -137,15 +146,24 @@ function getDefaultConfig(projectRoot, options = {}) {
137
146
  resolverMainFields.push('react-native');
138
147
  }
139
148
  resolverMainFields.push('browser', 'main');
149
+ const watchFolders = getWatchFolders_1.getWatchFolders(projectRoot);
150
+ // TODO: nodeModulesPaths does not work with the new Node.js package.json exports API, this causes packages like uuid to fail. Disabling for now.
151
+ const nodeModulesPaths = getModulesPaths_1.getModulesPaths(projectRoot);
140
152
  if (exports.EXPO_DEBUG) {
141
153
  console.log();
142
154
  console.log(`Expo Metro config:`);
155
+ try {
156
+ console.log(`- Version: ${require('../package.json').version}`);
157
+ }
158
+ catch { }
143
159
  console.log(`- Bundler target: ${target}`);
144
160
  console.log(`- Legacy: ${isLegacy}`);
145
161
  console.log(`- Extensions: ${sourceExts.join(', ')}`);
146
162
  console.log(`- React Native: ${reactNativePath}`);
147
163
  console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);
148
164
  console.log(`- Resolver Fields: ${resolverMainFields.join(', ')}`);
165
+ console.log(`- Watch Folders: ${watchFolders.join(', ')}`);
166
+ console.log(`- Node Module Paths: ${nodeModulesPaths.join(', ')}`);
149
167
  console.log(`- Exotic: ${isExotic}`);
150
168
  console.log();
151
169
  }
@@ -156,10 +174,12 @@ function getDefaultConfig(projectRoot, options = {}) {
156
174
  // Merge in the default config from Metro here, even though loadConfig uses it as defaults.
157
175
  // This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.
158
176
  return MetroConfig.mergeConfig(metroDefaultValues, {
177
+ watchFolders,
159
178
  resolver: {
160
179
  resolverMainFields,
161
180
  platforms: ['ios', 'android', 'native'],
162
181
  sourceExts,
182
+ nodeModulesPaths,
163
183
  },
164
184
  serializer: {
165
185
  getModulesRunBeforeMainModule: () => [
@@ -200,7 +220,7 @@ function getDefaultConfig(projectRoot, options = {}) {
200
220
  : // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.
201
221
  require.resolve('./transformer/metro-expo-babel-transformer'),
202
222
  assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
203
- assetPlugins: hashAssetFilesPath ? [hashAssetFilesPath] : [],
223
+ assetPlugins: getAssetPlugins(projectRoot),
204
224
  },
205
225
  });
206
226
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoMetroConfig.js","sourceRoot":"","sources":["../src/ExpoMetroConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;;;;;;AAErE,yCAAkG;AAClG,8CAA6E;AAC7E,kDAA0B;AAC1B,mCAAiC;AAGjC,gDAAwB;AACxB,gEAAuC;AAEvC,qEAAwE;AAE3D,QAAA,UAAU,GAAG,gBAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACvD,MAAM,eAAe,GAAG,gBAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAE1D,wFAAwF;AAC3E,QAAA,wBAAwB,GAAG,IAAI,MAAM,CAChD;IACE,8CAA8C;IAC9C,6CAA6C;IAC7C,+BAA+B;IAC/B,4BAA4B;IAC5B,iCAAiC;IACjC,2CAA2C;IAC3C,qCAAqC;IACrC,iCAAiC;IACjC,sDAAsD;IACtD,oDAAoD;IACpD,sCAAsC;IACtC,iCAAiC;IACjC,yCAAyC;IACzC,uCAAuC;IACvC,uCAAuC;IACvC,6DAA6D;IAC7D,qCAAqC;IACrC,8CAA8C;IAC9C,mDAAmD;IACnD,kDAAkD;IAClD,2CAA2C;IAC3C,oCAAoC;IACpC,kGAAkG;IAClG,iCAAiC;IACjC,iCAAiC;IACjC,2CAA2C;IAC3C,4CAA4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G,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,EAClD,aAAa,CACd,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport { getConfig, getDefaultTarget, isLegacyImportsEnabled, ProjectTarget } from '@expo/config';\nimport { getBareExtensions, getManagedExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport { boolish } from 'getenv';\nimport { Reporter } from 'metro';\nimport type MetroConfig from 'metro-config';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { importMetroConfigFromProject } from './importMetroFromProject';\n\nexport const EXPO_DEBUG = boolish('EXPO_DEBUG', false);\nconst EXPO_USE_EXOTIC = boolish('EXPO_USE_EXOTIC', false);\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Ignore the log forwarder used in the Expo Go app\n '/expo/build/environment/react-native-logs.fx.js$',\n '/src/environment/react-native-logs.fx.ts$',\n '/expo/build/logs/RemoteConsole.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n ].join('|')\n);\n\nexport interface DefaultConfigOptions {\n target?: ProjectTarget;\n mode?: 'exotic';\n}\n\nfunction readIsLegacyImportsEnabled(projectRoot: string): boolean {\n const config = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n return isLegacyImportsEnabled(config.exp);\n}\n\nfunction getProjectBabelConfigFile(projectRoot: string): string | undefined {\n return (\n resolveFrom.silent(projectRoot, './babel.config.js') ||\n resolveFrom.silent(projectRoot, './.babelrc') ||\n resolveFrom.silent(projectRoot, './.babelrc.js')\n );\n}\n\nlet hasWarnedAboutExotic = false;\n\nexport function getDefaultConfig(\n projectRoot: string,\n options: DefaultConfigOptions = {}\n): MetroConfig.InputConfigT {\n const isExotic = options.mode === 'exotic' || EXPO_USE_EXOTIC;\n\n if (isExotic && !hasWarnedAboutExotic) {\n hasWarnedAboutExotic = true;\n console.log(\n chalk.gray(\n `\\u203A Unstable feature ${chalk.bold`EXPO_USE_EXOTIC`} is enabled. Bundling may not work as expected, and is subject to breaking changes.`\n )\n );\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n\n const reactNativePath = path.dirname(resolveFrom(projectRoot, 'react-native/package.json'));\n\n try {\n // Set the `EXPO_METRO_CACHE_KEY_VERSION` variable for use in the custom babel transformer.\n // This hack is used because there doesn't appear to be anyway to resolve\n // `babel-preset-fbjs` relative to the project root later (in `metro-expo-babel-transformer`).\n const babelPresetFbjsPath = resolveFrom(projectRoot, 'babel-preset-fbjs/package.json');\n process.env.EXPO_METRO_CACHE_KEY_VERSION = String(require(babelPresetFbjsPath).version);\n } catch {\n // noop -- falls back to a hardcoded value.\n }\n\n let hashAssetFilesPath;\n try {\n hashAssetFilesPath = resolveFrom(projectRoot, 'expo-asset/tools/hashAssetFiles');\n } catch {\n // TODO: we should warn/throw an error if the user has expo-updates installed but does not\n // have hashAssetFiles available, or if the user is in managed workflow and does not have\n // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,\n // it is not needed\n }\n\n const isLegacy = readIsLegacyImportsEnabled(projectRoot);\n // Deprecated -- SDK 41 --\n if (options.target) {\n if (!isLegacy) {\n console.warn(\n chalk.yellow(\n `The target option is deprecated. Learn more: http://expo.fyi/expo-extension-migration`\n )\n );\n delete options.target;\n }\n } else if (process.env.EXPO_TARGET) {\n console.error(\n 'EXPO_TARGET is deprecated. Learn more: http://expo.fyi/expo-extension-migration'\n );\n if (isLegacy) {\n // EXPO_TARGET is used by @expo/metro-config to determine the target when getDefaultConfig is\n // called from metro.config.js.\n // @ts-ignore\n options.target = process.env.EXPO_TARGET;\n }\n } else if (isLegacy) {\n // Fall back to guessing based on the project structure in legacy mode.\n options.target = getDefaultTarget(projectRoot);\n }\n\n if (!options.target) {\n // Default to bare -- no .expo extension.\n options.target = 'bare';\n }\n // End deprecated -- SDK 41 --\n\n const { target } = options;\n if (!(target === 'managed' || target === 'bare')) {\n throw new Error(\n `Invalid target: '${target}'. Debug info: \\n${JSON.stringify(\n {\n 'options.target': options.target,\n default: getDefaultTarget(projectRoot),\n },\n null,\n 2\n )}`\n );\n }\n const sourceExtsConfig = { isTS: true, isReact: true, isModern: false };\n const sourceExts =\n target === 'bare'\n ? getBareExtensions([], sourceExtsConfig)\n : getManagedExtensions([], sourceExtsConfig);\n\n if (isExotic) {\n // Add support for cjs (without platform extensions).\n sourceExts.push('cjs');\n }\n\n const babelConfigPath = getProjectBabelConfigFile(projectRoot);\n const isCustomBabelConfigDefined = !!babelConfigPath;\n\n const resolverMainFields: string[] = [];\n\n // Disable `react-native` in exotic mode, since library authors\n // use it to ship raw application code to the project.\n if (!isExotic) {\n resolverMainFields.push('react-native');\n }\n resolverMainFields.push('browser', 'main');\n\n if (EXPO_DEBUG) {\n console.log();\n console.log(`Expo Metro config:`);\n console.log(`- Bundler target: ${target}`);\n console.log(`- Legacy: ${isLegacy}`);\n console.log(`- Extensions: ${sourceExts.join(', ')}`);\n console.log(`- React Native: ${reactNativePath}`);\n console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);\n console.log(`- Resolver Fields: ${resolverMainFields.join(', ')}`);\n console.log(`- Exotic: ${isExotic}`);\n console.log();\n }\n const {\n // Remove the default reporter which metro always resolves to be the react-native-community/cli reporter.\n // This prints a giant React logo which is less accessible to users on smaller terminals.\n reporter,\n ...metroDefaultValues\n } = MetroConfig.getDefaultConfig.getDefaultValues(projectRoot);\n\n // Merge in the default config from Metro here, even though loadConfig uses it as defaults.\n // This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.\n return MetroConfig.mergeConfig(metroDefaultValues, {\n resolver: {\n resolverMainFields,\n platforms: ['ios', 'android', 'native'],\n sourceExts,\n },\n serializer: {\n getModulesRunBeforeMainModule: () => [\n require.resolve(path.join(reactNativePath, 'Libraries/Core/InitializeCore')),\n // TODO: Bacon: load Expo side-effects\n ],\n getPolyfills: () => require(path.join(reactNativePath, 'rn-get-polyfills'))(),\n },\n server: {\n port: Number(process.env.RCT_METRO_PORT) || 8081,\n },\n symbolicator: {\n customizeFrame: frame => {\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n },\n },\n transformer: {\n allowOptionalDependencies: true,\n babelTransformerPath: isExotic\n ? require.resolve('./transformer/metro-expo-exotic-babel-transformer')\n : isCustomBabelConfigDefined\n ? // If the user defined a babel config file in their project,\n // then use the default transformer.\n // Try to use the project copy before falling back on the global version\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer')\n : // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.\n require.resolve('./transformer/metro-expo-babel-transformer'),\n assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',\n assetPlugins: hashAssetFilesPath ? [hashAssetFilesPath] : [],\n },\n });\n}\n\nexport interface LoadOptions {\n config?: string;\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n target?: ProjectTarget;\n}\n\nexport async function loadAsync(\n projectRoot: string,\n { reporter, target, ...metroOptions }: LoadOptions = {}\n): Promise<MetroConfig.ConfigT> {\n let defaultConfig = getDefaultConfig(projectRoot, { target });\n if (reporter) {\n defaultConfig = { ...defaultConfig, reporter };\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n return await MetroConfig.loadConfig(\n { cwd: projectRoot, projectRoot, ...metroOptions },\n defaultConfig\n );\n}\n"]}
1
+ {"version":3,"file":"ExpoMetroConfig.js","sourceRoot":"","sources":["../src/ExpoMetroConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;;;;;;AAErE,yCAAkG;AAClG,8CAA6E;AAC7E,kDAA0B;AAC1B,mCAAiC;AAGjC,gDAAwB;AACxB,gEAAuC;AAEvC,uDAAoD;AACpD,uDAAoD;AACpD,qEAAwE;AAE3D,QAAA,UAAU,GAAG,gBAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACvD,MAAM,eAAe,GAAG,gBAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAE1D,wFAAwF;AAC3E,QAAA,wBAAwB,GAAG,IAAI,MAAM,CAChD;IACE,8CAA8C;IAC9C,6CAA6C;IAC7C,+BAA+B;IAC/B,4BAA4B;IAC5B,iCAAiC;IACjC,2CAA2C;IAC3C,qCAAqC;IACrC,iCAAiC;IACjC,sDAAsD;IACtD,oDAAoD;IACpD,sCAAsC;IACtC,iCAAiC;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AAE,IAAI;YAC/B,oBAAoB,EAAE,QAAQ;gBAC5B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mDAAmD,CAAC;gBACtE,CAAC,CAAC,0BAA0B;oBAC5B,CAAC,CAAC,4DAA4D;wBAC5D,oCAAoC;wBACpC,wEAAwE;wBACxE,sBAAW,CAAC,MAAM,CAAC,WAAW,EAAE,sCAAsC,CAAC;oBACzE,CAAC,CAAC,6FAA6F;wBAC7F,OAAO,CAAC,OAAO,CAAC,4CAA4C,CAAC;YACjE,iBAAiB,EAAE,4CAA4C;YAC/D,YAAY,EAAE,eAAe,CAAC,WAAW,CAAC;SAC3C;KACF,CAAC,CAAC;AACL,CAAC;AAlLD,4CAkLC;AAWM,KAAK,UAAU,SAAS,CAC7B,WAAmB,EACnB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,KAAkB,EAAE;IAEvD,IAAI,aAAa,GAAG,gBAAgB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,IAAI,QAAQ,EAAE;QACZ,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE,CAAC;KAChD;IACD,MAAM,WAAW,GAAG,qDAA4B,CAAC,WAAW,CAAC,CAAC;IAC9D,OAAO,MAAM,WAAW,CAAC,UAAU,CACjC,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,EAClD,aAAa,CACd,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport { getConfig, getDefaultTarget, isLegacyImportsEnabled, ProjectTarget } from '@expo/config';\nimport { getBareExtensions, getManagedExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport { boolish } from 'getenv';\nimport { Reporter } from 'metro';\nimport type MetroConfig from 'metro-config';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { getModulesPaths } from './getModulesPaths';\nimport { getWatchFolders } from './getWatchFolders';\nimport { importMetroConfigFromProject } from './importMetroFromProject';\n\nexport const EXPO_DEBUG = boolish('EXPO_DEBUG', false);\nconst EXPO_USE_EXOTIC = boolish('EXPO_USE_EXOTIC', false);\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Ignore the log forwarder used in the Expo Go app\n '/expo/build/environment/react-native-logs.fx.js$',\n '/src/environment/react-native-logs.fx.ts$',\n '/expo/build/logs/RemoteConsole.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n ].join('|')\n);\n\nexport interface DefaultConfigOptions {\n target?: ProjectTarget;\n mode?: 'exotic';\n}\n\nfunction readIsLegacyImportsEnabled(projectRoot: string): boolean {\n const config = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n return isLegacyImportsEnabled(config.exp);\n}\n\nfunction getProjectBabelConfigFile(projectRoot: string): string | undefined {\n return (\n resolveFrom.silent(projectRoot, './babel.config.js') ||\n resolveFrom.silent(projectRoot, './.babelrc') ||\n resolveFrom.silent(projectRoot, './.babelrc.js')\n );\n}\n\nfunction getAssetPlugins(projectRoot: string): string[] {\n const assetPlugins: string[] = [];\n\n let hashAssetFilesPath;\n try {\n hashAssetFilesPath = resolveFrom(projectRoot, 'expo-asset/tools/hashAssetFiles');\n } catch {\n // TODO: we should warn/throw an error if the user has expo-updates installed but does not\n // have hashAssetFiles available, or if the user is in managed workflow and does not have\n // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,\n // it is not needed\n }\n\n if (hashAssetFilesPath) {\n assetPlugins.push(hashAssetFilesPath);\n }\n\n return assetPlugins;\n}\n\nlet hasWarnedAboutExotic = false;\n\nexport function getDefaultConfig(\n projectRoot: string,\n options: DefaultConfigOptions = {}\n): MetroConfig.InputConfigT {\n const isExotic = options.mode === 'exotic' || EXPO_USE_EXOTIC;\n\n if (isExotic && !hasWarnedAboutExotic) {\n hasWarnedAboutExotic = true;\n console.log(\n chalk.gray(\n `\\u203A Unstable feature ${chalk.bold`EXPO_USE_EXOTIC`} is enabled. Bundling may not work as expected, and is subject to breaking changes.`\n )\n );\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n\n const reactNativePath = path.dirname(resolveFrom(projectRoot, 'react-native/package.json'));\n\n try {\n // Set the `EXPO_METRO_CACHE_KEY_VERSION` variable for use in the custom babel transformer.\n // This hack is used because there doesn't appear to be anyway to resolve\n // `babel-preset-fbjs` relative to the project root later (in `metro-expo-babel-transformer`).\n const babelPresetFbjsPath = resolveFrom(projectRoot, 'babel-preset-fbjs/package.json');\n process.env.EXPO_METRO_CACHE_KEY_VERSION = String(require(babelPresetFbjsPath).version);\n } catch {\n // noop -- falls back to a hardcoded value.\n }\n\n const isLegacy = readIsLegacyImportsEnabled(projectRoot);\n // Deprecated -- SDK 41 --\n if (options.target) {\n if (!isLegacy) {\n console.warn(\n chalk.yellow(\n `The target option is deprecated. Learn more: http://expo.fyi/expo-extension-migration`\n )\n );\n delete options.target;\n }\n } else if (process.env.EXPO_TARGET) {\n console.error(\n 'EXPO_TARGET is deprecated. Learn more: http://expo.fyi/expo-extension-migration'\n );\n if (isLegacy) {\n // EXPO_TARGET is used by @expo/metro-config to determine the target when getDefaultConfig is\n // called from metro.config.js.\n // @ts-ignore\n options.target = process.env.EXPO_TARGET;\n }\n } else if (isLegacy) {\n // Fall back to guessing based on the project structure in legacy mode.\n options.target = getDefaultTarget(projectRoot);\n }\n\n if (!options.target) {\n // Default to bare -- no .expo extension.\n options.target = 'bare';\n }\n // End deprecated -- SDK 41 --\n\n const { target } = options;\n if (!(target === 'managed' || target === 'bare')) {\n throw new Error(\n `Invalid target: '${target}'. Debug info: \\n${JSON.stringify(\n {\n 'options.target': options.target,\n default: getDefaultTarget(projectRoot),\n },\n null,\n 2\n )}`\n );\n }\n const sourceExtsConfig = { isTS: true, isReact: true, isModern: false };\n const sourceExts =\n target === 'bare'\n ? getBareExtensions([], sourceExtsConfig)\n : getManagedExtensions([], sourceExtsConfig);\n\n if (isExotic) {\n // Add support for cjs (without platform extensions).\n sourceExts.push('cjs');\n }\n\n const babelConfigPath = getProjectBabelConfigFile(projectRoot);\n const isCustomBabelConfigDefined = !!babelConfigPath;\n\n const resolverMainFields: string[] = [];\n\n // Disable `react-native` in exotic mode, since library authors\n // use it to ship raw application code to the project.\n if (!isExotic) {\n resolverMainFields.push('react-native');\n }\n resolverMainFields.push('browser', 'main');\n\n const watchFolders = getWatchFolders(projectRoot);\n // TODO: nodeModulesPaths does not work with the new Node.js package.json exports API, this causes packages like uuid to fail. Disabling for now.\n const nodeModulesPaths = getModulesPaths(projectRoot);\n if (EXPO_DEBUG) {\n console.log();\n console.log(`Expo Metro config:`);\n try {\n console.log(`- Version: ${require('../package.json').version}`);\n } catch {}\n console.log(`- Bundler target: ${target}`);\n console.log(`- Legacy: ${isLegacy}`);\n console.log(`- Extensions: ${sourceExts.join(', ')}`);\n console.log(`- React Native: ${reactNativePath}`);\n console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);\n console.log(`- Resolver Fields: ${resolverMainFields.join(', ')}`);\n console.log(`- Watch Folders: ${watchFolders.join(', ')}`);\n console.log(`- Node Module Paths: ${nodeModulesPaths.join(', ')}`);\n console.log(`- Exotic: ${isExotic}`);\n console.log();\n }\n const {\n // Remove the default reporter which metro always resolves to be the react-native-community/cli reporter.\n // This prints a giant React logo which is less accessible to users on smaller terminals.\n reporter,\n ...metroDefaultValues\n } = MetroConfig.getDefaultConfig.getDefaultValues(projectRoot);\n\n // Merge in the default config from Metro here, even though loadConfig uses it as defaults.\n // This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.\n return MetroConfig.mergeConfig(metroDefaultValues, {\n watchFolders,\n resolver: {\n resolverMainFields,\n platforms: ['ios', 'android', 'native'],\n sourceExts,\n nodeModulesPaths,\n },\n serializer: {\n getModulesRunBeforeMainModule: () => [\n require.resolve(path.join(reactNativePath, 'Libraries/Core/InitializeCore')),\n // TODO: Bacon: load Expo side-effects\n ],\n getPolyfills: () => require(path.join(reactNativePath, 'rn-get-polyfills'))(),\n },\n server: {\n port: Number(process.env.RCT_METRO_PORT) || 8081,\n },\n symbolicator: {\n customizeFrame: frame => {\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n },\n },\n transformer: {\n allowOptionalDependencies: true,\n babelTransformerPath: isExotic\n ? require.resolve('./transformer/metro-expo-exotic-babel-transformer')\n : isCustomBabelConfigDefined\n ? // If the user defined a babel config file in their project,\n // then use the default transformer.\n // Try to use the project copy before falling back on the global version\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer')\n : // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.\n require.resolve('./transformer/metro-expo-babel-transformer'),\n assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',\n assetPlugins: getAssetPlugins(projectRoot),\n },\n });\n}\n\nexport interface LoadOptions {\n config?: string;\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n target?: ProjectTarget;\n}\n\nexport async function loadAsync(\n projectRoot: string,\n { reporter, target, ...metroOptions }: LoadOptions = {}\n): Promise<MetroConfig.ConfigT> {\n let defaultConfig = getDefaultConfig(projectRoot, { target });\n if (reporter) {\n defaultConfig = { ...defaultConfig, reporter };\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n return await MetroConfig.loadConfig(\n { cwd: projectRoot, projectRoot, ...metroOptions },\n defaultConfig\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function getModulesPaths(projectRoot: string): string[];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getModulesPaths = void 0;
7
+ const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
8
+ const path_1 = __importDefault(require("path"));
9
+ function getModulesPaths(projectRoot) {
10
+ const paths = [];
11
+ // Only add the project root if it's not the current working directory
12
+ // this minimizes the chance of Metro resolver breaking on new Node.js versions.
13
+ const workspaceRoot = find_yarn_workspace_root_1.default(path_1.default.resolve(projectRoot)); // Absolute path or null
14
+ if (workspaceRoot) {
15
+ paths.push(path_1.default.resolve(projectRoot));
16
+ paths.push(path_1.default.resolve(workspaceRoot, 'node_modules'));
17
+ }
18
+ return paths;
19
+ }
20
+ exports.getModulesPaths = getModulesPaths;
21
+ //# sourceMappingURL=getModulesPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getModulesPaths.js","sourceRoot":"","sources":["../src/getModulesPaths.ts"],"names":[],"mappings":";;;;;;AAAA,wFAAyD;AACzD,gDAAwB;AAExB,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,sEAAsE;IACtE,gFAAgF;IAChF,MAAM,aAAa,GAAG,kCAAiB,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,wBAAwB;IAC5F,IAAI,aAAa,EAAE;QACjB,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;KACzD;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAZD,0CAYC","sourcesContent":["import findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\n\nexport function getModulesPaths(projectRoot: string): string[] {\n const paths: string[] = [];\n\n // Only add the project root if it's not the current working directory\n // this minimizes the chance of Metro resolver breaking on new Node.js versions.\n const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot)); // Absolute path or null\n if (workspaceRoot) {\n paths.push(path.resolve(projectRoot));\n paths.push(path.resolve(workspaceRoot, 'node_modules'));\n }\n\n return paths;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @param workspaceProjectRoot Root file path for the yarn workspace
3
+ * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`
4
+ * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`
5
+ */
6
+ export declare function globAllPackageJsonPaths(workspaceProjectRoot: string, linkedPackages: string[]): string[];
7
+ /**
8
+ * @param workspaceProjectRoot root file path for a yarn workspace.
9
+ * @returns list of package.json file paths that are linked to the yarn workspace.
10
+ */
11
+ export declare function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot: string): string[];
12
+ /**
13
+ * @param projectRoot file path to app's project root
14
+ * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`
15
+ */
16
+ export declare function getWatchFolders(projectRoot: string): string[];
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWatchFolders = exports.resolveAllWorkspacePackageJsonPaths = exports.globAllPackageJsonPaths = void 0;
7
+ const json_file_1 = __importDefault(require("@expo/json-file"));
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
10
+ const glob_1 = require("glob");
11
+ const path_1 = __importDefault(require("path"));
12
+ /**
13
+ * @param workspaceProjectRoot Root file path for the yarn workspace
14
+ * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`
15
+ * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`
16
+ */
17
+ function globAllPackageJsonPaths(workspaceProjectRoot, linkedPackages) {
18
+ return linkedPackages
19
+ .map(glob => {
20
+ return glob_1.sync(path_1.default.join(glob, 'package.json').replace(/\\/g, '/'), {
21
+ cwd: workspaceProjectRoot,
22
+ absolute: true,
23
+ ignore: ['**/@(Carthage|Pods|node_modules)/**'],
24
+ }).map(pkgPath => {
25
+ try {
26
+ json_file_1.default.read(pkgPath);
27
+ return pkgPath;
28
+ }
29
+ catch {
30
+ // Skip adding path if the package.json is invalid or cannot be read.
31
+ }
32
+ return null;
33
+ });
34
+ })
35
+ .flat()
36
+ .filter(Boolean)
37
+ .map(p => path_1.default.join(p));
38
+ }
39
+ exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
40
+ function getWorkspacePackagesArray({ workspaces }) {
41
+ if (Array.isArray(workspaces)) {
42
+ return workspaces;
43
+ }
44
+ assert_1.default(workspaces === null || workspaces === void 0 ? void 0 : workspaces.packages, 'Could not find a `workspaces` object in the root package.json');
45
+ return workspaces.packages;
46
+ }
47
+ /**
48
+ * @param workspaceProjectRoot root file path for a yarn workspace.
49
+ * @returns list of package.json file paths that are linked to the yarn workspace.
50
+ */
51
+ function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot) {
52
+ try {
53
+ const rootPackageJsonFilePath = path_1.default.join(workspaceProjectRoot, 'package.json');
54
+ // Could throw if package.json is invalid.
55
+ const rootPackageJson = json_file_1.default.read(rootPackageJsonFilePath);
56
+ // Extract the "packages" array or use "workspaces" as packages array (yarn workspaces spec).
57
+ const packages = getWorkspacePackagesArray(rootPackageJson);
58
+ // Glob all package.json files and return valid paths.
59
+ return globAllPackageJsonPaths(workspaceProjectRoot, packages);
60
+ }
61
+ catch {
62
+ return [];
63
+ }
64
+ }
65
+ exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
66
+ /**
67
+ * @param projectRoot file path to app's project root
68
+ * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`
69
+ */
70
+ function getWatchFolders(projectRoot) {
71
+ const workspaceRoot = find_yarn_workspace_root_1.default(path_1.default.resolve(projectRoot));
72
+ // Rely on default behavior in standard projects.
73
+ if (!workspaceRoot) {
74
+ return [];
75
+ }
76
+ const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);
77
+ if (!packages.length) {
78
+ return [];
79
+ }
80
+ return uniqueItems([
81
+ path_1.default.join(workspaceRoot, 'node_modules'),
82
+ ...packages.map(pkg => path_1.default.dirname(pkg)),
83
+ ]);
84
+ }
85
+ exports.getWatchFolders = getWatchFolders;
86
+ function uniqueItems(items) {
87
+ return [...new Set(items)];
88
+ }
89
+ //# sourceMappingURL=getWatchFolders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWatchFolders.js","sourceRoot":"","sources":["../src/getWatchFolders.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAuC;AACvC,oDAA4B;AAC5B,wFAAyD;AACzD,+BAAwC;AACxC,gDAAwB;AAExB;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,oBAA4B,EAC5B,cAAwB;IAExB,OAAO,cAAc;SAClB,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,OAAO,WAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YACnE,GAAG,EAAE,oBAAoB;YACzB,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,qCAAqC,CAAC;SAChD,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACf,IAAI;gBACF,mBAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvB,OAAO,OAAO,CAAC;aAChB;YAAC,MAAM;gBACN,qEAAqE;aACtE;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;SACD,IAAI,EAAE;SACN,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,CAAW,CAAC,CAAC,CAAC;AACtC,CAAC;AAvBD,0DAuBC;AAED,SAAS,yBAAyB,CAAC,EAAE,UAAU,EAAO;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,UAAU,CAAC;KACnB;IAED,gBAAM,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,EAAE,+DAA+D,CAAC,CAAC;IAE9F,OAAO,UAAU,CAAC,QAAQ,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CAAC,oBAA4B;IAC9E,IAAI;QACF,MAAM,uBAAuB,GAAG,cAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC;QAChF,0CAA0C;QAC1C,MAAM,eAAe,GAAG,mBAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAE/D,6FAA6F;QAC7F,MAAM,QAAQ,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAE5D,sDAAsD;QACtD,OAAO,uBAAuB,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;KAChE;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAdD,kFAcC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,aAAa,GAAG,kCAAiB,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnE,iDAAiD;IACjD,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,QAAQ,GAAG,mCAAmC,CAAC,aAAa,CAAC,CAAC;IACpE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,WAAW,CAAC;QACjB,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;QACxC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC;AAhBD,0CAgBC;AAED,SAAS,WAAW,CAAC,KAAe;IAClC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import JsonFile from '@expo/json-file';\nimport assert from 'assert';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\n/**\n * @param workspaceProjectRoot Root file path for the yarn workspace\n * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`\n * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`\n */\nexport function globAllPackageJsonPaths(\n workspaceProjectRoot: string,\n linkedPackages: string[]\n): string[] {\n return linkedPackages\n .map(glob => {\n return globSync(path.join(glob, 'package.json').replace(/\\\\/g, '/'), {\n cwd: workspaceProjectRoot,\n absolute: true,\n ignore: ['**/@(Carthage|Pods|node_modules)/**'],\n }).map(pkgPath => {\n try {\n JsonFile.read(pkgPath);\n return pkgPath;\n } catch {\n // Skip adding path if the package.json is invalid or cannot be read.\n }\n return null;\n });\n })\n .flat()\n .filter(Boolean)\n .map(p => path.join(p as string));\n}\n\nfunction getWorkspacePackagesArray({ workspaces }: any): string[] {\n if (Array.isArray(workspaces)) {\n return workspaces;\n }\n\n assert(workspaces?.packages, 'Could not find a `workspaces` object in the root package.json');\n\n return workspaces.packages;\n}\n\n/**\n * @param workspaceProjectRoot root file path for a yarn workspace.\n * @returns list of package.json file paths that are linked to the yarn workspace.\n */\nexport function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot: string) {\n try {\n const rootPackageJsonFilePath = path.join(workspaceProjectRoot, 'package.json');\n // Could throw if package.json is invalid.\n const rootPackageJson = JsonFile.read(rootPackageJsonFilePath);\n\n // Extract the \"packages\" array or use \"workspaces\" as packages array (yarn workspaces spec).\n const packages = getWorkspacePackagesArray(rootPackageJson);\n\n // Glob all package.json files and return valid paths.\n return globAllPackageJsonPaths(workspaceProjectRoot, packages);\n } catch {\n return [];\n }\n}\n\n/**\n * @param projectRoot file path to app's project root\n * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`\n */\nexport function getWatchFolders(projectRoot: string): string[] {\n const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot));\n // Rely on default behavior in standard projects.\n if (!workspaceRoot) {\n return [];\n }\n\n const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);\n if (!packages.length) {\n return [];\n }\n\n return uniqueItems([\n path.join(workspaceRoot, 'node_modules'),\n ...packages.map(pkg => path.dirname(pkg)),\n ]);\n}\n\nfunction uniqueItems(items: string[]): string[] {\n return [...new Set(items)];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/metro-config",
3
- "version": "0.2.8",
3
+ "version": "0.3.3",
4
4
  "description": "A Metro config for running React Native projects with the Metro bundler",
5
5
  "main": "build/ExpoMetroConfig.js",
6
6
  "scripts": {
@@ -28,25 +28,27 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/expo/expo-cli/issues"
30
30
  },
31
- "homepage": "https://github.com/expo/expo-cli/tree/master/packages/metro-config#readme",
31
+ "homepage": "https://github.com/expo/expo-cli/tree/main/packages/metro-config#readme",
32
32
  "files": [
33
33
  "build",
34
34
  "transformer"
35
35
  ],
36
36
  "dependencies": {
37
- "@expo/config": "6.0.6",
37
+ "@expo/config": "6.0.10",
38
+ "@expo/json-file": "8.2.34",
38
39
  "chalk": "^4.1.0",
39
40
  "debug": "^4.3.2",
41
+ "find-yarn-workspace-root": "~2.0.0",
40
42
  "getenv": "^1.0.0",
41
43
  "sucrase": "^3.20.0"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@babel/core": "^7.15.5",
45
- "expo": "37",
46
- "metro": "^0.59.0",
47
- "metro-babel-transformer": "^0.66.2",
48
- "metro-config": "^0.59.0",
49
- "react-native": "~0.63.4"
47
+ "expo": "43",
48
+ "metro": "~0.64.0",
49
+ "metro-babel-transformer": "~0.64.0",
50
+ "metro-config": "~0.64.0",
51
+ "react-native": "~0.64.3"
50
52
  },
51
53
  "publishConfig": {
52
54
  "access": "public"