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";
+1 -1
View File
@@ -14,4 +14,4 @@
*/
// File does not exist.
import b from "tests/jerry/fail/module-exports.js"
import b from "module-exports.js"
+1 -1
View File
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import { , as b } from "tests/jerry/es2015/module-export-01.js";
import { , as b } from "../es2015/module-export-01.js";
+1 -1
View File
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import , as b from "tests/jerry/es2015/module-export-01.js";
import , as b from "../es2015/module-export-01.js";
+1 -1
View File
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import { b as , } from "tests/jerry/es2015/module-export-01.js";
import { b as , } from "../es2015/module-export-01.js";
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Named imports must be in a NamedImports block. */
import b as , from "tests/jerry/es2015/module-export-01.js";
import b as , from "../es2015/module-export-01.js";
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Module requests must always be evaluated. */
import "tests/jerry/fail/module-sideeffect.js"
import "./module-sideeffect.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Can't have duplicate local bindings */
import { c as a, d as a } from "tests/jerry/es2015/module-export-01.js";
import { c as a, d as a } from "../es2015/module-export-01.js";
+1 -1
View File
@@ -15,5 +15,5 @@
/* Import/export statements must be in the global scope. */
if (true) {
import { c } from "tests/jerry/es2015/module-export-01.js";
import { c } from "../es2015/module-export-01.js";
}
+1 -1
View File
@@ -15,5 +15,5 @@
/* Import/export statements must be in the global scope. */
function someFunction() {
import { c } from "tests/jerry/es2015/module-export-01.js";
import { c } from "../es2015/module-export-01.js";
}
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Import/export statements must be in the global scope. */
eval ('import { c } from "tests/jerry/es2015/module-export-01.js";');
eval ('import { c } from "../es2015/module-export-01.js";');
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* NamedImports must always be followed by a FromClause. */
import { b }, from "tests/jerry/es2015/module-export-01.js"
import { b }, from "../es2015/module-export-01.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* An import statement can have either a NameSpaceImport or NamedIpmorts */
import * as mod, { b } from "tests/jerry/es2015/module-export-01.js"
import * as mod, { b } from "../es2015/module-export-01.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* '*' is not valid inside NamedImports. */
import { *, d } from "tests/jerry/es2015/module-imported-01.js"
import { *, d } from "../es2015/module-imported-01.js"
+2 -2
View File
@@ -14,5 +14,5 @@
*/
/* Can't have duplicated local bindings. */
import { b } from "tests/jerry/es2015/module-export-01.js"
import { b } from "tests/jerry/es2015/module-export-02.js"
import { b } from "../es2015/module-export-01.js"
import { b } from "../es2015/module-export-02.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* FromClause must follow an ImportClause. */
import from "tests/jerry/es2015/module-export-02.js"
import from "../es2015/module-export-02.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Namespace imports must have a local name. */
import * from "tests/jerry/es2015/module-export-01.js"
import * from "../es2015/module-export-01.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Star exports can't have an export name. */
export * as star from "tests/jerry/es2015/module-export-01.js"
export * as star from "../es2015/module-export-01.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Indirect exports must be checked if they are resolvable. */
export { l } from "tests/jerry/es2015/module-export-01.js"
export { l } from "../es2015/module-export-01.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Can't have circular imports/exports. */
export { b } from "tests/jerry/fail/module-027.js"
export { b } from "./module-027.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Can't have circular imports/exports. */
export { b } from "tests/jerry/fail/module-026.js"
export { b } from "./module-026.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Ambiguous import */
import { x } from "tests/jerry/es2015/module-export-05.js"
import { x } from "../es2015/module-export-05.js"
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* Import/export statements must be in the global scope. */
Function('','import { c } from "tests/jerry/es2015/module-export-01.js";')
Function('','import { c } from "../es2015/module-export-01.js";')
+1 -1
View File
@@ -14,4 +14,4 @@
*/
/* No default export found. */
import def from "tests/jerry/es2015/module-export-06.js"
import def from "../es2015/module-export-06.js"
@@ -13,4 +13,4 @@
// limitations under the License.
export {} from "dummy.js";
export {} from "tests/jerry/es2015/module-export-04.js";
export {} from "../es2015/module-export-04.js";