Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions injected/docs/adding-bundles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Adding a New Bundle

Bundles are how platforms integrate content-scope-scripts, they're often used within a context and so serve a distinct purpose. There is a cost to serving multiple bundles within the web page context so that should be avoided.

To add a new bundle to the Content Scope Scripts build system:

## 1. Define Build Configuration

**File**: `injected/scripts/entry-points.js`

Add your bundle to the `builds` object:

```js
'my-new-bundle': {
input: 'entry-points/my-entry.js',
output: ['../build/my-platform/myScript.js'],
},
```

## 2. Update TypeScript Types

**File**: `injected/src/globals.d.ts`

Add the bundle name to the `injectName` union type:

```ts
injectName?:
| 'firefox'
| 'apple'
| 'my-new-bundle' // Add here
```

## 3. Configure Platform Features (Optional)

**File**: `injected/src/features.js`

If creating a platform-specific bundle, add feature configuration:

```js
'my-platform': [
'cookie',
...baseFeatures,
'mySpecificFeature',
],
```

## Optional: 4. Create Entry Point

**Directory**: `injected/entry-points/`

Create your entry point file (e.g., `my-entry.js`) that imports and configures the required features for your bundle.

**Entry points** are the main files that define the implementation of a build. These should only be added if absolutely required.

## Remote configuration

Inject Name is a condition that can then be used in the config.

**Example**: Target specific bundles in feature configuration:

```json
{
"features": {
"myFeature": {
"state": "enabled",
"settings": {
"something": "hello",
"conditionalChanges": [
{
"condition": {
"injectName": "android-adsjs"
},
"patchSettings": [
{
"op": "replace",
"path": "/something",
"value": "else"
}
]
}
]
}
}
}
}
```

This allows the same feature to have different behavior depending on which bundle it's running in.
Loading