I've found that when named and default exports are mixed, the helper function getDefaultExportFromNamespaceIfNotNamed doesn't work correctly, it's defined as:
function getDefaultExportFromNamespaceIfNotNamed (n) {
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
}
The spot I'm seeing this cause problems is with graceful-fs. It has an var constants = require('constants');, and then later on it does a check for constants.hasOwnProperty('O_SYMLINK'), which blows up because it's treating the import as a import * as constants, which doesn't have hasOwnProperty and thus blows up.
I'm not sure what the right approach is, other than maybe only exporting a default object? Does node.js support `import {ENETDOWN} from 'constants'?
I've found that when named and default exports are mixed, the helper function
getDefaultExportFromNamespaceIfNotNamed
doesn't work correctly, it's defined as:Which means that code being compiled would need to import the
default
key specifically. This is mentioned here as well: https://rollupjs.org/guide/en/#outputexports.The spot I'm seeing this cause problems is with
graceful-fs
. It has anvar constants = require('constants');
, and then later on it does a check forconstants.hasOwnProperty('O_SYMLINK')
, which blows up because it's treating the import as aimport * as constants
, which doesn't havehasOwnProperty
and thus blows up.I'm not sure what the right approach is, other than maybe only exporting a default object? Does node.js support `import {ENETDOWN} from 'constants'?