Resolve module paths relative to the current module (#2976)

The current module implementation resolves module paths relative to the
current working directory, but paths should be resolved relative to the
currently evaluated module/source.

This requires a change in the jerry_port_normalize_path port API
function, so that it also takes the current module path as an argument.
On the engine side, we now also create a module object for the main
script, so that we can properly identify the base path for other
modules.

Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2019-07-17 14:44:18 +02:00
committed by GitHub
parent 6c441091b4
commit ec11a7b4e9
47 changed files with 233 additions and 129 deletions
+4 -4
View File
@@ -13,8 +13,8 @@
* limitations under the License.
*/
export {} from "tests/jerry/es2015/module-export-01.js";
export {aa,} from "tests/jerry/es2015/module-export-01.js";
export {bb as b_, cc as c_} from "tests/jerry/es2015/module-export-01.js";
export * from "tests/jerry/es2015/module-export-01.js";
export {} from "module-export-01.js";
export {aa,} from "module-export-01.js";
export {bb as b_, cc as c_} from "module-export-01.js";
export * from "module-export-01.js";
export default function () {return "default"};
+1 -1
View File
@@ -23,4 +23,4 @@ export default class {
}
}
export * from "tests/jerry/es2015/module-export-02.js"
export * from "module-export-02.js"
+2 -2
View File
@@ -13,6 +13,6 @@
* limitations under the License.
*/
export * from "tests/jerry/es2015/module-export-01.js";
export * from "tests/jerry/es2015/module-export-04.js";
export * from "module-export-01.js";
export * from "module-export-04.js";
export default a = "str"
+2 -2
View File
@@ -14,6 +14,6 @@
*/
export {}
export {} from "tests/jerry/es2015/module-export-01.js";
export {} from "module-export-01.js";
export {};
export {} from "tests/jerry/es2015/module-export-04.js"
export {} from "module-export-04.js"
+7 -7
View File
@@ -13,13 +13,13 @@
* limitations under the License.
*/
import "tests/jerry/es2015/module-export-01.js";
import def from "tests/jerry/es2015/module-export-01.js";
import {} from "tests/jerry/es2015/module-export-01.js";
import {aa as a,} from "tests/jerry/es2015/module-export-01.js";
import {bb as b, cc as c} from "tests/jerry/es2015/module-export-01.js";
import {x} from "tests/jerry/es2015/module-export-01.js";
import * as mod from "tests/jerry/es2015/module-export-01.js";
import "./module-export-01.js";
import def from "module-export-01.js";
import {} from "module-export-01.js";
import {aa as a,} from "module-export-01.js";
import {bb as b, cc as c} from "module-export-01.js";
import {x} from "module-export-01.js";
import * as mod from "module-export-01.js";
assert (def === "default");
assert (a === "a");
+2 -2
View File
@@ -13,8 +13,8 @@
* limitations under the License.
*/
import def, * as mod from "tests/jerry/es2015/module-export-02.js";
import {b_, c_,} from "tests/jerry/es2015/module-export-02.js";
import def, * as mod from "module-export-02.js";
import {b_, c_,} from "module-export-02.js";
assert (def() === "default")
assert (mod.aa === "a")
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import incrementer, {aa, c_, x,} from "tests/jerry/es2015/module-export-03.js"
import incrementer, {aa, c_, x,} from "module-export-03.js"
var i = new incrementer(3);
assert(i.incr() === 4);
assert(i.incr() === 5);
+4 -4
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import "tests/jerry/es2015/module-import-01.js"
import "tests/jerry/es2015/module-export-05.js"
import "tests/jerry/es2015/module-export-06.js"
import "tests/jerry/es2015/module-export-07.js"
import "module-import-01.js";
import "module-export-05.js";
import "module-export-06.js";
import "module-export-07.js";