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

webpack pre-built javascript warning #477

Closed
AnthonyACE opened this issue Dec 22, 2015 · 7 comments · Fixed by #564
Closed

webpack pre-built javascript warning #477

AnthonyACE opened this issue Dec 22, 2015 · 7 comments · Fixed by #564

Comments

@AnthonyACE
Copy link

When I use webpack to bundle, it complaint something like this.

WARNING in ./~/i18next/bin/index.js
Critical dependencies:
1:409-416 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.
 @ ./~/i18next/bin/index.js 1:409-416

To clear this warning, I need to change the package.json file.

"main": "./lib/index.js",

or import 'i18next' from 'i18next/lib/index.js.
I`m not sure this warning need to optimize.
Thanks for your time.

@AnthonyACE
Copy link
Author

btw, i18next-xhr-backend and i18next-localStorage-cache have the same warning message.

@jamuhl
Copy link
Member

jamuhl commented Dec 22, 2015

yes...we use the files from /lib folder.

i already thought about adding: "browser": "./lib/index.js" to package.json -> but that would specifiy to use that file on clientside which just is not true...the files in lib folder are only useful if using a build chain like webpack or browserify (on the other hand i don't know any framework using the browser field on package.json not doing a own build).

best would be having a flag on the file to toggle of the warning ;)

so any idea, optimization would be welcome.

@dannydorfel
Copy link

👍

@tquetano-r7
Copy link

So the solution I used is to alias it in your webpack config to point to index.js:

module.exports = {
   ... other config stuff
   resolve: {
      alias: {
         i18next: 'i18next/lib/index.js'
      }
   }
};

Not ideal, but gets rid of the error and brings in the correct package.

@okmttdhr
Copy link

okmttdhr commented Feb 8, 2016

I used this solution too...
#477 (comment)

@just-boris
Copy link
Contributor

+1
This is not recommended approach for several reasons, one of them is that Uglify is very slow on already minified files.

@mathieumg
Copy link

Same issue here, it would be better if the main package field didn't point to an already minified file. What I see most libraries do is provide a separate minified UMD build for people that want to get up and running quickly, most of the time using script tags. In other scenarios, it makes little sense to concat & pre-minify the files and that part should rather be left to the user's pipeline, most likely using Browserify, Webpack or a similar tool.

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

Successfully merging a pull request may close this issue.

7 participants