Skip to content

esm modules documentation doesn't describe how to implement a module #28060

Closed
@sam-github

Description

@sam-github

I read https://nodejs.org/api/esm.html and found that while it had good/exhaustive coverage of import, it doesn't describe how to export a module. Unless I very much missed it, there is not even a single example of a ESM module.

I know, import and export are part of the language base, and node's documentation doesn't cover the Javascript language. In this case, I think its necessary to at least have a single example, such as:

export function whatever() {};
export function somethingElse() {};
export default {
  whatever,
   somethingElse,
};

Not having this makes the import docs hard to understand, they talk a lot about "exports" and "default exports", but without defining them.

Also, having read through ~600 lines of documentation on ECMAscript modules and still having to scrape the internet to figure out how to write one is not a great documentation experience :-).

  • Version: master/12
  • Platform: any
  • Subsystem: doc

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions