Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign updoc: esm: options for package authors #29497
Conversation
nodejs-github-bot
added
the
doc
label
Sep 8, 2019
GeoffreyBooth
force-pushed the
GeoffreyBooth:esm-package-doc
branch
from
aaeceba
to
c28ee9b
Sep 9, 2019
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@nodejs/documentation @nodejs/modules @nodejs/collaborators This could use some reviews. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Anyone care to review? |
|
I'm not a subject-matter expert on ES modules by any means, but LGTM other than needing to move a bottom reference to a different location in the list. I evaluated it it for formatting and clarity of text. It would be great if someone from @nodejs/modules-active-members could sign off on it (or provide a brief explanation of why perhaps it shouldn't land). |
Trott
added
the
author ready
label
Sep 16, 2019
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
not sure if late for this party, but as soon as you decide to reserve an entry in
{
// backward compatible
"main": "cjs/index.js",
"type": {
"commonjs": "cjs/index.js",
"esm": "esm/index.mjs",
"json": "json/index.json",
"wasm": "wasm/index.wasm"
}
}Something like that would help dual, triple, quadruple package modules that could include present and future of any format we could come up with. TL;DR why would |
This comment has been minimized.
This comment has been minimized.
|
@WebReflection sounds like you're asking for nodejs/modules#283 :-) |
This comment has been minimized.
This comment has been minimized.
This is outside the scope of this PR, but it’s under development in nodejs/modules#368. |
This comment has been minimized.
This comment has been minimized.
|
I don't think |
This comment has been minimized.
This comment has been minimized.
|
@ljharb @GeoffreyBooth thanks, not sure it's the same, but I'll have a look
what I've said has nothing to do with A dual module would like to point at both CJS and ESM, but if loaded via WASM (in the future) it could point at WASM too, whenever it'll get some module namespace. Having a |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure what you mean by "loaded as WASM" - wouldn't you expect that if the same package is reachable from JS and WASM, it would do the same thing / point to the same thing? In my head those boundaries between modules shouldn't care that either side is WASM or JS..? I would expect that if I have gone through the pains of shipping a binary AST format in the future, it would always be used even if the importing module happens to be written in plain JS. |
This comment has been minimized.
This comment has been minimized.
|
@WebReflection please open an issue in https://github.com/nodejs/modules if you don’t mind, this PR is just a documentation update |
This comment has been minimized.
This comment has been minimized.
if the bundler doesn't understand that, it can fallback. and so on and so forth, there are not just two kind of modules, as there was never just one kind, hence my comment. @GeoffreyBooth if you think it's needed, I will. Regaards |
Trott
force-pushed the
nodejs:master
branch
from
1ecc406
to
49cf67e
Sep 17, 2019
This comment has been minimized.
This comment has been minimized.
|
As ES Modules are |
This comment has been minimized.
This comment has been minimized.
|
Landed in 80cc6f5 |
GeoffreyBooth commentedSep 8, 2019
This updates the ECMAScript Modules docs with a few changes agreed in recent modules group meetings:
Per the 2019-06-19 meeting, we decided that we want to encourage all package authors to always include the
package.json"type"field, even for CommonJS packages (where"type": "commonjs"is implied).Per the 2019-08-28 meeting, we decided that the docs needed more discussion of packages and specifically what options are available for package authors wishing to support both CommonJS and ESM consumers of packages, and both current and older versions of Node.
Regarding the latter, this PR is just a first step; it will need expansion if/when #29494 is merged in, and possibly again later if more improvements are made to better support different module systems or Node runtime versions. For now, though, I think this text is an improvement on the very minimal mention that dual CommonJS/ESM support in packages has currently.
Checklist
//cc @nodejs/modules-active-members