-
Notifications
You must be signed in to change notification settings - Fork 669
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
Remove vue-server-renderer as a peer dependency #440
Comments
Seems reasonable to me. |
@timoschwarzer A temporary workaround is to add this to your webpack config: {
node: {
fs: 'empty',
module: 'empty'
}
} See webpack-contrib/css-loader#447 This isn't a great solution, and we shouldn't force users to add extra config. My suggestion of checking the package ourselves won't solve this problem. We could split vue-test-utils into two packages, vue-test-utils and vue-test-utils-server 🤔 |
I thought about this a bit more. Is there any merit to removing/splitting? |
It would mean people could bundle with webpack without having to add extra config, and it would solve the peer dependency issue |
Can't people bundle with webpack either way? Maybe I don't fully understand this part. Considering both packages are maintained by the Vue core team, is it so bad to have a peer dependency? I understand it's better not to have them, though. |
vue-server-renderer uses node modules, like path and fs. To bundle these with webpack and run in node you need to add If you want to bundle to run tests in the browser (like with karma), you need to tell webpack not to bundle the native node modules vue-server-renderer uses (like path and fs). This extra config makes it more difficult to set up webpack to compile tests for either node or the browser. I don't think Instead, we could turn vue-test-utils into a monorepo that generates two packages. That way, most users can carry on bundling their tests with webpack, without additional config. Any users who want to test SSR could download |
Ok, I understand now. Thanks for that explanation. In light of this, your proposal seems best. |
I'm working on converting the repo into a monorepo this week. I'd appreciate feedback on the structure once I've finished 😄 EDIT: WIP—#447 |
To fix both issues with webpack you need to set both fs and module empty in your webpack config:
|
Thanks for pointing this out 😛 |
Even when you include vue-server-renderer and EDIT:
|
@kdocki It's been split into seperate packages. We'll release soon |
I am getting these errors. Are they related?
|
This has been removed in beta-13.
|
@eddyerburgh do I need the server-test-utils if I dont do snapshot/dont use Jest? |
No, server-test-utils is only useful for testing SSR code. |
Yeah! Finally, thanks @eddyerburgh and your team |
If like me you want This is how I got it to work: Move all the SSR code into something like That way webpack will ignore the SSR stuff. |
Thanks,it works |
What problem does this feature solve?
renderToString was added in beta.12 , which uses vue-server-renderer.
I don't expect many users will call this method, as it's intended use is for testing server side code. Adding it as a peer dependency will warn users that they need to install it, even though they probably won't use the
renderToString
method.What does the proposed API look like?
@vue/test-utils
, and@vue/server-test-utils
.@vue/test-utils
will expose mount and shallow,@vue/server-test-utils
will exposerenderToString
.The text was updated successfully, but these errors were encountered: