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
When using CommonJS syntax in Node 23, global data files are not loaded properly and results in the data being unavailable throughout the build.
This is because Module objects for modules using module.exports now contain two keys, 'default' and 'module.exports', and Eleventy specifically checks if there is only one before accessing the default property. Then it goes on to make sure the keys from 'default' and those in the top level are the same, which fails on the 'module.exports' key.
The text was updated successfully, but these errors were encountered:
Good point @zachleat! I actually don't know if it's here to stay, but it does kind of look like it from Node's ESM docs (see also the commit):
These CommonJS namespace objects also provide the default export as a 'module.exports' named export, in order to unambiguously indicate that their representation in CommonJS uses this value, and not the namespace value. This mirrors the semantics of the handling of the 'module.exports' export name in require(esm) interop support.
This not so much specifies whether it is a temporary change or not, but it does seem like Node's attempting to document it properly and has reasons for its existance (which, I'll be honest, I don't quite follow, but they're there).
Either way, given the fix for it seems rather unintrusive, I think it'd just be a nice-to-have for those on 23 (and potentially beyond) without bothering anyone on Node <23 (I highly doubt anyone's explicitly exporting a 'module.exports' key).
If you really are worried about this breaking things for users on lower Node versions, we can introduce an extra check against the Node version to make it a Node 23-only change.
Eleventy
3.0.0
Describe the bug
When using CommonJS syntax in Node 23, global data files are not loaded properly and results in the data being unavailable throughout the build.
This is because
Module
objects for modules usingmodule.exports
now contain two keys,'default'
and'module.exports'
, and Eleventy specifically checks if there is only one before accessing thedefault
property. Then it goes on to make sure the keys from'default'
and those in the top level are the same, which fails on the'module.exports'
key.The text was updated successfully, but these errors were encountered: