On startup, grab the set of all module builtins like events and http. New modules like http2 are added in newer versions, so a hard-coded list can easily fall out of date. Something like this is probably fine:
let modules = system('node -p "JSON.stringify(require(''module'').builtinModules)"')
let modules = json_decode(modules)
When the developer tries to open one of these builtins, open it in a read-only buffer:
enew
let source = systemlist('node -p "process.binding(''natives'')[''' . module . ''']"')
call setline(1, source)
setf javascript
Some kind of warning is probably appropriate, like "Warning: viewing read-only module builtin".
On startup, grab the set of all module builtins like
eventsandhttp. New modules likehttp2are added in newer versions, so a hard-coded list can easily fall out of date. Something like this is probably fine:When the developer tries to open one of these builtins, open it in a read-only buffer:
Some kind of warning is probably appropriate, like "Warning: viewing read-only module builtin".