Skip to content

Should module allow to import self? #60515

@fisker

Description

@fisker
>cat foo.js
export const foo = "foo";

>cat bar.js
export * from "./foo.js";

import { foo } from "./bar.js";

console.log(foo);

>node bar.js
foo

If it's intentional to allow, there is another issue.

>cat test.js
import "./test.js" with { unknown: "attribute" };

console.log("It works!");

>node test.js
It works!

>cat test.js
import "node:fs" with { unknown: "attribute" };

>node test.js
node:internal/modules/esm/assert:60
      throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED(keys[i], importAttributes[keys[i]], url);
            ^

TypeError [ERR_IMPORT_ATTRIBUTE_UNSUPPORTED]: Import attribute "unknown" with value "attribute" is not supported in node:fs

When importing self, the validateAttributes not checking attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions