-
Notifications
You must be signed in to change notification settings - Fork 134
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
Choosing a marker to customize default exports returned by require(esm)
#1622
Conversation
…urned by `require(esm)`"
@nodejs/tsc Friendly ping, there's still half of us who haven't cast a ballot. The vote should close by EOW so there's enough time to implement the winning proposal before the v23.x cutoff. |
Can we conclude this vote? |
I will try to vote tomorrow. Sorry for the long wait. |
Oops, started the workflow https://github.com/nodejs/TSC/actions/runs/11087086622/job/30805393578 before I saw #1622 (comment) |
(Although, apparently I didn't start it right, somehow. Maybe @aduh95 knows how to do it properly) |
Looks like there's a typo in the workflow file: #1624 However, to close the vote, we still need (at least) 3 secret holders to reveal their key part as indicated in the PR description:
Waiting for Paolo's vote SGTM (I'm also OK not waiting if the timing is too tight). |
I would like to close this vote, and for this effect, I'm revealing my key part:
|
I would like to close this vote, and for this effect, I'm revealing my key part:
|
I would like to close this vote, and for this effect, I'm revealing my key part:
|
Election resultsSubject: Choosing a marker to customize default exports returned by ResultsWinning candidate: Table of results
Voting dataParticipants:
Private key to decrypt ballots
Discarded commitsSome commits have not been taken into account when counting the ballots: [
{
"commitInfo": {
"sha": "f60348115185aaeeec8b14d30d82b8807ddee336",
"signatureStatus": "E",
"author": "James M Snell <[email protected]>",
"files": [
"votes/76d8966e-bd27-4e30-a13d-48200a34004a/jasnell"
]
},
"reason": "A more recent vote commit from this author has already been counted."
}
] Footnotes
|
Should it be merged by pushing the merge button or is there a workflow for it? |
When a user have an existing CommonJS package like this:
Now that
require(esm)
is possible and they can ship ESM to their CommonJS users without breaking them, they would try something like this:As you can see, for CommonJS consumers this will not be exactly equivalent. Since in ESM the default exports is a property of the name space, they need to access
.default
from the result returned byrequire(esm)
. So the idea is that Node.js can take a marker from package authors to directly customize whatrequire(esm)
returns in this case.To keep
const foo = require('foo')
working, the two proposed markers are:or
Further to this vote, there is a follow-on proposal to reuse this marker on namespaces representing CJS modules imported into ESM, where attaching this marker would effectively define a scheme for converting CJS into ESM that would retain full transitive interop semantics allowing arbitrary CJS to be converted into ESM as a non-breaking change.
Under this follow-on marking, when importing some CJS module
bar
into ESM:Users importing with
console.log(await import('bar'))
would obtain a namespace object either of the formModuleNamespace { __cjsUnwrapDefault: true, default: 'bar' }
orModuleNamespace { default: 'bar', 'module.exports': 'bar' }
depending on which option is chosen for this first PR.The vote should stay open for 7 days, or until all TSC voting members have cast a ballot.
Vote instructions:
To close the vote, at least 3 secret holder(s)1 must run the following command:
git node vote https://github.com/nodejs/TSC/pull/1622 --decrypt-key-part --post-comment
/cc @nodejs/tsc
Current estimated participation: 89.47%
Footnotes
secret holders are folks who have access to the private key associated with a public key on hkps://keys.openpgp.org that references an email address listed on the TSC voting member list at the time of the opening of the vote. ↩