mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
/*
|
|
* Relative resolution bug in Duktape 0.12.0
|
|
*
|
|
* https://github.com/svaarala/duktape/issues/48
|
|
*/
|
|
|
|
/*---
|
|
{
|
|
"custom": true
|
|
}
|
|
---*/
|
|
|
|
/*===
|
|
Duktape.modSearch foo
|
|
Duktape.modSearch quux
|
|
Duktape.modSearch foo/bar
|
|
Duktape.modSearch foo/quux
|
|
===*/
|
|
|
|
function test() {
|
|
/*
|
|
* Relative resolution from 'foo'
|
|
*/
|
|
|
|
Duktape.modSearch = function (id) {
|
|
print('Duktape.modSearch', id);
|
|
if (id === 'foo') {
|
|
return "var text = 'Hello world!'; // not visible outside the module\n" +
|
|
"var quux = require('./quux'); // loads quux\n" +
|
|
"exports.hello = function () { print(text); };";
|
|
}
|
|
return ''; // return a fake empty module
|
|
};
|
|
void require('foo');
|
|
|
|
/*
|
|
* Relative resolution from 'foo/bar'
|
|
*/
|
|
|
|
Duktape.modSearch = function (id) {
|
|
print('Duktape.modSearch', id);
|
|
if (id === 'foo/bar') {
|
|
return "var text = 'Hello world!'; // not visible outside the module\n" +
|
|
"var quux = require('./quux'); // loads foo/quux\n" +
|
|
"exports.hello = function () { print(text); };";
|
|
}
|
|
return ''; // return a fake empty module
|
|
};
|
|
void require('foo/bar');
|
|
}
|
|
|
|
try {
|
|
test();
|
|
} catch (e) {
|
|
print(e.stack || e);
|
|
}
|
|
|