Use local package in example project.

This commit is contained in:
Dylan Vann 2018-05-07 11:26:26 -04:00
parent b2fb48bbe3
commit e8cfc7ae5d
8 changed files with 79 additions and 46 deletions

View File

@ -184,37 +184,7 @@ If you have any problems using this library try the steps in [troubleshooting](d
## Development
```bash
# Install SDWebImage submodules.
git submodule update --init --recursive
# Install npm dependencies.
yarn
```
Developing modules for React Native is currently a mess because the packager does not support symlinks.
Both major package managers, `npm@5` and `yarn`, do local installations by creating symlinks.
Unfortunately for now the workaround to update the example is to run:
```bash
# In the repo directory pack the module:
npm pack
# This makes a tarball like:
# react-native-fast-image-1.0.0.tgz
# Move into the example:
cd example
# Install the tarball:
npm install ../react-native-fast-image-1.0.0.tgz
```
To update while developing you can re-pack and reinstall the tarball.
Hopefully [metro](https://github.com/facebook/metro) will add support for symlinks soon.
[Follow these instructions to get the example app running.](docs/development.md)
## Supported React Native Versions

View File

@ -74,6 +74,7 @@ import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
bundleConfig: "./metro.config.js"
]
apply from: "../../node_modules/react-native/react.gradle"

View File

@ -2,6 +2,6 @@ rootProject.name = 'ReactNativeFastImageExample'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../../android')
include ':app'

View File

@ -372,7 +372,7 @@
4BD56E1000C54038A7679FB3 /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
5B07421EB1E941269F1CFF5D /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; 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>"; };
633E06912F184278A517D8FA /* FastImage.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = FastImage.xcodeproj; path = "../node_modules/react-native-fast-image/ios/FastImage.xcodeproj"; sourceTree = "<group>"; };
633E06912F184278A517D8FA /* FastImage.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = FastImage.xcodeproj; path = ../../ios/FastImage.xcodeproj; sourceTree = "<group>"; };
64308C10C3D142E9886F32AE /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; 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>"; };
7DCFCBBB488D400CA319D2EB /* Feather.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Feather.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Feather.ttf"; sourceTree = "<group>"; };
@ -1213,7 +1213,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
shellScript = "export NODE_BINARY=node\nexport BUNDLE_CONFIG=./metro.config.js\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
@ -1227,7 +1227,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
shellScript = "export NODE_BINARY=node\nexport BUNDLE_CONFIG=./metro.config.js\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
/* End PBXShellScriptBuildPhase section */
@ -1305,7 +1305,7 @@
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = ReactNativeFastImageExampleTests/Info.plist;
@ -1333,7 +1333,7 @@
DEVELOPMENT_TEAM = U8E2VB5JLQ;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = ReactNativeFastImageExampleTests/Info.plist;
@ -1362,7 +1362,7 @@
DEVELOPMENT_TEAM = U8E2VB5JLQ;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = ReactNativeFastImageExample/Info.plist;
@ -1386,7 +1386,7 @@
DEVELOPMENT_TEAM = U8E2VB5JLQ;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = ReactNativeFastImageExample/Info.plist;
@ -1417,7 +1417,7 @@
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = "ReactNativeFastImageExample-tvOS/Info.plist";
@ -1454,7 +1454,7 @@
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**",
"$(SRCROOT)/../../ios/FastImage/**",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
);
INFOPLIST_FILE = "ReactNativeFastImageExample-tvOS/Info.plist";

View File

@ -0,0 +1,17 @@
const path = require('path');
const blacklist = require('metro/src/blacklist');
module.exports = {
extraNodeModules: {
},
getBlacklistRE: () => blacklist([
/[/\\]Users[/\\]dylan[/\\]repos[/\\]react-native-fast-image[/\\]node_modules[/\\]react-native[/\\].*/
]),
getProjectRoots: () => [
// Include current package as project root
path.resolve(__dirname),
// Include symlinked packages as project roots
path.resolve('/Users/dylan/repos/react-native-fast-image')
],
};

View File

@ -3,13 +3,13 @@
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"start": "metro-with-symlinks start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-fast-image": "file:../react-native-fast-image-4.0.8.tgz",
"react-native-fast-image": "../",
"react-native-image-progress": "^1.1.0",
"react-native-status-bar-height": "^2.0.0",
"react-native-vector-icons": "^4.5.0",
@ -21,6 +21,7 @@
"babel-jest": "23.0.0-alpha.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.2",
"metro-with-symlinks": "https://github.com/DylanVann/metro-with-symlinks",
"react-test-renderer": "^16.3.0-alpha.1"
},
"jest": {

View File

@ -1826,6 +1826,10 @@ decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
dedent-js@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/dedent-js/-/dedent-js-1.0.1.tgz#bee5fb7c9e727d85dffa24590d10ec1ab1255305"
deep-extend@~0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
@ -3656,6 +3660,12 @@ metro-source-map@0.30.2:
dependencies:
source-map "^0.5.6"
"metro-with-symlinks@https://github.com/DylanVann/metro-with-symlinks":
version "1.0.5"
resolved "https://github.com/DylanVann/metro-with-symlinks#14f9f076df06d8a4065bc1ada900e0d260aa31eb"
dependencies:
dedent-js "^1.0.1"
metro@^0.30.0:
version "0.30.2"
resolved "https://registry.yarnpkg.com/metro/-/metro-0.30.2.tgz#e722e0eb106530f6d5bcf8de1f50353a0732cfb3"
@ -4401,9 +4411,8 @@ react-native-drawer-layout@1.3.2:
dependencies:
react-native-dismiss-keyboard "1.0.0"
"react-native-fast-image@file:../react-native-fast-image-4.0.8.tgz":
version "4.0.8"
resolved "file:../react-native-fast-image-4.0.8.tgz#ef6bfc6006cfaefa3d507a1b04fe9ccc6d6c68aa"
react-native-fast-image@../:
version "4.0.12"
dependencies:
prop-types "^15.5.10"

35
docs/development.md Normal file
View File

@ -0,0 +1,35 @@
# Development
For now this uses a modified cli to work around issues with symlinked packages.
This is how to start the example app so you can test code with it.
```bash
# In the repo root folder.
# Install dependencies.
yarn
# Install SDWebImage submodules.
git submodule update --init --recursive
# Link module.
yarn link
# Move to example folder.
cd ReactNativeFastImageExample
# Install dependencies.
yarn
# Link module.
yarn link react-native-fast-image
# Start packager.
yarn start
# Start the iOS app.
yarn react-native run-ios
# Start the android app.
yarn react-native run-android
# You will need to re-run those commands to re-compile native code.
```