# galactus

> Prunes dependencies from your package

Latest version **2.0.2** (published 2025-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install galactus
pnpm add galactus
yarn add galactus
bun add galactus
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2025-07-14 |
| First published | 2018-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.12.0 |
| Dependencies | 2 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Samuel Attard |
| Maintainers | marshallofsound |
| Keywords | prune, production |

## Links

- npm: https://www.npmjs.com/package/galactus
- Repository: https://github.com/MarshallOfSound/galactus
- Homepage: https://github.com/MarshallOfSound/galactus#readme
- Issues: https://github.com/MarshallOfSound/galactus/issues
- npm.io page: https://npm.io/package/galactus

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.4.1
- [flora-colossus](https://npm.io/package/flora-colossus.md) ^3.0.2

## Recent versions

- 2.0.2 (latest) — 2025-07-14
- 1.0.0 — 2022-11-04
- 0.2.1 — 2018-04-08
- 0.2.0 — 2018-03-24
- 0.1.0 — 2018-02-27
- 0.0.1 — 2018-01-02

## README

Galactus
-----------

> A JS implementation of `prune --production`

## Installation

```bash
npm i --save-dev galactus
```

## API

### Class: `DestroyerOfModules`

```js
import { DestroyerOfModules } from 'galactus';

// modulePath is the root folder of your module
const destroyer = new DestroyerOfModules({
  rootDirectory: __dirname,
  // Optionally provide your own walker from 'flora-colossus'
  walker: myWalker,
  // Optionally provide a method to override the default
  // keep or destroy test
  shouldKeepModuleTest: (module, isDepDep) => true,
});
```

#### `destroyer.destroy()`

Returns a `Promise` that resolves once the destruction is complete. By default
it will destroy all dependencies that aren't required for production or
optional dependencies. You can override this behavior by providing a
`shouldKeepModuleTest` function in the constructor.

#### `destroyer.collectKeptModules()`

Returns a `Promise` of a `ModuleMap` (a `Map` of paths to `Module`s). The
`Promise` resolves when the walker finishes walking the module tree. The
`ModuleMap` only contains the `Module`s that would be kept by a call
to `destroy()`.

There is one optional keyword argument, `relativePaths`. By default, the paths
in the `ModuleMap` are absolute. If `relativePaths` is `true`, they are relative
to the `rootDirectory` specified in the constructor.

---
_Source: https://npm.io/package/galactus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
