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

extractReactIntl named export is overwritten #58

Closed
gautier-lefebvre opened this issue Nov 1, 2019 · 1 comment
Closed

extractReactIntl named export is overwritten #58

gautier-lefebvre opened this issue Nov 1, 2019 · 1 comment

Comments

@gautier-lefebvre
Copy link

  • version: 2.3.3
  • node version: 10.16.0
  • npm (or yarn) version: yarn 1.19.1

Do you want to request a feature or report a bug?:
Report a bug

What is the current behavior?:

const { extractReactIntl } = require('extract-react-intl-messages');
// extractReactIntl is undefined

What is the expected behavior?:
The symbol is exported from the module, so I want to be able to import it.

Suggested solution:

In index.ts, at line 67, you do

export const extractReactIntl = _extractReactIntl

But at line 138 you write this

module.exports = extractMessage

For CommonJS, line 67 is transpiled to exports.extractReactIntl = _extractReactIntl, so at line 138 you overwrite completely exports.

Easiest fix, since you want to be able to use require without .default, would be simply to assign extractReactIntl as a property of extractMessage:

extractMessage.extractReactIntl = _extractReactIntl

export default extractMessage

// For CommonJS default export support
module.exports = extractMessage
module.exports.default = extractMessage

This way you don't change your API (but on the other hand you always get extractReactIntl when you import default, which is not problematic given that this module is not meant to be used in a tree-shaking context).

@akameco
Copy link
Owner

akameco commented Nov 30, 2019

@gautier-lefebvre Thank you 👍

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

No branches or pull requests

2 participants