I have a Library A, having dependency on Library C version "X"
Library A also have dependency on Library B
Library B have dependency on Library C version "Y"
On using webpack for packaging library A, which version of Library C will be packaged? Will it both X and Y?
The logic sequence that will determine the answer of your question is dynamic, so it can depend on many factors. However, in general terms it goes as follows:
Your package manager (NPM, Yarn, etc.) will be the first subject to intervene. Dependency tree will be traversed and all modules will be distributed in different levels depending on how the relate, obviously also considering allowed versions per package. This step may already delete duplicated dependencies (even if two different versions are required in different places. If a common valid version is found, it will be used instead).
If no common valid version is found, then you'll have different versions of the same package in different levels of the tree (they will have the same names, but different paths), subsequently Webpack will treat them as different modules.
However, common dependencies of these now different modules, will be deduped depending on Webpack configuration.
Long story short, be sure that there are many layers of algorithms that work with the solely purpose of optimising your final bundle. Library C version "X" and Library C version "Y" will not be both present unless it is absolutely necessary and still common dependencies will not be repeated.