Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sam-github opened this issue Jun 4, 2019 · 3 comments
Closed
Labels
doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@sam-github
Copy link
Contributor

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
@sam-github sam-github added doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation. labels Jun 4, 2019
@sam-github
Copy link
Contributor Author

/to @nodejs/modules-active-members

@karthikPullela
Copy link

I'm new to contributing to Node.js but I can try to take point on this.

@GeoffreyBooth
Copy link
Member

The section https://nodejs.org/api/esm.html#esm_writing_dual_packages_while_avoiding_or_minimizing_hazards includes some example ES modules with exports.

Admittedly that’s not the export equivalent of https://nodejs.org/api/esm.html#esm_code_import_code_specifiers, but as the OP notes, it’s not Node’s job to document the JavaScript language itself. There’s nothing about export that Node does differently than the spec, or that’s special in Node as compared to any other runtimes. https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export should be sufficient I would think.

rosaxxny added a commit to rosaxxny/node that referenced this issue Apr 30, 2020
codebytere pushed a commit that referenced this issue May 16, 2020
Fixes: #28060

PR-URL: #33168
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
codebytere pushed a commit that referenced this issue Jun 7, 2020
Fixes: #28060

PR-URL: #33168
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
codebytere pushed a commit to codebytere/node that referenced this issue Jun 9, 2020
Fixes: nodejs#28060

PR-URL: nodejs#33168
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants