Skip to content

Commit a30e237

Browse files
Add some basic docs for bundles and entry points (#1969)
* Add some basic docs for bundles and entry points * Lint fix
1 parent 3ce385b commit a30e237

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

injected/docs/adding-bundles.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Adding a New Bundle
2+
3+
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.
4+
5+
To add a new bundle to the Content Scope Scripts build system:
6+
7+
## 1. Define Build Configuration
8+
9+
**File**: `injected/scripts/entry-points.js`
10+
11+
Add your bundle to the `builds` object:
12+
13+
```js
14+
'my-new-bundle': {
15+
input: 'entry-points/my-entry.js',
16+
output: ['../build/my-platform/myScript.js'],
17+
},
18+
```
19+
20+
## 2. Update TypeScript Types
21+
22+
**File**: `injected/src/globals.d.ts`
23+
24+
Add the bundle name to the `injectName` union type:
25+
26+
```ts
27+
injectName?:
28+
| 'firefox'
29+
| 'apple'
30+
| 'my-new-bundle' // Add here
31+
```
32+
33+
## 3. Configure Platform Features (Optional)
34+
35+
**File**: `injected/src/features.js`
36+
37+
If creating a platform-specific bundle, add feature configuration:
38+
39+
```js
40+
'my-platform': [
41+
'cookie',
42+
...baseFeatures,
43+
'mySpecificFeature',
44+
],
45+
```
46+
47+
## Optional: 4. Create Entry Point
48+
49+
**Directory**: `injected/entry-points/`
50+
51+
Create your entry point file (e.g., `my-entry.js`) that imports and configures the required features for your bundle.
52+
53+
**Entry points** are the main files that define the implementation of a build. These should only be added if absolutely required.
54+
55+
## Remote configuration
56+
57+
Inject Name is a condition that can then be used in the config.
58+
59+
**Example**: Target specific bundles in feature configuration:
60+
61+
```json
62+
{
63+
"features": {
64+
"myFeature": {
65+
"state": "enabled",
66+
"settings": {
67+
"something": "hello",
68+
"conditionalChanges": [
69+
{
70+
"condition": {
71+
"injectName": "android-adsjs"
72+
},
73+
"patchSettings": [
74+
{
75+
"op": "replace",
76+
"path": "/something",
77+
"value": "else"
78+
}
79+
]
80+
}
81+
]
82+
}
83+
}
84+
}
85+
}
86+
```
87+
88+
This allows the same feature to have different behavior depending on which bundle it's running in.

0 commit comments

Comments
 (0)