Skip to content
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

Deprecation warning triggered on parsing morgan #812

Open
rchl opened this issue Jun 4, 2019 · 3 comments
Open

Deprecation warning triggered on parsing morgan #812

rchl opened this issue Jun 4, 2019 · 3 comments

Comments

@rchl
Copy link

rchl commented Jun 4, 2019

  • esm 3.2.25

Importing morgan package triggers deprecation warning due to accessing the default property of morgan import.

That property is marked as deprecated in morgan with this code:

var deprecate = require('depd')('morgan')
// ...
deprecate.property(morgan, 'default', 'default format: use combined format')

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

@borisding
Copy link

I believe it's related to this reported issue:

expressjs/morgan#190

@rchl
Copy link
Author

rchl commented Jun 4, 2019

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?

@mbrowne
Copy link

mbrowne commented Aug 16, 2019

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants