Page MenuHomeSealhub

Remove `require` from locreq
Open, NormalPublic1 Points

Description

Locreq's development began as a tool for dynamicly requireing modules given only their path relative to the project root. After shift to ESM and typescript we no longer seem to use its require functionality and only use the resolve function that returns the resolved absolute path to the file.

The task is about removing the require functionality of locreq. The API should now work like this:

ts
import locreq from "locreq";

await locreq(import.meta.filename, "public/images/myimage.png"); // should resolve to a string

// also possible to do currying like this:

import locreq from "locreq";

const initialized_locreq = locreq(import.meta.filename); // when given only one argument, it returns a function that can then be called with just the searched path:


await initialized_locreq(import.meta.filename); // should resolve to a string

Adjust the README to reflect those new changes

Related Objects