Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react-native): upgrade metro to 0.71.0 #10598

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/generated/packages/react-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": [],
Expand Down Expand Up @@ -474,6 +479,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": ["name"],
Expand Down
12 changes: 9 additions & 3 deletions e2e/react-native/src/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ describe('react native', () => {
const libName = uniq('lib');
const componentName = uniq('component');

runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
runCLI(`generate @nrwl/react-native:library ${libName}`);
runCLI(
`generate @nrwl/react-native:component ${componentName} --project=${libName} --export`
Expand Down Expand Up @@ -59,7 +61,9 @@ describe('react native', () => {

it('should create storybook with application', async () => {
const appName = uniq('my-app');
runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
runCLI(
`generate @nrwl/react-native:storybook-configuration ${appName} --generateStories --no-interactive`
);
Expand All @@ -86,7 +90,9 @@ describe('react native', () => {

it('sync npm dependencies for autolink', async () => {
const appName = uniq('my-app');
runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
// Add npm package with native modules
updateFile(join('package.json'), (content) => {
const json = JSON.parse(content);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"license-webpack-plugin": "^4.0.2",
"loader-utils": "1.2.3",
"memfs": "^3.0.1",
"metro-resolver": "^0.70.3",
"metro-resolver": "^0.71.0",
"mime": "2.4.4",
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "3.0.5",
Expand Down
9 changes: 9 additions & 0 deletions packages/detox/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
"alwaysAddToPackageJson": false
}
}
},
"14.2.1": {
"version": "14.2.1-beta.0",
"packages": {
"detox": {
"version": "19.7.1",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"chalk": "^4.1.0"
},
"peerDependencies": {
"detox": "^19.6.9"
"detox": "^19.7.1"
},
"builders": "./executors.json",
"ng-update": {
Expand Down
2 changes: 1 addition & 1 deletion packages/detox/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const nxVersion = require('../../package.json').version;

export const detoxVersion = '19.6.9';
export const detoxVersion = '19.7.1';
export const testingLibraryJestDom = '5.16.4';
37 changes: 37 additions & 0 deletions packages/react-native/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,43 @@
"alwaysAddToPackageJson": false
}
}
},
"14.2.1": {
"version": "14.2.1-beta.0",
"packages": {
"metro": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-resolver": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-babel-register": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-config": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-react-native-babel-preset": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"@testing-library/jest-native": {
"version": "4.0.5",
"alwaysAddToPackageJson": false
},
"@babel/runtime": {
"version": "7.18.3",
"alwaysAddToPackageJson": false
},
"@types/react-native": {
"version": "0.67.8",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"enhanced-resolve": "^5.8.3",
"fs-extra": "^10.1.0",
"ignore": "^5.0.4",
"metro-resolver": "^0.70.3",
"metro-resolver": "^0.71.0",
"node-fetch": "^2.6.7",
"tsconfig-paths": "^3.9.0"
},
Expand Down
16 changes: 6 additions & 10 deletions packages/react-native/plugins/metro-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ export function getResolveRequest(extensions: string[]) {
return function (
_context: any,
realModuleName: string,
platform: string | null,
moduleName: string
platform: string | null
) {
const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';

if (DEBUG) console.log(chalk.cyan(`[Nx] Resolving: ${moduleName}`));
if (DEBUG) console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));

const { resolveRequest, ...context } = _context;

Expand All @@ -32,15 +31,14 @@ export function getResolveRequest(extensions: string[]) {
context,
extensions,
realModuleName,
moduleName,
platform,
DEBUG
) ||
pnpmResolver(extensions, context, realModuleName, moduleName, DEBUG);
pnpmResolver(extensions, context, realModuleName, DEBUG);
if (resolvedPath) {
return resolvedPath;
}
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
};
}

Expand Down Expand Up @@ -75,7 +73,6 @@ function pnpmResolver(
extensions: string[],
context: any,
realModuleName: string,
moduleName: string,
debug: boolean
) {
try {
Expand All @@ -93,7 +90,7 @@ function pnpmResolver(
if (debug)
console.log(
chalk.cyan(
`[Nx] Unable to resolve with default PNPM resolver: ${moduleName}`
`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`
)
);
}
Expand All @@ -107,7 +104,6 @@ function tsconfigPathsResolver(
context: any,
extensions: string[],
realModuleName: string,
moduleName: string,
platform: string,
debug: boolean
) {
Expand All @@ -124,7 +120,7 @@ function tsconfigPathsResolver(
} else {
if (debug) {
console.log(
chalk.red(`[Nx] Failed to resolve ${chalk.bold(moduleName)}`)
chalk.red(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`)
);
console.log(
chalk.cyan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('app', () => {
displayName: 'myApp',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
});
const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
Expand All @@ -37,6 +38,7 @@ describe('app', () => {
tags: 'one,two',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
});

const { projects } = readJson(appTree, '/workspace.json');
Expand All @@ -53,6 +55,7 @@ describe('app', () => {
displayName: 'myApp',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
});
expect(appTree.exists('apps/my-app/src/app/App.tsx')).toBeTruthy();
expect(appTree.exists('apps/my-app/src/main.tsx')).toBeTruthy();
Expand All @@ -71,6 +74,7 @@ describe('app', () => {
displayName: 'myApp',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
});

const tsconfig = readJson(appTree, 'apps/my-app/tsconfig.json');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export async function reactNativeApplicationGenerator(
);
const detoxTask = await addDetox(host, options);
const symlinkTask = runSymlink(host.root, options.appProjectRoot);
const podInstallTask = runPodInstall(join(host.root, options.iosProjectRoot));
const podInstallTask = runPodInstall(
join(host.root, options.iosProjectRoot),
options.install
);
const chmodTaskGradlew = runChmod(
join(host.root, options.androidProjectRoot, 'gradlew'),
0o775
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('Normalize Options', () => {
name: 'my-app',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
Expand All @@ -24,13 +25,15 @@ describe('Normalize Options', () => {
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});

it('should normalize options with name in camel case', () => {
const schema: Schema = {
name: 'myApp',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
Expand All @@ -46,6 +49,7 @@ describe('Normalize Options', () => {
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});

Expand All @@ -54,6 +58,7 @@ describe('Normalize Options', () => {
name: 'my-app',
directory: 'directory',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
Expand All @@ -70,13 +75,15 @@ describe('Normalize Options', () => {
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});

it('should normalize options that has directory in its name', () => {
const schema: Schema = {
name: 'directory/my-app',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
Expand All @@ -92,6 +99,7 @@ describe('Normalize Options', () => {
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});

Expand All @@ -100,6 +108,7 @@ describe('Normalize Options', () => {
name: 'my-app',
displayName: 'My App',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
Expand All @@ -115,6 +124,7 @@ describe('Normalize Options', () => {
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export interface Schema {
linter?: Linter;
setParserOptionsProject?: boolean;
e2eTestRunner?: 'detox' | 'none';
install: boolean; // default is true
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": []
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-ser
import { jestInitGenerator } from '@nrwl/jest';
import { detoxInitGenerator } from '@nrwl/detox';
import {
reactTestRendererVersion,
reactVersion,
typesReactVersion,
} from '@nrwl/react/src/utils/versions';
Expand All @@ -28,7 +29,6 @@ import {
reactNativeSvgTransformerVersion,
reactNativeSvgVersion,
reactNativeVersion,
reactTestRendererVersion,
testingLibraryJestNativeVersion,
testingLibraryReactNativeVersion,
typesNodeVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export async function createTestUIApp(libName: string): Promise<Tree> {
style: 'css',
unitTestRunner: 'none',
name: libName,
install: false,
});
return appTree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export async function createTestUILib(libName: string): Promise<Tree> {
skipFormat: false,
unitTestRunner: 'none',
name: `${libName}-e2e`,
install: false,
});
return appTree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export async function createTestAppLib(
unitTestRunner: 'none',
name: libName,
js: plainJS,
install: false,
});

await componentGenerator(appTree, {
Expand Down