Rework module parsing and execution (#4462)
This patch disables automatic detection of module code, and instead requires the user to explicitly specify whether to parse a source as a module or as a script. To achieve this the jerry_parse API function now takes a new option which signals that the source should be parsed as a module. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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 {} from "module-export-01.mjs";
|
||||
export {aa,} from "module-export-01.mjs";
|
||||
export {bb as b_, cc as c_} from "module-export-01.mjs";
|
||||
export * from "module-export-01.mjs";
|
||||
export default function () {return "default"};
|
||||
@@ -23,4 +23,4 @@ export default class {
|
||||
}
|
||||
}
|
||||
|
||||
export * from "module-export-02.js"
|
||||
export * from "module-export-02.mjs"
|
||||
@@ -13,6 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from "module-export-01.js";
|
||||
export * from "module-export-04.js";
|
||||
export * from "module-export-01.mjs";
|
||||
export * from "module-export-04.mjs";
|
||||
export default a = "str"
|
||||
@@ -14,6 +14,6 @@
|
||||
*/
|
||||
|
||||
export {}
|
||||
export {} from "module-export-01.js";
|
||||
export {} from "module-export-01.mjs";
|
||||
export {};
|
||||
export {} from "module-export-04.js"
|
||||
export {} from "module-export-04.mjs"
|
||||
@@ -13,5 +13,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from "./module-export-04.js";
|
||||
export * from "./module-export-04.mjs";
|
||||
export let c = 5;
|
||||
@@ -13,13 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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";
|
||||
import "./module-export-01.mjs";
|
||||
import def from "module-export-01.mjs";
|
||||
import {} from "module-export-01.mjs";
|
||||
import {aa as a,} from "module-export-01.mjs";
|
||||
import {bb as b, cc as c} from "module-export-01.mjs";
|
||||
import {x} from "module-export-01.mjs";
|
||||
import * as mod from "module-export-01.mjs";
|
||||
|
||||
assert (def === "default");
|
||||
assert (a === "a");
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import def, * as mod from "module-export-02.js";
|
||||
import {b_, c_,} from "module-export-02.js";
|
||||
import def, * as mod from "module-export-02.mjs";
|
||||
import {b_, c_,} from "module-export-02.mjs";
|
||||
|
||||
assert (def() === "default")
|
||||
assert (mod.aa === "a")
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import incrementer, {aa, c_, x,} from "module-export-03.js"
|
||||
import incrementer, {aa, c_, x,} from "module-export-03.mjs"
|
||||
var i = new incrementer(3);
|
||||
assert(i.incr() === 4);
|
||||
assert(i.incr() === 5);
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import "module-import-01.js";
|
||||
import "module-export-05.js";
|
||||
import "module-export-06.js";
|
||||
import "module-export-07.js";
|
||||
import "module-import-01.mjs";
|
||||
import "module-export-05.mjs";
|
||||
import "module-export-06.mjs";
|
||||
import "module-export-07.mjs";
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as f from "./module-export-08.js";
|
||||
import * as f from "./module-export-08.mjs";
|
||||
|
||||
assert (f.c === 5)
|
||||
assert (f.x === 41)
|
||||
+1
-1
@@ -22,6 +22,6 @@ getNamePromise(collector).then(() => { collector["end"] = resourceName(); });
|
||||
function __checkAsync() {
|
||||
assert(collector["start"].endsWith("module-resource-name-export.mjs"));
|
||||
assert(collector["middle"].endsWith("module-resource-name-export.mjs"));
|
||||
assert(collector["end"].endsWith("module-resource-name.js"));
|
||||
assert(collector["end"].endsWith("module-resource-name.mjs"));
|
||||
assert(Object.keys(collector).length === 3);
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
/* Import/export statements must be in the global scope. */
|
||||
var eval = eval.bind();
|
||||
try {
|
||||
eval('import { c } from "tests/jerry/es.next/module-export-01.js";');
|
||||
eval('import { c } from "tests/jerry/es.next/module-export-01.mjs";');
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert (e instanceof SyntaxError);
|
||||
|
||||
Reference in New Issue
Block a user