> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/rollup.md).

# Rollup

> **Applies to:** applications and libraries bundled directly with Rollup. Vite uses Rollup for production builds; see [Vite](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/vite.md).

## Step 1: Source maps <a href="#source-maps" id="source-maps"></a>

```js
// rollup.config.mjs
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';

export default {
  input: 'src/main.js',
  output: {
    dir: 'dist',
    format: 'es',        // or 'iife' for a single classic script
    sourcemap: true,     // or 'hidden'
  },
  plugins: [resolve(), terser()],
};
```

Every plugin that transforms code (TypeScript, Babel, terser) must pass source maps through; most do by default. Check with `dryRun` that methods resolve to `src/...`.

## Step 2: Build, scan and instrument <a href="#scan" id="scan"></a>

```bash
printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npx rollup -c

npx slnodejs config --tokenFile sltoken.txt --appName my-web-app \
  --branchName "$BRANCH_NAME" --buildName "$BUILD_NUMBER"
npx slnodejs scan --tokenFile sltoken.txt --buildSessionIdFile buildSessionId \
  --scanDir dist --scmType git --es6Modules \
  --instrumentForBrowsers --outputPath sl_dist \
  --labId qa-env --excludeSourceMapFiles skipCopy
```

* `format: 'es'`: keep `--es6Modules`. `format: 'iife'` or `'umd'`: remove it.
* Output with `.cjs` extensions is not scanned by default; set `SL_fileExtensions=.js,.mjs,.cjs`.

## Libraries used by other applications <a href="#libraries" id="libraries"></a>

A shared component library bundled with Rollup and loaded by several applications can be:

* **its own build** (its own `config` and `scan`, instrumented copy published to the test environment), when it is deployed separately, for example as a micro-frontend or a CDN script; see [Micro-frontends](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/micro-frontends.md);
* **part of each application's bundle**, when the applications import it from `node_modules`. It is then covered only if its source maps reach the application's bundle and it is not excluded by `.slignore.instrument`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/rollup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
