Skip to content

Commit

Permalink
feat(align-deps): introduce preset with New Arch packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Oct 26, 2022
1 parent 404c2e6 commit a82f4d9
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/shy-lemons-wash.md
@@ -0,0 +1,6 @@
---
"@rnx-kit/align-deps": minor
"@rnx-kit/dep-check-preset-react-native-new-arch": minor
---

A containing only packages that are compatible with New Architecture
47 changes: 47 additions & 0 deletions incubator/dep-check-preset-react-native-new-arch/README.md
@@ -0,0 +1,47 @@
# @rnx-kit/dep-check-preset-react-native-new-arch

[![Build](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml/badge.svg)](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml)
[![npm version](https://img.shields.io/npm/v/@rnx-kit/dep-check-preset-react-native-new-arch)](https://www.npmjs.com/package/@rnx-kit/dep-check-preset-react-native-new-arch)

🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧

### This package is EXPERIMENTAL - USE WITH CAUTION

🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧

A preset for
[`@rnx-kit/dep-check`](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#readme)
containing only packages that are compatible with React Native New Architecture.

## Install

```sh
npm add --save-dev @rnx-kit/dep-check @rnx-kit/dep-check-preset-react-native-new-arch
```

## Usage

Follow the instructions to initialize a new configuration if you haven't
already: https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#usage

Add this package to `customProfiles` in your `package.json`, e.g.:

```diff
{
"rnx-kit": {
"reactNativeVersion": "^0.70",
"reactNativeDevVersion": "^0.70",
"capabilities": [
"core-android",
"core-ios"
],
+ "customProfiles": "@rnx-kit/dep-check-preset-react-native-new-arch"
}
}
```

Finally, run:

```
yarn rnx-dep-check --vigilant 0.70
```
37 changes: 37 additions & 0 deletions incubator/dep-check-preset-react-native-new-arch/package.json
@@ -0,0 +1,37 @@
{
"name": "@rnx-kit/dep-check-preset-react-native-new-arch",
"version": "0.0.1",
"description": "EXPERIMENTAL - USE WITH CAUTION - @rnx-kit/dep-check preset for New Architecture compatible packages",
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/incubator/dep-check-preset-react-native-new-arch#readme",
"license": "MIT",
"author": {
"name": "Microsoft Open Source",
"email": "microsoftopensource@users.noreply.github.com"
},
"files": [
"src/*.js"
],
"main": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rnx-kit",
"directory": "incubator/dep-check-preset-react-native-new-arch"
},
"scripts": {
"build": "rnx-kit-scripts build",
"format": "rnx-kit-scripts format"
},
"devDependencies": {
"@rnx-kit/dep-check": "*",
"@rnx-kit/scripts": "*"
},
"depcheck": {
"ignoreMatches": [
"@rnx-kit/dep-check"
]
},
"eslintConfig": {
"extends": "@rnx-kit/eslint-config"
},
"experimental": true
}
49 changes: 49 additions & 0 deletions incubator/dep-check-preset-react-native-new-arch/src/index.js
@@ -0,0 +1,49 @@
// @ts-check
/** @type {Record<string, import("@rnx-kit/dep-check").Profile>} */
module.exports = {
"0.70": {
animation: {
name: "react-native-reanimated",
version: "^3.0.0-0",
},
base64: null,
checkbox: null,
clipboard: null,
"datetime-picker": null,
filesystem: null,
"floating-action": null,
// gestures: already in the default profile
html: null,
"linear-gradient": {
name: "rnx-gradient",
version: "^0.1.0",
},
"masked-view": null,
modal: null,
"navigation/native": null,
"navigation/stack": null,
netinfo: null,
popover: null,
"safe-area": {
name: "react-native-safe-area-context",
version: "^4.1.2",
},
screens: {
name: "react-native-screens",
version: "^3.12.0",
},
shimmer: null,
slider: {
name: "react-native-slider",
version: "^4.3.0",
},
sqlite: null,
storage: null,
svg: {
name: "react-native-svg",
version: "^13.0.0",
},
// "test-app": already in the default profile,
webview: null,
},
};
@@ -0,0 +1,7 @@
{
"extends": "@rnx-kit/scripts/tsconfig-shared.json",
"compilerOptions": {
"noEmit": true
},
"include": ["src/"]
}
2 changes: 2 additions & 0 deletions packages/align-deps/src/index.ts
@@ -1,6 +1,8 @@
import { preset as communityReactNativeNewArchOnlyPreset } from "./presets/community/react-native-new-arch-only";
import { preset as reactNativePreset } from "./presets/microsoft/react-native";

export const presets = {
"community/react-native-new-arch-only": communityReactNativeNewArchOnlyPreset,
"microsoft/react-native": reactNativePreset,
};

Expand Down
@@ -0,0 +1,11 @@
import type { Preset } from "../../types";
import profile_0_70 from "./react-native-new-arch-only/profile-0.70";

// Also export this by name for scripts to work around a bug where this module
// is wrapped twice, i.e. `{ default: { default: preset } }`, when imported as
// ESM.
export const preset: Readonly<Preset> = {
"0.70": profile_0_70,
};

export default preset;
@@ -0,0 +1,54 @@
import type { Capability } from "@rnx-kit/config";
import type { Profile } from "../../../types";
import profile_0_70 from "../../microsoft/react-native/profile-0.70";

const profile: Profile = {
...profile_0_70,
animation: {
name: "react-native-reanimated",
version: "^3.0.0-0",
},
// gestures: already in the default profile
// @ts-expect-error 'linear-gradient' is not a known capability
"linear-gradient": {
name: "rnx-gradient",
version: "^0.1.0",
},
// safe-area: already in the default profile
// screens: already in the default profile
slider: {
name: "react-native-slider",
version: "^4.3.1",
},
svg: {
name: "react-native-svg",
version: "^13.4.0",
},
// "test-app": already in the default profile,
};

const unsupportedCapabilities: Capability[] = [
"base64",
"checkbox",
"clipboard",
"datetime-picker",
"filesystem",
"floating-action",
"html",
"masked-view",
"modal",
"navigation/native",
"navigation/stack",
"netinfo",
"popover",
"shimmer",
"sqlite",
"storage",
"webview",
];

unsupportedCapabilities.forEach((capability) => {
delete profile[capability];
});

export default profile;

0 comments on commit a82f4d9

Please sign in to comment.