First law of thermodynamics is a work-energy balance equation. If we state it loud, it would sound like this:
“All $\mathrm{δ}Q$ amount of heat that we add to a system and do not end up to be used to perform a $\mathrm{δ}W$ amount of work, will be stored in that system as a $\mathrm{d}U$ increase in its internal energy”. Writing this down mathematically
$$δQ=dU+δW \tag{1}$$
This equation is always true independently of the sign convention for the thermodynamic work. Rearranging (1)
$$dU= δQ –δW= δQ +(–δW) \tag{2}$$
In mechanics, work as been defined as
$$dW \equiv F \cdot \mathbf{d}x \tag{3}$$
Considering that
$$p=\frac{F}{A} \Longrightarrow F=pA \tag{4}$$
Substituting (4) in (3), taking into account that $\mathrm{d}V=A \mathrm{d}x$
$$dW=p \mathrm{d}V \tag{5}$$
From the 2 equalities in (2) we realize that work in thermodynamics can be defined in 2 ways without violating the statement of first law:
$$\begin{equation}
\begin{cases}
dW_T = dW=p \mathrm{d}V & \, (Work) \\
dU= δQ–δW_T & \, (First \, law)
\end{cases}
\tag{Option 1}
\end{equation}$$
Or
$$\begin{equation}
\begin{cases}
dW_T = –dW=-p \mathrm{d}V & \, (Work) \\
dU= δQ +δW_T & \, (First \, law)
\end{cases}
\tag{Option 2}
\end{equation}$$
In option 1) expansion work (work done by the system) is positive since $V_2 >V_1, δW >0$ and compression work (work done into the system) is negative. The reverse happens in option 2).
Option 1) is the so called Clausius notation and has the advantage of giving a direct relation between mechanical and thermodynamic work. Option 2) is the new notation proposed by IUPAC, and has the advantage of depicting all net energy going out of the system as negative, just like in any balance sheet.
There is nothing wrong with any of the 2 choices, as long as you keep it the same throughout you book or paper.