Skip to content

Support module builtins #13

@PsychoLlama

Description

@PsychoLlama

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".

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions