Comments (14)
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.
This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.
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.
hey @RafikiTiki , do you have any results/ performance benchmarks that support this statement? For any super-app development, are there any guidelines around when/ how to choose certain parts of your app as Remote vs Local Chunks?
@jbroma please do add as well
from repack.
This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.
from repack.
This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.
from repack.
This issue has been automatically closed because it has been inactive for more than 14 days. Please reopen if you want to add more context.
from repack.
Related Issues (20)
- Error: Can't resolve 'react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance HOT 2
- File src_navigation_Request_tsx.chunk.bundle for ios not found in compilation assets and i try to add react-native-reanimated-carousel lib to project HOT 2
- i try to add react-native-reanimated-carousel lib to project HOT 2
- Stuck while loading bundles on second app launch with cache flag enabled HOT 11
- `sourceURL` in raw React Native stack frames is inconsitent HOT 1
- Property '__webpack_share_scopes__' doesn't exist HOT 5
- Task :app:createBundleReleaseJsAndAssets_SentryUpload_*************************** FAILED HOT 3
- RangeError: Maximum call stack size exceeded HOT 1
- Missing libhermes.so causes crashes in Release Build HOT 14
- getting scriptmanager's resolved url: `noop://scriptId.chunk.bundle` for dev:false bundle HOT 1
- `dev:false` bundle throws error with react-navigation HOT 10
- PROBLEMS WITH NAVIGATION IN MICROFRONT FEDERATION HOT 4
- File not found in compilation assets causes memory leak HOT 2
- handle a module's redux state from another module HOT 4
- App compilation is complete but app is crashing on launch HOT 17
- Webpack env not able to change production mode after migrate v4 HOT 1
- Module parse failed: Unexpected token (1:7) HOT 2
- Compatible version for RN v0.71.8 HOT 1
- App Launch Failure After Upgrading to React Native 0.72.15
- The cliOptions.arguments.bundle.dev might be the string 'false' HOT 1
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.