Comments (7)
Oh nice, love it. I think I've got enough to put together a PR, should have time in the next couple of weeks.
from react-native-ultimate-config.
@maxkomarychev Any feedback on this? I'd be happy to put together a PR if we can agree on a direction.
from react-native-ultimate-config.
hey! that's a great suggestion!
why not drop the js_override flag and the UltimateConfig module reference from JavaScript entirely and just generate a pure JavaScript module containing the needed variables. This would simplify usage (zero config!) and make things work on the web and on native with the same import path. Or am I missing some benefit to pulling the JS config values from native?
the very reason I created this project is to keep all platforms aligned. there are plenty of solutions which work good in pure js world but I want to be able to define variables in all platforms. having said that it seems natural to propagate values from ios/android to js.
it's getting a bit tricky now to try to retrofit pure-js solution on top of current library.
I wonder is it possible to have isomorphic implementation such that we don't have to generate separate d.ts file for overrides.
for instance is maybe possible to detect whether code is running in web or react-native? maybe by checking existence of some global variable? window?
from react-native-ultimate-config.
the very reason I created this project is to keep all platforms aligned. there are plenty of solutions which work good in pure js world but I want to be able to define variables in all platforms. having said that it seems natural to propagate values from ios/android to js.
The vision makes sense, I like it.
I wonder is it possible to have isomorphic implementation such that we don't have to generate separate d.ts file for overrides. Would the switch between the pure-js web module and the react-native module have to be automatic though?
I believe that building an automatic switch behinds the scenes would require dynamic imports (to avoid referencing react native modules in a web app)... not ideal. I think we could generate a separate build file specifically for the web though without duplicating types. Users could import the file via import config from "react-native-ultimate-config/web";
, making it clear that they're getting a web-specific version. For universal react-native/react-native-web projects it is standard to use webpack to replace "react-native" imports with "react-native-web" imports, so we could write a bit o' documentation recommending the same thing to switch between "react-native-ultimate-config" and "react-native-ultimate-config/web".
These changes could be implemented separately from any modification to the js_override
flag, but they would allow you to eventually drop the js_override
flag in favor of import config from "react-native-ultimate-config/web";
which I think would be more in line with your vision of an "ultimate" config option that is the same everywhere in a react native app.
from react-native-ultimate-config.
Do you think we can do it relying on this feature of react-native and metro bundler https://reactnative.dev/docs/platform-specific-code ?
We could create a file index.js
and index.native.js
. In web projects you it would resolve to index.js
free of all react-native imports. In RN projects it would resolve to index.native.js
.
In such case we don't have to worry about dynamic and/or optional imports and simply have 2 files picked up by a bundler based on which bundler/env is used.
What do you think?
from react-native-ultimate-config.
published as part of 3.4.0
from react-native-ultimate-config.
thank you! <3
from react-native-ultimate-config.
Related Issues (20)
- Warning on build: ios/rnuc.xcconfig: line 1: //: is a directory HOT 4
- is it possible to keep env based package name in proguard-rules.pro? HOT 2
- Build Failure - RN 0.69.1 HOT 30
- Android JCenter - build failure HOT 3
- expo 47 compatible ? HOT 2
- RN issue: Cannot choose between the following variants of com.facebook.react:react-native HOT 4
- Cannot choose between the following variants of com.facebook.react:react-native:0.70.6: HOT 2
- Error React Native IOS Undefined symbol: _RCTRegisterModule HOT 1
- Build error on 0.71.2: 'RNUltimateConfigSpec.h' file not found HOT 7
- Doc/Quickstart (minor): `npm bin` deprecated in Node 18.14 HOT 1
- Gradle 8 support HOT 4
- Could not set unknown property 'classifier' for task
- Packaging error
- Multiple env files possible? HOT 1
- Kotlin support
- '$' is not recognized as internal or external command HOT 1
- Error: Cannot resolve ./override HOT 8
- Does this package support use_frameworks! :linkage => :static ? HOT 1
- Firebase Initialization Issue with react-native-ultimate-config in NX Monorepo
- How to access from shell scripts HOT 5
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-ultimate-config.