nodejs / nodejs/node

Generating Compile Cache Ahead of Runtime

Open
#58,482 16 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request stale
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

It is currently not possible to generate the compile cache without executing the files that will be cached.

Currently, container images and lambda functions can't easily generate code caches ahead of the actual runtime, since the code may have effects you may not want to execute early.

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

Would it be possible to add a way to generate the compile cache without executing the relevant files, i.e. walking the module tree from the entry point, generating caches along the way?

Perhaps something like node --generate-compile-cache path/to/entrypoint.mjs
and/or

module.generateCompileCache("path/to/entrypoint.mjs")
What alternatives have you considered?

You may be able to work around this by adding "dry-run" code paths specifically for code cache generation, but this is a hacky workaround that can require massive effort.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining Node.js's existing compile-cache behavior and the proposed --generate-compile-cache and module.generateCompileCache() entry points. Determine how an entrypoint's module tree could be traversed without executing application code. Done means a documented, tested way to generate the relevant compile cache ahead of runtime.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.