Skip to content

Why NodeJS store source code in memory? #46990

Answered by bnoordhuis
Luchanso asked this question in General
Discussion options

You must be logged in to vote

It's pretty much required by the language. Calling .toString() on a function must return the source text.

SpiderMonkey (the JS engine in Firefox) at one time reconstructed the source text from bytecode but that had so many bugs and edge cases, it never really worked right.

They eventually gave up trying to make it work and switched to retaining source in memory, just like all other major JS engines.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Luchanso
Comment options

You must be logged in to vote
1 reply
@bnoordhuis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants