Skip to content

Strange Error on addLocaleData #249

Closed

Description

@smad

Hi,
When i run my universal react project, the console show me this warning :

 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 [0]  @ ./~/react-intl/dist/locale-data/fr.js 1:529-536

In my code :

import * as ReactIntl from 'react-intl';
import frLocale from 'react-intl/dist/locale-data/fr.js';
ReactIntl.addLocaleData(frLocale);

The project is working. I'm using the react-intl V2.
Is this someone has the same problem ?

Activity

  1. ericf commented on Dec 17, 2015

    @ericf
    Collaborator

    What's your build system? What's throwing this warning?

  2. smad commented on Dec 17, 2015

    @smad
    Author

    I'm using node 4.2 on mac O, react 0.14.2 and the warning is on the console

    image

  3. ericf commented on Dec 17, 2015

    @ericf
    Collaborator

    You'll have to provide details about the build system that bundling the code.

  4. lapponiandevil commented on Dec 23, 2015

    @lapponiandevil

    Hi guys!

    I'm running into the same warning but my build doesn't go through because of something related to this. It seems to me that the error is fired when Webpack is trying to resolve the dependency from the file's folder, after not finding what it needs in the modules path. Note the extra "/js" at the end of the path.

    https://webpack.github.io/docs/resolving.html

    I am also running on OS X with node 5.1.0, npm 3.3.12 and Webpack 1.12.9.
    Is this a Webpack issue?

    WARNING in ./~/react-intl/dist/locale-data/en.js
    Critical dependencies:
    1:529-536 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
     @ ./~/react-intl/dist/locale-data/en.js 1:529-536
    
    ERROR in ./js/frontpage.js
    Module not found: Error: Cannot resolve module 'react-intl/locale-data/en' in /Users/path/to/project/js
    resolve module react-intl/locale-data/en in /Users/path/to/project/js
      looking for modules in /Users/path/to/project/node_modules
        resolve 'file' or 'directory' locale-data/en in /Users/path/to/project/node_modules/react-intl
          resolve file
            /Users/path/to/project/node_modules/react-intl/locale-data/en doesn't exist
            /Users/path/to/project/node_modules/react-intl/locale-data/en.webpack.js doesn't exist
            /Users/path/to/project/node_modules/react-intl/locale-data/en.web.js doesn't exist
            /Users/path/to/project/node_modules/react-intl/locale-data/en.js doesn't exist
            /Users/path/to/project/node_modules/react-intl/locale-data/en.json doesn't exist
          resolve directory
            /Users/path/to/project/node_modules/react-intl/locale-data/en doesn't exist (directory default file)
            /Users/path/to/project/node_modules/react-intl/locale-data/en/package.json doesn't exist (directory description file)
    [/Users/path/to/project/node_modules/react-intl/locale-data/en]
    [/Users/path/to/project/node_modules/react-intl/locale-data/en.webpack.js]
    [/Users/path/to/project/node_modules/react-intl/locale-data/en.web.js]
    [/Users/path/to/project/node_modules/react-intl/locale-data/en.js]
    [/Users/path/to/project/node_modules/react-intl/locale-data/en.json]
     @ ./js/frontpage.js 19:10-46
    

    This is a pick from my package.json

    ...
    "dependencies": {
        "babel-core": "^6.3.26",
        "babel-loader": "^6.2.0",
        "babel-plugin-react-intl": "^2.0.0",
        "babel-preset-es2015": "^6.3.13",
        "babel-preset-react": "^6.3.13",
        "babel-preset-stage-0": "^6.3.13",
        ...
        "react": "^0.14.3",
        "react-addons-linked-state-mixin": "^0.14.3",
        "react-addons-update": "^0.14.3",
        "react-dom": "^0.14.3",
        "react-intl": "^2.0.0-beta-2",
      },
    ...
    
  5. ericf commented on Dec 24, 2015

    @ericf
    Collaborator

    I would recommend importing/requiring: "react-intl/lib/locale-data/fr" or the ES6 module at: "react-intl/src/locale-data/fr". This will likely get rid of the Webpack warning. If it doesn't, please reopen this issue.

  6. Eyesonly88 commented on Jan 7, 2016

    @Eyesonly88

    Hi, I've hit this as well and the solution for me was what @ericf mentioned. However, I had to import the ones from lib.
    If I import the ones from dist then I get the warning like so:

    WARNING in ./~/react-intl/dist/locale-data/en.js
    Critical dependencies:
    1:529-536 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
     @ ./~/react-intl/dist/locale-data/en.js 1:529-536
    
    WARNING in ./~/react-intl/dist/locale-data/ar.js
    Critical dependencies:
    1:529-536 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
     @ ./~/react-intl/dist/locale-data/ar.js 1:529-536
    

    And if I import the ones from src then I get a parse error like so:

    You may need an appropriate loader to handle this file type.
    | // GENERATED FILE
    ....
    

    So yes, importing the ones from lib seems to get rid of the warning. Thanks.

  7. ericf commented on Jan 7, 2016

    @ericf
    Collaborator

    @Eyesonly88 Yeah, I think I'll have to change main in the package.json to be ./lib/index.js for the modules locale data modules to resolve via react-intl/locale-data/en, etc.

  8. ericf commented on Jan 13, 2016

    @ericf
    Collaborator

    I made some changes to the package layout and locale-data/ modules in #282. I wonder if this fixes these issues.

  9. export-mike commented on Feb 9, 2016

    @export-mike

    Hi I'm using 2.0.0-beta-2 and getting the same errors reported by: @Eyesonly88

  10. turboza commented on Feb 12, 2016

    @turboza

    @export-mike I am using version 2.0.0-beta-2 with babel 6 and I could make it works now by importing like this.

    import { IntlProvider, addLocaleData } from 'react-intl';
    import th from 'react-intl/lib/locale-data/th'
    
  11. export-mike commented on Feb 12, 2016

    @export-mike

    @turboza 👍 thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions