Coder Social home page Coder Social logo

[RFC] sync API about repack HOT 14 CLOSED

troZee avatar troZee commented on September 22, 2024
[RFC] sync API

from repack.

Comments (14)

RafikiTiki avatar RafikiTiki commented on September 22, 2024 2

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.

thymikee avatar thymikee commented on September 22, 2024 2

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.

troZee avatar troZee commented on September 22, 2024 1

@jbroma done

from repack.

jbroma avatar jbroma commented on September 22, 2024 1

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.

jbroma avatar jbroma commented on September 22, 2024

@troZee please update the description 🙏 thanks!

from repack.

jbroma avatar jbroma commented on September 22, 2024

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.

RafikiTiki avatar RafikiTiki commented on September 22, 2024

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.

jbroma avatar jbroma commented on September 22, 2024

@thymikee WDYT

from repack.

jbroma avatar jbroma commented on September 22, 2024

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.

github-actions avatar github-actions commented on September 22, 2024

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.

DivyatejaChe avatar DivyatejaChe commented on September 22, 2024

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.

github-actions avatar github-actions commented on September 22, 2024

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.

github-actions avatar github-actions commented on September 22, 2024

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.

github-actions avatar github-actions commented on September 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.