You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- link the screenshots in `readme.md`
- fix the jumping window width issue of `option.html` when it is opened up in popup mode, while also being compatible with mobile view (occupying all available width), and desktop view (occupying just enough width)
- forgot to make the open-source links in `option.html` actually open up a new tab
- the "download" button now always blinks red when clicked on, since we have yet to implement that feature
- bump patch version to `v0.1.1`
@@ -46,6 +53,26 @@ all in all, that will lead to a highly coupled codebase, and it'll be incredibly
46
53
47
54
## The Deno build process
48
55
56
+
### Building it yourself
57
+
58
+
to build this yourself, make sure that you first have [`Deno`](https://deno.com/) installed. then, in your terminal (or cmd), run:
59
+
```shell
60
+
deno task build-all
61
+
```
62
+
and you should get an unpacked distribution of the extension in the [`/dist/github_aid_ts-v*`](./dist/github_aid_ts-v0.1.0/) directory.
63
+
64
+
other available commands (tasks):
65
+
| command | general description |
66
+
|---------|---------------------|
67
+
|`deno task clean`| delete the [`/dist/`](./dist/) folder |
68
+
|`deno task clean --js-only`| delete only the javascript files under the [`/dist/`](./dist/) folder |
69
+
|`deno task build-1`| copy all non-typescript source files to the [`/dist/`](./dist/) folder |
70
+
|`deno task build-2`| bundle endpoint typescript files inside of [`/src/`](./src/),<br>and mirror the resulting javascript files to the [`/dist/`](./dist/) folder |
71
+
| add an additional `--log-only` <br> flag to any of the commands above | execute the task without actually writing or deleting any files |
### what is code-splitting, and how does it differ from regular bundling?
167
+
### What is Code-Splitting, and how does it differ from regular bundling?
141
168
suppose you have a total of 5 source code files (`A`, `B`, `C`, `D`, and `E`), with the following dependency graph:
142
169
```mermaid
143
170
---
@@ -178,7 +205,7 @@ this is where a potential problem can occur: if there was a runtime-unique share
178
205
a few examples of runtime-unique shared pieces of code would be:
179
206
- a javascript `Symbol`. both `bundleA` and `bundleB` will define the symbol separately, thereby becoming incompatible
180
207
- mutative side-effects inside of `D`. if, for instance, `D.injectButton` was a function that would inject a button into your html and then set a `D.button_injected = true` flag inside so that duplicates of buttons are not made in future calls.
181
-
If both `bundleA` and `bundleB` call `D.injectButton` several times, then we'd get two buttons instead of one, because now, the flags are defined independently.
208
+
If both `bundleA` and `bundleB` call `D.injectButton` several times, then we'd get two buttons instead of one, because now, the flags are defined independently. <br>
182
209
had we imported from `D` instead of bundling, we would've expected to see a single injected button.
183
210
184
211
if we bundle with code-splitting enabled, we would get the following output dependency graph, and our runtime-unique shared pieces of code will interoperate correctly:
@@ -206,10 +233,10 @@ flowchart
206
233
207
234
bundling with code-splitting also comes with the advantage of smaller total output file size.
208
235
209
-
### caveates, specifically with browser-extensions development
236
+
### Caveates of Code-Splitting specific to browser-extensions development
210
237
211
238
first, you need to know that the extension is supposed to be a single javascript file that is executed after your designated injection-target website has loaded (this being "github.com" for this extension). <br>
212
-
the javascript file to be ran is specified in the manifest file ([`/src/manifest.json`](/src/manifest.json)), under `manifest["content_scripts"][0]["js"][0]`. <br>
239
+
the javascript file to be ran is specified in the manifest file ([`/src/manifest.json`](./src/manifest.json)), under `manifest["content_scripts"][0]["js"][0]`. <br>
213
240
the global context available to this javascript of yours is simply the same as the one available to the target webpage (i.e. you are in the `window` environment), in addition to having a limitied number of browser-extension features, such as: `chrome.storage` and `chrome.runtime` (or in the case of firefox: `browser.storage` and `browser.runtime`). <br>
214
241
moreover, by web-security design, you cannot do static imports in any content_script (so `import {x, y, z} from "./abc.js"` is disallowed). <br>
215
242
however, you *can* dynamically import using `const {x, y, z} = await import("./abc.js")`, but it **will** require that the target webpage has access to that imported file, which it currently doesn't, because the file sits locally in your browser. <br>
@@ -232,10 +259,10 @@ here's how it should look: <br>
232
259
// ...
233
260
}
234
261
```
235
-
with that, you've solved the problem that you initiated, and made your extension less secure in doing so. <br>
236
-
alternatively you can choose to bundle without code-splitting, and avoid all of this fuss. but where's the fun in that? <br>
262
+
with that, you've solved the problem that you initiated, and made your extension less secure along the way. <br>
263
+
alternatively you can choose to bundle without code-splitting, and avoid all the fuss. but where's the fun in that? <br>
237
264
see this [stackexchange answer](https://stackoverflow.com/a/53033388), where I found this information from. <br>
238
-
also see [`/src/js/content_script.ts`](/src/js/content_script.ts#L32-35) for the dynamic imports being done in this extension.
265
+
also see [`/src/js/content_script.ts`](./src/js/content_script.ts#L32-L35) for the dynamic imports being done in this extension.
0 commit comments