Closed ranaharoni closed 7 years ago
This is not a bug. You need to write your own a loader, ad hoc.
@ranaharoni this behaviour is caused by the "normalising" step of V8Js' require implementation. What it tries to do is resolve relative path names (like you're trying to give) to absolute ones, so the module loader callback is provided absolute path names.
Some simple example
// from root context
require('foo/bar'); // this calls the module loader with 'foo/bar'
// in foo/bar
require('./baz'); // this calls the module loader with 'foo/baz'
// still in foo/bar
require('../blar'); // this calls the module loader with 'blar'
So if you do not want that path normalisation by V8Js you need to provide some custom normalisation routine. So if you really really want no normalisation at all you can do something like
$v8->setModuleNormaliser(function($basedir, $load) { return [ '', $load ]; } );
However generally that is a bad idea if you require modules from other modules ...
Hi there,
I just noticed that a the module loader arg for the path does not pass the real path specified in the
require
argument.Is there any good reason it to omit the
.
and..
from the $path argument or is it just a bug?