Comments (10)
"The React Native Packager has a built-in option, extraNodeModules, which seems to act as a module alias mapping. I couldn't find much information about this option, but here's the PR where it was added: facebookarchive/node-haste#69. Here's my rn-cli.config.js:"
philikon/ReactNativify#4
from react-native-ble.
Im not sure why, but utilizing the react-native-webpack-server's example this works properly, but not when with a react native generated template and following their readme. Tracking here mjohnston/react-native-webpack-server#75
For now, Ive added an example based on their example thats working great.
from react-native-ble.
react-native-webpack-server seems poorly supported now, and react is holding steadfast on their packager.
Ive killed the react-native-webpack-server in the example for now, which means no aliasing again.
facebook/react-native#5917 and https://productpains.com/post/react-native/packager-support-resolvealias-ala-webpack/ need your upvotes.
from react-native-ble.
This was solved (I dont know what release) by using the default packager and the browser field in package.json
"browser": {
"noble": "react-native-ble"
},
from react-native-ble.
Current packager only alias's one level deep it would seem. So we can use var noble = require('noble') in our main file, but if we var Bean = require('ble-bean'); which does its own noble require, it fails out because its trying to us actual noble :(
from react-native-ble.
Here is the current issue that is asking for global aliasing. Please bump
facebook/react-native#6253
from react-native-ble.
I have a PR in with preliminary deep shim support facebook/react-native#9899 PRs and help wanted.
Also it seems like theres a lot of movement around rn-nodeify, a nifty hack rewriting files locally in order to get around fixing the react native packager. Ive favored this solution in the readmes for now while I continue to work on my solution
from react-native-ble.
Todo: Look at https://reactnatve.wordpress.com/2016/06/16/alias-in-react-native/
from react-native-ble.
Another day another set of options. I found https://github.com/tleunen/babel-plugin-module-resolver which should allow something like
{
'presets': ['module:metro-react-native-babel-preset'],
'plugins': [
['module-resolver', {
'extensions': ['.ios.js', '.android.js', '.js', '.json'],
'alias': {
'noble': 'react-native-ble'
}
}]
]
}
However in practice it also recursively rewrites react-native-ble itself so the noble/with-bindings becomes react-native-ble/with-bindings ...
It doesnt have an includes or excludes like say webpack tleunen/babel-plugin-module-resolver#301
but the regex or function
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#regular-expressions or
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#passing-a-substitute-function might be able to be hacked somehow?
Otherwise @phated has a concept for using the metro field in package.json here
"metro": {
"resolver": {
"resolverMainFields": [
"react-native",
"browser",
"main"
]
}
}
Then pushing these bindings directly inside of noble and then adding to nobles package.json
"react-native": {
"./lib/resolve-bindings.js": "./lib/resolve-bindings"
},
which could swap in resolve-bindings.ios.js or resolve-bindings.android.js if we move all this code upstream. Though noble needs cross platform code changes swapping events/ and inherits instead of util and events
from react-native-ble.
Oh odd.. you actually dont need any of the metro/react-native key stuff in either project, itll automatically pick up the bindings because noble doesnt specify an extension here
https://github.com/noble/noble/blob/c4cd18a7a429bb832f6c4ca793be3faf9af884e9/index.js#L2
from react-native-ble.
Related Issues (20)
- noble.state is `unsupported` on evey other launch (iOS) HOT 2
- Build Fail with RN v .0.40.0 'sendDeviceEventWithName:body:' is deprecated
- ios simulator app crashing with react-native-ble library installed HOT 2
- Error with running App with react-native-ble on Android in debug mode HOT 3
- Unable to resolve module 'url' HOT 6
- Evaluate react-native-ble-plx native code HOT 4
- noble.on is not a function HOT 2
- sendDeviceEventWithName:body is deprecated
- noble characteristic write error : 'Invalid parameter not satisfying: data != nil'
- Cannot subscribe to multiple characteristics HOT 3
- Cannot read property 'getState' of undefined HOT 2
- discoverIncludedServices not implemented for Android
- Can't read descriptor value
- Can't get characteristics list of a service HOT 3
- Crash on iOS HOT 4
- Eddystone protocol
- Different UUID format when running in my RN app and directly from noble/example/advertisement.js HOT 5
- List of characteristics are empty in service HOT 1
- Use Polidea's BLE for android and iOS under the hood
- How to advertise?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-ble.