Make it possible to develop without copying library to node_modules (#105)

Inspired by: https://github.com/callstack/react-native-paper/tree/master/example
and https://blog.callstack.io/adding-an-example-app-to-your-react-native-library-d23b9741a19c

cc: @satya164 😻, thanks!
This commit is contained in:
Michał Osadnik
2018-09-25 09:36:41 +02:00
committed by Krzysztof Magiera
parent a92e0c0ef7
commit 7a8885c871
10 changed files with 100 additions and 44 deletions

View File

@@ -1,3 +1,10 @@
{
"presets": ["react-native"]
"presets": ["react-native"],
"plugins": [
["module-resolver", {
"alias": {
"react-native-reanimated": "../src/Animated"
}
}]
]
}

8
Example/README.md Normal file
View File

@@ -0,0 +1,8 @@
## Run the example
+ Clone the repository
+ Run `yarn` to install the dependencies of library
+ `cd` to this directory
+ Run `yarn` to install the dependencies of example
+ Run `yarn start` to start the packager with custom config
+ `react-native run-ios` or `react-native run-android`

View File

@@ -1,6 +1,6 @@
rootProject.name = 'ReanimatedExample'
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../../android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

15
Example/cli.config.js Normal file
View File

@@ -0,0 +1,15 @@
const path = require('path');
const blacklist = require('metro/src/blacklist');
const glob = require('glob-to-regexp');
module.exports = {
getProjectRoots() {
return [__dirname, path.resolve(__dirname, '..')];
},
getProvidesModuleNodeModules() {
return ['react-native', 'react', 'fbjs'];
},
getBlacklistRE() {
return blacklist([glob(`${path.resolve(__dirname, '..')}/node_modules/*`)]);
},
};

View File

@@ -22,7 +22,7 @@
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
4457A80D20AD4C0100014714 /* MBFingerTipWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 4457A80B20AD4C0000014714 /* MBFingerTipWindow.m */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
610E8D981E4F4A1D9F03DA10 /* libRNReanimated.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 44C6D9B44006445CBA2AFA38 /* libRNReanimated.a */; };
66A008A621539E5500FD61E6 /* libRNReanimated.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 66A008A521539E4E00FD61E6 /* libRNReanimated.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
9657E5E7F2E04B0D80391B88 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 21F41B9A86C04760AA74F219 /* libRNGestureHandler.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
@@ -260,13 +260,6 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNGestureHandler;
};
440FECB6209066F700EEC73A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6297965D14D64A3992A67B2D /* RNReanimated.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNReanimated;
};
5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
@@ -281,6 +274,13 @@
remoteGlobalIDString = 2D2A28201D9B03D100D4039D;
remoteInfo = "RCTAnimation-tvOS";
};
66A008A421539E4E00FD61E6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66A008A021539E4D00FD61E6 /* RNReanimated.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNReanimated;
};
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
@@ -330,7 +330,7 @@
4457A80C20AD4C0100014714 /* MBFingerTipWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBFingerTipWindow.h; sourceTree = "<group>"; };
44C6D9B44006445CBA2AFA38 /* libRNReanimated.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNReanimated.a; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
6297965D14D64A3992A67B2D /* RNReanimated.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNReanimated.xcodeproj; path = "../node_modules/react-native-reanimated/ios/RNReanimated.xcodeproj"; sourceTree = "<group>"; };
66A008A021539E4D00FD61E6 /* RNReanimated.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNReanimated.xcodeproj; path = ../../ios/RNReanimated.xcodeproj; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
@@ -355,7 +355,7 @@
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
9657E5E7F2E04B0D80391B88 /* libRNGestureHandler.a in Frameworks */,
610E8D981E4F4A1D9F03DA10 /* libRNReanimated.a in Frameworks */,
66A008A621539E5500FD61E6 /* libRNReanimated.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -505,14 +505,6 @@
name = Products;
sourceTree = "<group>";
};
440FECB3209066F700EEC73A /* Products */ = {
isa = PBXGroup;
children = (
440FECB7209066F700EEC73A /* libRNReanimated.a */,
);
name = Products;
sourceTree = "<group>";
};
5E91572E1DD0AC6500FF2AA8 /* Products */ = {
isa = PBXGroup;
children = (
@@ -522,6 +514,14 @@
name = Products;
sourceTree = "<group>";
};
66A008A121539E4D00FD61E6 /* Products */ = {
isa = PBXGroup;
children = (
66A008A521539E4E00FD61E6 /* libRNReanimated.a */,
);
name = Products;
sourceTree = "<group>";
};
78C398B11ACF4ADC00677621 /* Products */ = {
isa = PBXGroup;
children = (
@@ -534,6 +534,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
66A008A021539E4D00FD61E6 /* RNReanimated.xcodeproj */,
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
@@ -547,7 +548,6 @@
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
2C7D106DBBC949B493C48206 /* RNGestureHandler.xcodeproj */,
6297965D14D64A3992A67B2D /* RNReanimated.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
@@ -693,8 +693,8 @@
ProjectRef = 2C7D106DBBC949B493C48206 /* RNGestureHandler.xcodeproj */;
},
{
ProductGroup = 440FECB3209066F700EEC73A /* Products */;
ProjectRef = 6297965D14D64A3992A67B2D /* RNReanimated.xcodeproj */;
ProductGroup = 66A008A121539E4D00FD61E6 /* Products */;
ProjectRef = 66A008A021539E4D00FD61E6 /* RNReanimated.xcodeproj */;
},
);
projectRoot = "";
@@ -936,13 +936,6 @@
remoteRef = 440FEC7D209066EB00EEC73A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
440FECB7209066F700EEC73A /* libRNReanimated.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNReanimated.a;
remoteRef = 440FECB6209066F700EEC73A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
@@ -957,6 +950,13 @@
remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
66A008A521539E4E00FD61E6 /* libRNReanimated.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNReanimated.a;
remoteRef = 66A008A421539E4E00FD61E6 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;

View File

@@ -3,21 +3,19 @@
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"postinstall":
"rm -rf node_modules/react-native-reanimated/{.git,node_modules,Example}"
"start": "node node_modules/react-native/local-cli/cli.js start --config ../../../../cli.config.js",
"test": "jest"
},
"dependencies": {
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-gesture-handler": "^1.0.5",
"react-native-reanimated": "file:..",
"react-navigation": "^2.6.2"
},
"devDependencies": {
"babel-jest": "23.2.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-preset-react-native": "^5",
"glob-to-regexp": "^0.4.0",
"jest": "23.3.0",
"react-test-renderer": "16.4.1"
},

View File

@@ -867,7 +867,7 @@ babel-helpers@^6.24.1:
babel-runtime "^6.22.0"
babel-template "^6.24.1"
babel-jest@23.2.0, babel-jest@^23.2.0:
babel-jest@^23.2.0:
version "23.2.0"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-23.2.0.tgz#14a9d6a3f4122dfea6069d37085adf26a53a4dba"
dependencies:
@@ -905,6 +905,16 @@ babel-plugin-jest-hoist@^23.2.0:
version "23.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167"
babel-plugin-module-resolver@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-3.1.1.tgz#881cf67e3d4b8400d5eaaefc1be44d2dc1fe404f"
dependencies:
find-babel-config "^1.1.0"
glob "^7.1.2"
pkg-up "^2.0.0"
reselect "^3.0.1"
resolve "^1.4.0"
babel-plugin-syntax-class-properties@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de"
@@ -2096,6 +2106,13 @@ finalhandler@1.1.0:
statuses "~1.3.1"
unpipe "~1.0.0"
find-babel-config@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.1.0.tgz#acc01043a6749fec34429be6b64f542ebb5d6355"
dependencies:
json5 "^0.5.1"
path-exists "^3.0.0"
find-cache-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
@@ -2236,6 +2253,10 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob-to-regexp@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.0.tgz#49bd677b1671022bd10921c3788f23cdebf9c7e6"
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
@@ -3999,6 +4020,12 @@ pkg-dir@^2.0.0:
dependencies:
find-up "^2.1.0"
pkg-up@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
dependencies:
find-up "^2.1.0"
plist@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/plist/-/plist-2.0.1.tgz#0a32ca9481b1c364e92e18dc55c876de9d01da8b"
@@ -4179,9 +4206,6 @@ react-native-gesture-handler@^1.0.5:
invariant "^2.2.2"
prop-types "^15.5.10"
"react-native-reanimated@file:..":
version "1.0.0-alpha.4"
react-native-safe-area-view@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.7.0.tgz#38f5ab9368d6ef9e5d18ab64212938af3ec39421"
@@ -4520,6 +4544,10 @@ require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
reselect@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147"
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@@ -4538,7 +4566,7 @@ resolve@1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
resolve@^1.3.2, resolve@^1.5.0:
resolve@^1.3.2, resolve@^1.4.0, resolve@^1.5.0:
version "1.8.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
dependencies:

View File

@@ -6,7 +6,7 @@
#import <React/RCTLog.h>
#import <React/RCTUIManager.h>
#import "RCTComponentData.h"
#import "React/RCTComponentData.h"
@implementation REAPropsNode
{

View File

@@ -60,7 +60,7 @@
"jest-react-native": "18.0.0",
"lint-staged": "^8.0.0-beta.1",
"prettier": "^1.13.4",
"react": "^16.0.0-alpha.12",
"react": "16.4.1",
"react-dom": "^16.0.0-beta.5",
"react-native": "^0.56.0",
"react-test-renderer": "^16.0.0-alpha.12"

View File

@@ -5029,7 +5029,7 @@ react-transform-hmr@^1.0.4:
global "^4.3.0"
react-proxy "^1.1.7"
react@^16.0.0-alpha.12:
react@16.4.1:
version "16.4.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.4.1.tgz#de51ba5764b5dbcd1f9079037b862bd26b82fe32"
dependencies: