You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
esm modules documentation doesn't describe how to implement a module #28060
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 :-).
Activity
sam-github commentedon Jun 4, 2019
/to @nodejs/modules-active-members
karthikPullela commentedon Jun 18, 2019
I'm new to contributing to Node.js but I can try to take point on this.
GeoffreyBooth commentedon Nov 22, 2019
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
exportequivalent 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 aboutexportthat 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.doc: add examples for implementing ESM
doc: add examples for implementing ESM
doc: add examples for implementing ESM
doc: add examples for implementing ESM
doc: add examples for implementing ESM