In 1940 , the town , along with the rest of Western Ukraine , became part of the Soviet Union ( see Molotov-Ribbentrop Pact ) . In 1939 , the town , along with the rest of western Ukraine , was invaded by the Soviet Union ( see Molotov-Ribbentrop Pact ) .