Skip to content

Commit

Permalink
Update React Native minimum version supported, fix test app autolinki…
Browse files Browse the repository at this point in the history
…ng (#235)

* Update minimum

* Remove extra package.json

* Update react-native.config.js

Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>

* Update react-native.config.js

Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>

* Fix typo

---------

Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
  • Loading branch information
Saadnajmi and tido64 authored Apr 13, 2024
1 parent 63a0ec0 commit 03ce8c1
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 1,377 deletions.
2 changes: 1 addition & 1 deletion example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Platform,
Image,
} from 'react-native';
import Clipboard, {useClipboard} from '@react-native-clipboard/clipboard';
import Clipboard, {useClipboard} from '../src';

// Small icon of a plus for demo purposes
const TEST_IMAGE =
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ PODS:
- React-Core
- React-jsi
- ReactTestApp-Resources (1.0.0-dev)
- RNCClipboard (1.13.2):
- RNCClipboard (1.14.0):
- React-Core
- SocketRocket (0.6.1)
- Yoga (1.14.0)
Expand Down Expand Up @@ -1082,7 +1082,7 @@ DEPENDENCIES:
- "ReactNativeHost (from `../../node_modules/@rnx-kit/react-native-host`)"
- ReactTestApp-DevSupport (from `../../node_modules/react-native-test-app`)
- ReactTestApp-Resources (from `..`)
- "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)"
- RNCClipboard (from `../..`)
- Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -1190,7 +1190,7 @@ EXTERNAL SOURCES:
ReactTestApp-Resources:
:path: ".."
RNCClipboard:
:path: "../node_modules/@react-native-clipboard/clipboard"
:path: "../.."
Yoga:
:path: "../../node_modules/react-native/ReactCommon/yoga"

Expand Down Expand Up @@ -1245,7 +1245,7 @@ SPEC CHECKSUMS:
ReactNativeHost: 339df34d3c2050f37e8909ade6693465e8a947f7
ReactTestApp-DevSupport: 1fe22a4a29414ec3227d20b3eb96217ba1ff13d0
ReactTestApp-Resources: 857244f3a23f2b3157b364fa06cf3e8866deff9c
RNCClipboard: 60fed4b71560d7bfe40e9d35dea9762b024da86d
RNCClipboard: 090462274cc05b02628bd158baf6d73c3abe8441
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 805bf71192903b20fc14babe48080582fee65a80

Expand Down
11 changes: 0 additions & 11 deletions example/metro.config.js

This file was deleted.

52 changes: 0 additions & 52 deletions example/package.json

This file was deleted.

23 changes: 0 additions & 23 deletions example/react-native.config.js

This file was deleted.

26 changes: 11 additions & 15 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
/**
* Metro configuration for React Native
* /~https://github.com/facebook/react-native
*
* @format
*/
const blacklist = require('metro-config/src/defaults/blacklist');
const path = require('path');
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

module.exports = {
const { makeMetroConfig } = require("@rnx-kit/metro-config");
module.exports = mergeConfig(getDefaultConfig(__dirname), makeMetroConfig({
projectRoot: path.join(__dirname, 'example'),
watchFolders: [__dirname],
resolver: {
blacklistRE: blacklist([
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip
// /~https://github.com/dotnet/msbuild/issues/5383
/.*\.ProjectImports\.zip/,
]),
extraNodeModules: {
'@react-native-clipboard/clipboard': __dirname,
},
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
inlineRequires: false,
},
}),
},
};
}));
19 changes: 0 additions & 19 deletions metro.config.macos.js

This file was deleted.

