New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rldr

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rldr

reloads a webpage on changes

latest
npmnpm
Version
3.0.12
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

rldr

Reloader, watches files for changes, reloads webpages in response

step 1 add a script tag for rldr to your html

<script src="/rldr"></script>

Option A: rldr in express

To use add this to your html someplace

Then in your express server add rldr to the app

automatic watching

  const path = require("path")
  const pathsToWatch = [path.join(__pathname, "../src")] 
  require("rldr")(app, pathsToWatch)

manual watching

  const path = require("path")
  reloadDirs = [path.join(__pathname, "../src")] 

  function addRldr(app) {
    const rldr = require("rldr")(app)
    const watch = require("watch")
  
    reloadDirs.forEach(dir => {
      watch.watchTree(dir, {interval: .2}, function (f, curr, prev) {
          console.log("Server Change Detected, reloading client")
          // Fire server-side reload event
          rldr.reload();
      });
    })
  }

Option B: rldr as a command

this had been moved to a separate module named rldr-cli rldr-cli

Adding a custom origin for RLDR requests

If rldr is used in addition to another webserver, you may need to set the RLDR_ORIGIN. So if you are loading rldr as http://localhost:8045 you can preset the variable with an inline script tag

<script>var RLDR_ORIGIN="http://localhost:8045"</script>
<script src="http://localhost:8045/rldr"></script>

or by settings RLDR_ORIGIN in localStorage

you will also probaby need to call the rldr-cli with --alow-origin http://localhost:YOUR_OTHER_PORT

Additional Notes

it uses express-longpoll to send reload events back to the client

Questions

why not websockets? simplicity. longpoll just works in more environments.

FAQs

Package last updated on 30 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts