public function addPackage($name, $location = null, $main = null)
    {
        $name = (string)$name;

        if ($name == '') {
            throw new exception\InvalidArgumentException('The require.js package name must not be empty');
        }

        if (!$location && !$main) {
            $this->packages[$name] = $name;
            return $this;
        }

        $this->packages[$name] = [
            'name' => $name,
        ];

        if ($location) {
            $this->packages[$name]['location'] = (string)$location;
        }

        if ($main) {
            $this->packages[$name]['main'] = (string)$main;
        }

        return $this;
    }