34 changes: 6 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@callstack/react-native-visionos": "^0.73.0",
"@react-native/babel-preset": "^0.73.0",
"@react-native/eslint-config": "^0.73.0",
"@react-native/metro-config": "^0.73.0",
"@rnx-kit/align-deps": "^2.4.1",
"@rnx-kit/metro-config": "^1.3.15",
"@types/react": "^18.2.0",
"babel-jest": "^26.1.0",
"eslint": "^7.32.0",
Expand All @@ -66,10 +68,10 @@
"typescript": "^4.4.3"
},
"peerDependencies": {
"react": "18.2.0",
"react-native": "^0.73.0",
"react-native-macos": "^0.73.0",
"react-native-windows": "^0.73.0"
"react": "16.9.0 || 16.11.0 || 16.13.1 || 17.0.1 || 17.0.2 || 18.0.0 || 18.1.0 || 18.2.0",
"react-native": "^0.61.5 || ^0.62.3 || ^0.63.2 || ^0.64.2 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0 || ^0.73.0",
"react-native-macos": "^0.61.0 || ^0.62.0 || ^0.63.0 || ^0.64.0 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0 || ^0.73.0",
"react-native-windows": "^0.61.0 || ^0.62.0 || ^0.63.0 || ^0.64.0 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0 || ^0.73.0"
},
"publishConfig": {
"access": "public"
Expand All @@ -82,30 +84,6 @@
"javaPackageName": "com.reactnativecommunity.clipboard"
}
},
"rnx-kit": {
"kitType": "library",
"alignDeps": {
"requirements": {
"development": [
"react-native@0.73"
],
"production": [
"react-native@>=0.73"
]
},
"capabilities": [
"babel-preset-react-native",
"core",
"core-android",
"core-ios",
"core-macos",
"core-windows",
"jest",
"react",
"react-test-renderer"
]
}
},
"packageManager": "yarn@4.1.1",
"workspaces": [
"example"
Expand Down
83 changes: 41 additions & 42 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
/**
* This cli config is needed for the coexistance of react-native and other
* out-of-tree implementations such react-native-macos.
* The following issue is tracked by
* /~https://github.com/react-native-community/discussions-and-proposals/issues/182
*
* The work-around involves having a metro.config.js for each out-of-tree
* platform, i.e. metro.config.js for react-native and
* metro.config.macos.js for react-native-macos.
* This react-native.config.js looks for a --use-react-native-macos
* switch and when present pushes --config=metro.config.macos.js
* and specifies reactNativePath: 'node_modules/react-native-macos'.
* The metro.config.js has to blacklist 'node_modules/react-native-macos',
* and conversely metro.config.macos.js has to blacklist 'node_modules/react-native'.
*/
'use strict';
const project = (() => {
const fs = require('fs');
const path = require('path');
try {
const { configureProjects } = require('react-native-test-app');

const macSwitch = '--use-react-native-macos';
const windowsSwitch = '--use-react-native-windows';
return configureProjects({
android: {
sourceDir: path.join('example', 'android'),
},
ios: {
sourceDir: 'example/ios',
},
windows: {
sourceDir: path.join('example', 'windows'),
solutionFile: path.join('example', 'windows', 'Example.sln'),
},
});
} catch (e) {
return undefined;
}
})();

if (process.argv.includes(macSwitch)) {
process.argv = process.argv.filter((arg) => arg !== macSwitch);
process.argv.push('--config=metro.config.macos.js');
module.exports = {
reactNativePath: 'node_modules/react-native-macos',
};
} else if (process.argv.includes(windowsSwitch)) {
process.argv = process.argv.filter((arg) => arg !== windowsSwitch);
process.argv.push('--config=metro.config.windows.js');
module.exports = {
reactNativePath: 'node_modules/react-native-windows',
};
} else {
module.exports = {
project: {
android: {sourceDir: './example/android'},
ios: {project: './example/ios/example.xcworkspace'},
module.exports = {
dependencies: {
// Help rn-cli find and autolink this library
'@react-native-clipboard/clipboard': {
root: __dirname,
},
},
dependency: {
platforms: {
windows: {
sourceDir: './example/windows',
solutionFile: 'ClipboardExample.sln',
project: {
projectFile: 'ClipboardExample/ClipboardExample.vcxproj',
},
sourceDir: 'windows',
solutionFile: 'windows.sln',
projects: [
{
projectFile: 'Clipboard/Clipboard.vcxproj',
directDependency: true,
},
],
},
},
};
}
},
...(project ? { project } : undefined),
};
Loading

0 comments on commit 03ce8c1

Please sign in to comment.