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:
@@ -14,4 +14,4 @@
|
||||
*/
|
||||
|
||||
// File does not exist.
|
||||
import b from "tests/jerry/fail/module-exports.js"
|
||||
import b from "module-exports.js"
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
*/
|
||||
|
||||
/* Module requests must always be evaluated. */
|
||||
import "tests/jerry/fail/module-sideeffect.js"
|
||||
import "./module-sideeffect.js"
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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";');
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
*/
|
||||
|
||||
/* Ambiguous import */
|
||||
import { x } from "tests/jerry/es2015/module-export-05.js"
|
||||
import { x } from "../es2015/module-export-05.js"
|
||||
|
||||
@@ -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";')
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user