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

IntlRelativeFormat not working in npm build of react-intl@next #166

Closed
wuzzeb opened this issue Sep 15, 2015 · 4 comments
Closed

IntlRelativeFormat not working in npm build of react-intl@next #166

wuzzeb opened this issue Sep 15, 2015 · 4 comments
Labels

Comments

@wuzzeb
Copy link

wuzzeb commented Sep 15, 2015

Steps to see the bug:

npm install react-intl@next

Use a simple html file such as

<html>
  <head>
    <script src="node_modules/react/dist/react.js"></script>
    <script src="node_modules/react-intl/dist/react-intl.js"></script>
  </head>
  <body>
    <p>Hello world!</p>
  </body>
</html>

Disable javascript source maps (I use chrome, it is in the settings). Then place a breakpoint on line 2787 in react-intl.js. The relavent lines are

var _intlMessageformat = require(5);

var _intlMessageformat2 = _interopRequireDefault(_intlMessageformat);

var _intlRelativeformat = require(14);

var _intlRelativeformat2 = _interopRequireDefault(_intlRelativeformat);

where the last line is line number 2787. When the breakpoint pauses at the last line, use the console to see that _intlMessageFormat and _intlRelativeFormat are identical and both equal to the MessageFormat class. Somehow, the require(14) call is pulling in the MessageFormat class instead of the RelativeFormat. Looking at react-intl.js, the RelativeFormat class seems to be in 15, not 14. Since _intlRelativeformat variable contains MessageFormat, I get an error later when using the FormattedRelative element. In particular, the MessageFormat class is passed the locale as the message to translate and an empty object for the locales.

Looks like some bug in browserfy during the dist step? I looked through the source code and it seems that it imports intl-relativeformat correctly.

@ericf
Copy link
Collaborator

ericf commented Sep 15, 2015

What version of Browserify are you using, this is a known Browserify bug, if you update to the latest it should go away. Reopen if that doesn't fix it.

@ericf ericf closed this as completed Sep 15, 2015
@wuzzeb
Copy link
Author

wuzzeb commented Sep 15, 2015

I wasn't using browserfy at all, it was exactly the file uploaded to npm, so whoever built and uploaded the package to npm will need to update browserfy. For now I can rebuild using the latest browserfy.

@ericf ericf added bug and removed duplicate labels Sep 16, 2015
@ericf ericf reopened this Sep 16, 2015
@ericf
Copy link
Collaborator

ericf commented Sep 16, 2015

Okay I see the issue now…

@ericf
Copy link
Collaborator

ericf commented Sep 16, 2015

I traced this down to the bundle-collapser Browserify plugin not working correctly.

ericf added a commit to ericf/react-intl that referenced this issue Sep 16, 2015
@ericf ericf closed this as completed Sep 16, 2015
longlho pushed a commit that referenced this issue Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants