Comments (10)
Yeah, keeping the async as the default sounds good! And since we have a technological possibility to implement a sync method let's do that – maybe someone will benefit from it in a way that's not obvious to us now.
from repack.
Agree on keeping the default. How big of a maintenance investment would it be to implement, test and document the loadScriptSync
method? Frankly I would wait for the opportunity to solve the real problem to arise before publishing the API and hoping for adoption
from repack.
@jbroma done
from repack.
I agree with @RafikiTiki, we would need to integrate it in a way that would allow for such optimisation in this rare case and keep async loadScript
as default.
from repack.
@troZee please update the description 🙏 thanks!
from repack.
Personally, I'm not sure whether sync API is useful as loadScript
is called only for the async chunks right now.
The only thing that comes to mind where this would be helpful is that we could split the the main chunk into smaller chunks and allow them to be OTA updated. As all chunks would be required at startup, the sync API could prove useful there.
To me it looks like loadScript
is the only sensible candidate to leverage the sync API
from repack.
Typically a user should see a loading screen/indicator when a script is being fetched and evaluated. Having sync API for loading a script would only make sense for local chunks but then it would be a little quirky to decide whether to use sync or async method 🤔
Edit: on top of that, in the linked docs we discourage users from using local chunks if they are using Hermes because it might result in degraded performance.
from repack.
@thymikee WDYT
from repack.
loadScript
is used mostly internally, although it is exposed as a public API and can be used on it's own. I imagine we would have to add a field to Script
config returned from resolver to turn on synchronous loading like this:
import { ScriptManager, Script } from '@callstack/repack/client';
ScriptManager.shared.addResolver(async (scriptId) => {
// In development, get all the chunks from dev server.
if (__DEV__) {
return {
url: Script.getDevServerURL(scriptId),
cache: false,
};
}
// In production, get chunks matching the regex from filesystem.
if (/^.+\.local$/.test(scriptId)) {
return {
url: Script.getFileSystemURL(scriptId),
sync: true // <-------
};
} else {
return {
url: Script.getRemoteURL(`https://my-domain.dev/${scriptId}`),
};
}
});
Maintenance wise, this is not part of something that changes often (or at all) from my experience, we can also consider marking it as experimental.
from repack.
Related Issues (20)
- Facing issue while implementing Offline Bundling. HOT 8
- Error in bundling micro apps with react-native-svg packages HOT 3
- [RFC] Override `start` command in `react-native.config.js` HOT 10
- Unhandled error in Webpack Compiler when doing `rpm run ios` HOT 2
- Cannot Resole React Hook Form correctly HOT 7
- repack monorepo deployment help
- Android is crashing when "onMessage" props is accessed in "react-native-webview" library HOT 1
- Improve types for `prefetchScript` and `loadScript` HOT 6
- Is it possible to load a remote module before it is requested by the user?
- callstack_repack-Swift.h file not found HOT 18
- Repack app fails with "could not find react-redux context value" for the latest versions of react-redux and @reduxjs/toolkit HOT 3
- Property 'HMRClient' doesn't exist HOT 4
- Challenge Integrating Repack in React Native Mono Repo: App1 Loads Successfully, App2 Fails to Load from Server Bundles HOT 3
- Extract runtime into separate package in monorepo & publish it separately HOT 4
- Migrate ObjC code parts to Swift HOT 2
- How do i use react-native-gesture-handler in both my mini app and host app? HOT 5
- Repack Navigation From Mini App To Main APP HOT 3
- Adopt the new federation runtime HOT 5
- A clear working example of how code signing works with repack HOT 11
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 repack.