Coder Social home page Coder Social logo

Comments (4)

tazsingh avatar tazsingh commented on May 27, 2024

Hi @BernardA, are you using TypeScript on your project? The error related to a declaration file seems to be from type definitions not being present.

I don't use TypeScript myself but maybe this article could be of use? https://medium.com/@chris_72272/migrating-to-typescript-write-a-declaration-file-for-a-third-party-npm-module-b1f75808ed2
Can possibly just reuse react-loadable's definitions as it's the same API as that. A PR would definitely be welcome if you get it working.

With respect to the service worker, I'm guessing that Webpack is resolving to a different URL than the require path. I haven't had a good use for service workers yet but maybe something like this could be useful - https://github.com/oliviertassinari/serviceworker-webpack-plugin
In the past I've just used HTTP caching to do what I believe you're trying to do. Maybe have a look at that also as I've seen service workers cause more harm than good for a various projects.

from react-loadable-visibility.

BernardA avatar BernardA commented on May 27, 2024

Thanks @tazsingh. I am not directly using TypeScript. React seems to do that on its own. I will check the article you referenced to, but I am afraid I am not knowledgeable enough to come up with a PR.

Concerning the service worker issue, I will try the plugin you mentioned. Right now I am updating Webpack to v4, from my Symfony Encore installation. Once I got that done, I will check if the fetching from network issue persists. If so, I will install the plugin.

In general I am very pleased with service worker, and it would be fantastic to have react-loadable fetch from cache for all requests subsequent to initial load. I will keep you posted.

By the way, the issue with double posting was that I posted the first time and still saw zero issues open. Same on the second time around. I had actually given up. As you said, it was a temporary glitch on github.

from react-loadable-visibility.

BernardA avatar BernardA commented on May 27, 2024

I tried the OfflinePlugin instead of the workbox-webpack-plugin but it did not solve the issue with react-loadable/visibility not fetching from cache.
It would seem that the issue is really with react-loadable/visibility.

from react-loadable-visibility.

tazsingh avatar tazsingh commented on May 27, 2024

Hi @BernardA, it would be impossible for this library to influence caching as there is nothing related to caching or service workers in it. As such, I am closing this issue due to it not being an issue with the way that this library functions.

I'm not sure exactly what you're trying to achieve with a service worker and its caching, however as mentioned above I've used HTTP caching with a long max-age or even immutable value as well as Webpack's chunk hash in the filename to achieve the desired effect for me. This is also the more conventional way of handling asynchronous chunk loading. Have you taken a look at that?

from react-loadable-visibility.

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.