bare --eval is not able to load modules from relative paths
freeall opened this issue · comments
Tobias Baunbæk Christensen commented
When running with --eval
, modules from relative paths does not seem to load.
This case works:
$ bare --eval "require('bare-path')"
And all of these exits with Uncaught ModuleError: MODULE_NOT_FOUND: Cannot find module '...' imported from 'file:///bare.bundle/bin/bare.js'
$ bare --eval "require('./')"
$ bare --eval "require('./index.js')"
$ bare --eval "require('/Users/freeall/workspace/holepunch/brittle/index.js')"
Kasper Isager Dalsgarð commented
The issue is that the --eval
and --print
flags use direct eval()
:
Lines 42 to 52 in 253139d
The require()
function is therefore not scoped to the current working directory, but instead to the bin/bare.js
bundle. They should use the Module.*
APIs instead.