# Building GoJS from TypeScript Sources

All customers can use the `go.js` and `go-debug.js` files or the corresponding ES module files to run their app. However, if you have purchased a license to the GoJS TypeScript source code, you can build your app from the TypeScript source. Popular module bundlers such as Webpack are able to remove a number of modules from the source, provided you are not using them, to shrink the size of the deliverable file.

Because the `go.js` and `go-debug.js` files are built in a custom process to reduce size, using Webpack or another bundler with the GoJS source, even though it removes unused modules, may result in a larger file size than just using `go.js`. However, programmers using TypeScript may appreciate the feedback and debugging capabilities of building from source.

## Classes/modules that can be removed when building from source

Several classes, such as `CommandHandler` and the Tools, may be essential to add to your project, while others such as all or all but one `Layout` and one type of `Model` can often be removed. Below is a list of modules that webpack can remove from builds, provided they are not referenced in your code:

- CommandHandler, used for keyboard functionality.
- `SVGSurface`, used by Diagram.makeSvg.
- GraphLinksModel, without loading this module, the default Diagram.model is of type `Model`.
- TreeModel
- Overview, for showing a thumbnail image of the whole document.
- Palette

Layouts:

- GridLayout
- TreeLayout
- LayeredDigraphLayout
- CircularLayout
- ForceDirectedLayout,

Mouse-down tools:

- ActionTool
- RelinkingTool
- LinkReshapingTool
- ResizingTool
- RotatingTool

Mouse-move tools:

- LinkingTool
- DraggingTool
- DragSelectingTool
- PanningTool

Mouse-up tools:

- ContextMenuTool
- TextEditingTool
- ClickCreatingTool
- ClickSelectingTool

There are several "built in" Panel types, each of which is a PanelLayout. Some of these are required for building the source:

- `PanelLayoutPosition`
- `PanelLayoutVertical`
- `PanelLayoutLink`
- `PanelLayoutAuto`
- `PanelLayoutGrid`

However, it is possible to build without the following panel types:

- `PanelLayoutHorizontal`
- `PanelLayoutSpot`
- `PanelLayoutTable`
- `PanelLayoutViewbox`
- `PanelLayoutTableRow`
- `PanelLayoutTableColumn`
- `PanelLayoutGraduated`

The source index files demonstrate the necessary calls to `Panel.addPanelLayout` to include each panel type.

## Using the optional classes

A typical GoJS project is not expected to remove all or even most of these modules, and may use the majority of them.

## Important license information about GoJS source code

The GoJS source code is subject to the terms of our license, contained in SoftwareLicenseAgreement.pdf.

Do not use, release (deploy), or distribute the unminified source code. To build GoJS for your own application you must use a popular obfuscation/minification tool.