# Build files

Source: https://signy.dev/documentation/1/overview/build-files/

Every file in the package's `dist` folder, and when to load it.

## Which file to use

- With a bundler, import `signy` or one of its [entry points](https://signy.dev/documentation/1/overview/installation/index.html.md#entry-points). The bundler picks the files.
- With a script tag, load `signy.global.js` while you develop and `signy.global.prod.js` in production.
- For browsers without ES2022, use the `es2017` or `es5` file of the same build.

## Script tag builds

Each one defines a global on `window`. The dev build logs warnings. The `.prod.js` build is minified and leaves the dev checks out.

| Dev build | Production build | Global | Contents |
| --- | --- | --- | --- |
| `signy.global.js` | `signy.global.prod.js` | `Signy` | Everything, router and store included |
| `signy.global.es2017.js` | `signy.global.es2017.prod.js` | `Signy` | Everything, as ES2017 |
| `signy.global.es5.js` | `signy.global.es5.prod.js` | `Signy` | Everything, as ES5 |
| `signy.web.global.js` | `signy.web.global.prod.js` | `Signy` | Like `signy/web`, no router and no `application()` |
| `signy.core.global.js` | `signy.core.global.prod.js` | `Signy` | Like `signy/core`, no DOM |
| `signy.store.global.js` | `signy.store.global.prod.js` | `SignyStore` | Like `signy/store`, load it after one of the builds above |

Load one of the `Signy` builds per page. They each carry the runtime, and two copies do not share signals. For the router, load `signy.global.js`.

## The store build

`signy.store.global.js` has no runtime of its own. It uses the one on `Signy`, so a store write reaches the effects of the page. Load it after the core, web or full build. Loaded first, it throws an error that names the build it needs.

```html
<script src="https://cdn.jsdelivr.net/npm/signy@1/dist/signy.core.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/signy@1/dist/signy.store.global.prod.js"></script>
<script>
  const { effect } = Signy;
  const { store } = SignyStore;
</script>
```

## ES module builds

These import `htm` by its package name, so they need a bundler, or an import map that maps `htm`.

| File | Dev checks | Contents |
| --- | --- | --- |
| `signy.js`, `chunk-*.js` and the `core`, `web`, `app`, `router`, `store` and `jsx` folders | Off when `process.env.NODE_ENV` is `'production'` | The npm entry points, with TypeScript types. They share chunks, so every entry point uses one runtime. |
| `signy.min.js` | Off | Everything in one minified file |
| `signy.es2017.js` | On | Everything, as ES2017 |
| `signy.es2017.min.js` | Off | Everything, as ES2017, minified |
| `signy.es5.js` | On | Everything, as ES5 code inside `import` and `export` |
| `signy.es5.min.js` | Off | Everything, as ES5, minified |

Every file except the ES5 ones has a `.map` source map next to it.
