-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
3,149 additions
and
11,048 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# TODO(dependencies): Remove this and properly deal with all peerDeps | ||
# https://github.com/FormidableLabs/victory/issues/2236 | ||
strict-peer-dependencies=false | ||
auto-install-peers=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,20 @@ | ||
// https://docs.expo.dev/guides/monorepos/#modify-the-metro-config | ||
const { getDefaultConfig } = require("expo/metro-config"); | ||
const path = require("path"); | ||
const {getDefaultConfig} = require("expo/metro-config"); | ||
const blacklist = require("metro-config/src/defaults/exclusionList"); | ||
const escape = require("escape-string-regexp"); | ||
const glob = require('glob'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* Metro does not support symlinks. When resolving dependencies, we need to make | ||
* sure Metro is looking for dependencies _here_ and not in the package repos' | ||
* node_modules folders (which will contain pnpm symlinks) | ||
* | ||
* We generate a list of all deps used in victory packages, and use that below. | ||
*/ | ||
const PKGS = path.resolve(__dirname, "../../packages") | ||
const VICTORY_DEPS = Array.from( | ||
glob.sync(path.join(PKGS, "victory*/package.json")) | ||
.map(p => JSON.parse(fs.readFileSync(p, 'utf8'))) | ||
.map(pkg => Object.keys(pkg.dependencies || {})) | ||
.reduce((set, depNames) => { | ||
depNames.forEach(name => set.add(name)); | ||
return set; | ||
}, new Set()) | ||
); | ||
// Find the project and workspace directories | ||
const projectRoot = __dirname; | ||
// Find the monorepo root | ||
const monorepoRoot = path.resolve(projectRoot, "../.."); | ||
|
||
/** | ||
* Reference to root of monorepo | ||
*/ | ||
const root = path.resolve(__dirname, "../.."); | ||
const config = getDefaultConfig(projectRoot); | ||
|
||
/** | ||
* We're going to extend default expo config | ||
*/ | ||
const defaultConfig = getDefaultConfig(__dirname); | ||
// 1. Watch all files within the monorepo | ||
config.watchFolders = [monorepoRoot]; | ||
// 2. Let Metro know where to resolve packages and in what order | ||
config.resolver.nodeModulesPaths = [ | ||
path.resolve(projectRoot, "node_modules"), | ||
path.resolve(monorepoRoot, "node_modules"), | ||
]; | ||
|
||
/** | ||
* Along with our standard app directory, we're also going to watch the root! | ||
* This allows us to make changes to the victory packages and get live refresh here. | ||
*/ | ||
defaultConfig.watchFolders = [root]; | ||
|
||
/** | ||
* Misc transform options. | ||
*/ | ||
defaultConfig.transformer.getTransformOptions = async () => ({ | ||
transform: { | ||
experimentalImportSupport: false, | ||
inlineRequires: true, | ||
}, | ||
}); | ||
|
||
/** | ||
* Ensuring we only use one version of some shared deps, like React. | ||
* Using multiple versions of React causes errors. | ||
* We want to ignore root/package-level instances, and only use the local ones here. | ||
*/ | ||
const modules = ["react", "react-native-svg", ...VICTORY_DEPS]; | ||
defaultConfig.resolver.blacklistRE = blacklist( | ||
modules.map( | ||
(m) => new RegExp(`^${escape(path.join(root, "node_modules", m))}\\/.*$`), | ||
), | ||
); | ||
defaultConfig.resolver.extraNodeModules = modules.reduce((acc, name) => { | ||
acc[name] = path.join(__dirname, "node_modules", name); | ||
return acc; | ||
}, {}); | ||
|
||
module.exports = defaultConfig; | ||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.