nx/packages/expo/plugins/with-nx-metro.ts
Emily Xiong a411e85e42
Feature/move expo (#11712)
* feat(expo): move expo to main repo

* feat(expo): add e2e expo tests and fix expo unit tests

* feat(expo): add generated docs

* feat(expo): update cz-config to add expo to commit message

* feat(expo): add @nrwl/expo to e2e test setup

* feat(expo): add expo to preset

* feat(expo): add detox tests

* feat(expo): update docs

* feat(expo): fix e2e tests

* feat(expo): upgrade expo to 46.0.10

* fix(expo): correct eas-cli build:info parameters names

* fix(expo): add cleanupProject to e2e test
2022-09-16 11:56:28 -04:00

41 lines
1.2 KiB
TypeScript

import { workspaceLayout, workspaceRoot } from '@nrwl/devkit';
import { join } from 'path';
import { existsSync } from 'fs-extra';
import { getResolveRequest } from './metro-resolver';
interface WithNxOptions {
debug?: boolean;
extensions?: string[];
projectRoot?: string;
watchFolders?: string[];
}
export function withNxMetro(config: any, opts: WithNxOptions = {}) {
const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
if (opts.debug) process.env.NX_REACT_NATIVE_DEBUG = 'true';
if (opts.extensions) extensions.push(...opts.extensions);
config.projectRoot = opts.projectRoot || workspaceRoot;
// Add support for paths specified by tsconfig
config.resolver = {
...config.resolver,
resolveRequest: getResolveRequest(extensions),
};
let watchFolders = config.watchFolders || [];
watchFolders = watchFolders.concat([
join(workspaceRoot, 'node_modules'),
join(workspaceRoot, workspaceLayout().libsDir),
]);
if (opts.watchFolders?.length) {
watchFolders = watchFolders.concat(opts.watchFolders);
}
watchFolders = watchFolders.filter((folder) => existsSync(folder));
config.watchFolders = watchFolders;
return config;
}