Bug 1777450 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Consider this JavaScript file:

```js
const p = await import(`data:text/javascript,
  export default import("./foo.js");
`);

await p.default;
```

It throws this error:
```
Uncaught TypeError: Error resolving module specifier “./foo.js”. Relative module specifiers must start with “./”, “../” or “/”.
```
which is super confusing, because `./foo.js` starts with `./`.

The same happens if you go to the `about:blank` page and run `await import("./foo.js")` in the console.

I believe that this happens because the referrer (the "base" from where `./foo.js`) is resolved in both cases is not a valid URL: in the first example it's probably the source of the inline imported module, while in the second case it's probably `about:blank`.

PS: I'm not sure if the component for this bug report should be "DOM: Core & HTML" or "JavaScript Engine"
Consider this JavaScript file:

```js
const p = await import(`data:text/javascript,
  export default import("./foo.js");
`);

await p.default;
```

It throws this error:
```
Uncaught TypeError: Error resolving module specifier “./foo.js”. Relative module specifiers must start with “./”, “../” or “/”.
```
which is super confusing, because `./foo.js` starts with `./`.

The same happens if you go to the `about:blank` page and run `await import("./foo.js")` in the console.

I believe that this happens because the referrer (the "base" from where `./foo.js` is resolved) in both cases is not a valid URL: in the first example it's probably the source of the inline imported module, while in the second case it's probably `about:blank`.

PS: I'm not sure if the component for this bug report should be "DOM: Core & HTML" or "JavaScript Engine"

Back to Bug 1777450 Comment 0