Skip to content

Module cache hooks #61173

@Lakedaemon

Description

@Lakedaemon

What is the problem this feature will solve?

My project builds immutable modules and persistently stores them in a lmdb instance

I would like to be able to :

  • cache these modules in my lmdb instance after compilation
  • provide those modules from my lmdb instance to the node cache, bypassing compilation

This cannot be done through the load hooks (because load output needs to be compiled, it cannot be a module)
And the module cache api doesn't have hooks for customization

In my project, those lmdb modules are built ONCE (sometimes modified/versioned) and used for years to build a lot of other stuff.
My project aims to provide free education. Those modules are animations/courses/knowledge

What is the feature you are proposing to solve the problem?

2 hooks would be nice :
1 hook so that a callBack is called with the module, just after compilation.
1 hook to that a callBack with the module data (url, ...) with shortcut can provide a module when the cache is hit for the first time

with some api to invalidate the cache (custom and node) on changes
(a onChange callBack ?)

What alternatives have you considered?

I can make it work TODAY without this by injecting code in my modules but this smells.

nodes is a lot about building modules, giving more control to the user will bring new features/good stuff

With this, it would be WAY cleaner

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions