-
-
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
add browsers field #288
add browsers field #288
Conversation
I am not sure why adding "browser" field breaks the tests. I thought it was some dependency update, but then the following PR passed... Does it pass when you run them locally? Is it maybe breaking browserify? |
It seems like it breaks the bundle creation indeed: Works: https://travis-ci.org/epoberezkin/ajv/jobs/155026726#L2271 See https://github.com/substack/node-browserify#browser-field |
It correct that browserify uses the I'll try to run the tests locally. I could use a |
Tests run locally when using |
If you want to use the bundle it can be just loaded separately. You can either use browserify to create this bundle (that's what is used here) or you can bundle Ajv as part of your application, in which case you just use I am not sure I understand what would be your code to use Ajv if you include the bundle rather than the index file - the bundle doesn't return the Ajv constructor as far as I understand. Would you just use global that the bundle exposes? In which case I don't think I understand why you need webpack at all if you use the bundle. And if you are going to use as above I don't think it would work. |
Isnt the bundle a UMD file? Than it would return the constructor. It must be that way as I can use Ajv just fine with the bundled file. "why you need webpack at all if you use the bundle" Well, I use the bundled file of Ajv, but my application has a lot of other dependencies and my own source code which wants to be bundled, too. Right? ;) And why would I want a prebundled file of one my dependencies? Well, to get rid of all the warnings from requires in try/catch-blocks for optional dependencies :) |
Got it. Thank you! |
Thank you! |
In 4.6.0 |
Webpack still complains
Seems like the best way to solve this is just to pass these dependencies in via the options. |
Interesting. I don't get this warning. But it is a different warning and it is just one, not three. Hmm... |
Is it possible instead to add IgnorePlugin to package.json somehow? Or add some other file that webpack would take into account and would use the plugin? I am not a webpack user, just thinking about what could work. |
Wouldn't the better solution be to simply add to docs the instruction to use IgnorePlugin (see #117 (comment))? |
In which case users who use any of those packages could also have them included by changing the regexp? |
I think that at least for now there should be some documentation. I am not using the async features in my app so my workaround is to new webpack.IgnorePlugin(/^regenerator|nodent|js\-beautify$/, /ajv/), I think that the choice of whether to include nodent or regenerator on the frontend is not one that should be hidden to the user because they are pretty large. I almost abandoned using Ajv on the frontend (after using it on my backend) because I thought I need to add another ~300kb (uncompressed) to my bundle. I would propose the following to sidestep this problem all together: import Ajv from 'ajv';
import regenerator from 'regenerator';
const ajv = new Ajv({ regenerator }); This would simplify the configuration over using Anyway that's my 2 cents. Sorry if this is off topic to this pull request. |
I'd like to not include framework specific configuration to my webpack configuration. I share between a lot of (compex) projects and so far it works without specific configurations. I thought the @sokra Is there a way to rewrite this line so it is ignored by webpack, but usable by browserify? (Sorry, for pinging you directly.) |
Use the |
So what is the correct configuration to avoid |
In our case we did:
And it seems to be working fine. From my understanding, ajv wants us to use |
This is a real fix for #117 to prevent webpack build warnings. Webpack will automatically use the browser build (see https://webpack.github.io/docs/configuration.html#resolve-packagemains).