-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
Building with Webpack causes spurious warnings #117
Comments
If you are building with browserify it doesn't resolve this dependency at build-time (because there is an expression) and at a run-time it quietly fails if js-beautify is not available (it can be provided either as another bundle or included in ajv bundle by adding browserify CLI option). The reason for not including js-beautify in the bundle by default is the bundle size. It's unlikely one would need beautifying generated code in the browser, it's a debugging feature. It seems that webpack tries to include modules even if their names are expressions. It's interesting what would it do if it encounters You can of course resolve this issue by installing js-beautify so that webpack finds it. But you will also have to add nodent and regenerator that are required in a similar manner (they are used for asynchronous validation but one would never need both). So you'll end up with a large bundle full of things you don't need - 659Kb minified, while ajv itself is 109Kb (and I am thinking how to reduce it). I am happy to modify the code in some way so that webpack can understand that these dependencies are optional and have to be resolved at run-time. I've searched but I don't see any elegant way to achieve it while still being compatible with node and browserify. So until we find such a way, the workarounds are to use:
Any other ideas? |
By the way, does it fail to build or is it just a warning? If the latter, there should be a way to suppress warnings I hope. |
Hi @epoberezkin : Thanks for the response. How about moving the require statement into the opts.beautify check? I'm not sure if that would fix the issue (it wouldn't if Webpack is indeed resolving To answer your question, the build still passes, and is just a warning, but it pollutes the console with the aforementioned stack trace. Will report back in a bit. |
Moving the require into |
If they are just warnings you can either find some option in webpack to suppress the warning or you can |
Definitely don't want to go the route of hiding all warnings, as that will contain useful information for other modules. I'll try to find another way around this when I can. |
Any luck using this for browser via webpack? |
What is possible with webpack that is not possible with browserify? |
I managed to suppress errors with the following plugin added to Webpack configuration: new IgnorePlugin(/regenerator|nodent|js\-beautify/, /ajv/) |
@epoberezkin : AFAIK, browserify does not support code splitting, hot reloading or incremental builds. The latter two features completely change the game in terms of how productive you can be while writing javascript... @strax : thanks for the tip, will give it a shot |
@avindra: it seems like it does, with additional tools: https://gist.github.com/substack/68f8d502be42d5cd4942 |
@strax thanks! |
@strax, new IgnorePlugin(/regenerator|nodent|js-beautify/, /ajv/) worked for me. Thanks |
Thanks. Probably worth making a note in readme in Using in browser. |
Hi, just saw that the issue has been closed. I might have missed it but latest release still generate the webpack errors. I suggest to keep it open until the warnings are removed (the IgnorePlugin trick is just a temporary workaround) |
I don't think it is possible to resolve in any other way. Webpack doesn't support dynamic imports. Optional dependencies need to be dynamic. |
It is not acceptable solution because: |
It doesn't log warnings with IgnorePlugin, see above. Why using it is not an acceptable solution? If you know a better solution than to use IgnorePlugin, we can post it here. To me it seems the webpack's limitation that it doesn't support dynamic dependencies. If it turns out it does and there is a way to change code so it is still compatible with browserify and nodejs, we can change it. |
I believe the issue here is that the JavaScript community does not have a standard for loading modules dynamically. Webpack 2 will support |
@epoberezkin I am not talking about your library. But for example my library which is using your ajv library. I need to inform all my users about this problem because it looks like a bug in my library. I do not want to complain but you know it is ugly |
Resolved in 5.0.1-beta.0 |
5.0.1-beta.3 should resolve it, finally |
Hi there. I tried @strax's solution, but I'm still getting the three warnings. I ask because I am using What is the magic combination of words to ignore AJV webpack warnings without generating other errors? I apologize if this is not the right place, but I figure someone here might know the answer. Full question and fiddle on StackOverflow. |
I assume you mean #117 (comment)
As soon as it is changed in har-validator, request will use new version, there is nothing more to propagate. I expect 2-3 weeks at most. Warnings aren't critical as long as it all works. You can also lock request to 2.79.0 if it's a problem. |
@epoberezkin Downgrading works for me. Thanks! |
Hey, does anybody has an idea why those warnings break my build?
this is my webpack.config.js
I am using serverless webpack. |
import nodeExternals worked for me, i added this rows to my server.webpack.config: const CONTEXT = path.join( __dirname, "../.." ), export default [ |
It is being caused by this line:
https://github.com/epoberezkin/ajv/blob/3.5.0/lib/compile/index.js#L10
Is there a cleaner way to manage this dependency? Is
peerDependencies
built for this?Error stack below:
The text was updated successfully, but these errors were encountered: