Skip to content

Commit

Permalink
bugfix(react-native): watch entire workspace (nrwl#19432)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi authored Oct 4, 2023
1 parent 2d12daf commit e5654c8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 38 deletions.
19 changes: 9 additions & 10 deletions packages/expo/plugins/metro-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,16 @@ function tsconfigPathsResolver(
platform: string,
debug: boolean
) {
const tsConfigPathMatcher = getMatcher(debug);
const match = tsConfigPathMatcher(
realModuleName,
undefined,
undefined,
extensions.map((ext) => `.${ext}`)
);

if (match) {
try {
const tsConfigPathMatcher = getMatcher(debug);
const match = tsConfigPathMatcher(
realModuleName,
undefined,
undefined,
extensions.map((ext) => `.${ext}`)
);
return metroResolver.resolve(context, match, platform);
} else {
} catch {
if (debug) {
console.log(
chalk.red(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`)
Expand Down
10 changes: 2 additions & 8 deletions packages/expo/plugins/with-nx-metro.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { workspaceLayout, workspaceRoot } from '@nx/devkit';
import { workspaceRoot } from '@nx/devkit';
import { mergeConfig } from 'metro-config';
import type { MetroConfig } from 'metro-config';
import { join } from 'path';
import { existsSync } from 'fs-extra';

import { getResolveRequest } from './metro-resolver';
Expand All @@ -24,12 +23,7 @@ export async function withNxMetro(
if (opts.debug) process.env.NX_REACT_NATIVE_DEBUG = 'true';
if (opts.extensions) extensions.push(...opts.extensions);

let watchFolders = [
join(workspaceRoot, 'node_modules'),
join(workspaceRoot, workspaceLayout().libsDir),
join(workspaceRoot, 'packages'),
join(workspaceRoot, '.storybook'),
];
let watchFolders = [workspaceRoot];
if (opts.watchFolders?.length) {
watchFolders = watchFolders.concat(opts.watchFolders);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const customConfig = {
sourceExts: [...sourceExts, 'svg'],
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
unstable_enableSymlinks: true,
unstable_enablePackageExports: true,
// unstable_enablePackageExports: true,
},
};

Expand Down
19 changes: 9 additions & 10 deletions packages/react-native/plugins/metro-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,16 @@ function tsconfigPathsResolver(
platform: string,
debug: boolean
) {
const tsConfigPathMatcher = getMatcher(debug);
const match = tsConfigPathMatcher(
realModuleName,
undefined,
undefined,
extensions.map((ext) => `.${ext}`)
);

if (match) {
try {
const tsConfigPathMatcher = getMatcher(debug);
const match = tsConfigPathMatcher(
realModuleName,
undefined,
undefined,
extensions.map((ext) => `.${ext}`)
);
return metroResolver.resolve(context, match, platform);
} else {
} catch {
if (debug) {
console.log(
chalk.red(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`)
Expand Down
10 changes: 2 additions & 8 deletions packages/react-native/plugins/with-nx-metro.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { workspaceLayout, workspaceRoot } from '@nx/devkit';
import { workspaceRoot } from '@nx/devkit';
import { mergeConfig } from 'metro-config';
import type { MetroConfig } from 'metro-config';
import { join } from 'path';
import { existsSync } from 'fs-extra';

import { getResolveRequest } from './metro-resolver';
Expand All @@ -24,12 +23,7 @@ export async function withNxMetro(
if (opts.debug) process.env.NX_REACT_NATIVE_DEBUG = 'true';
if (opts.extensions) extensions.push(...opts.extensions);

let watchFolders = [
join(workspaceRoot, 'node_modules'),
join(workspaceRoot, workspaceLayout().libsDir),
join(workspaceRoot, 'packages'),
join(workspaceRoot, '.storybook'),
];
let watchFolders = [workspaceRoot];
if (opts.watchFolders?.length) {
watchFolders = watchFolders.concat(opts.watchFolders);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const customConfig = {
sourceExts: [...sourceExts, 'svg'],
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
unstable_enableSymlinks: true,
unstable_enablePackageExports: true,
// unstable_enablePackageExports: true,
},
};

Expand Down

0 comments on commit e5654c8

Please sign in to comment.