Open rchl opened 5 years ago
I believe it's related to this reported issue:
It does indeed look the same. The question is only whether this is bug in esm or morgan...
It's true that morgan has default
property on exported object but is that something that can be distinguished from actual default exports?
I think this may very well be a bug in esm
...it's problematic for morgan to address this because the legacy API depends on exports.default
pointing to morgan's default format function (which returns a string) rather than the morgan function itself. The warning doesn't happen when using node's experimental-modules
flag so it seems like it should be possible for it to work without a warning in esm also, although that's just an educated guess.
Because the code for morgan does not contain the __esModule
flag, it seems like esm should be able to realize that exports.default
is not the default export of an ES6 module, but rather just a regular export of a CommonJS module that happens to be named default
. I took a quick look at the source code in this repo and I see that it is checking for __esModule
in a couple places, but maybe there's some additional place that check needs to be added...
Importing
morgan
package triggers deprecation warning due to accessing thedefault
property ofmorgan
import.That property is marked as deprecated in morgan with this code:
It seems that esm triggers deprecation warning on parsing.
Works without warning in 3.2.20. Version 3.2.21 is the first one that gives the warning.
Repro sandbox: https://codesandbox.io/s/esmpropertyaccessbug-8djiv