Skip to content

Commit c3dc1d2

Browse files
committed
Document some more things re: feedback
1 parent ea0c26c commit c3dc1d2

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

src/content/docs/ext-dev/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The global types are available [here](https://github.com/moonlight-mod/moonlight
1313
- Contains patching and Webpack module information, the API level, localStorage, LunAST, moonmap
1414
- `moonlightNode`: available in the web *and* Node.js environments
1515
- Contains configuration details, browser checks
16+
- Polyfilled in the browser extension
1617
- `moonlightNodeSandboxed`: available in the Node.js environments (`node.ts`)
1718
- Contains filesystem APIs
1819
- `moonlightHost`: available in the host environment (`host.ts`)

src/content/docs/ext-dev/cookbook.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Extensions can load in three different environments:
2727
- On the Node.js side, where DiscordNative and such live: `node.ts`
2828
- On the host, with little sandboxing and access to Electron APIs: `host.ts`
2929

30+
These map to the renderer, preload script, and main process in Electron terminology. The term "browser" is used to refer to the moonlight browser extension, while "web" refers to both the desktop and browser platforms.
31+
3032
Most extensions only need to run code in the browser. Use the Node environment if you need access to system APIs, like the filesystem or creating processes. Use the Host environment if you need to use the Electron API.
3133

3234
Remember that [you cannot directly import Node.js modules](/ext-dev/pitfalls#web-vs-nodejs), and should [share code with `moonlight.getNatives`](#sharing-code-between-nodejs-and-the-web).

src/content/docs/ext-dev/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Now, change the branding of the extension:
104104
- `index.tsx`
105105
- `node.ts`
106106
- `webpackModules/entrypoint.ts`
107+
- `webpackModules/someLibrary.ts`
107108
- `env.d.ts` (located at the root folder)
108109

109110
### Build and run the extension

src/content/docs/ext-dev/webpack.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ export const webpackModules: ExtensionWebExports["webpackModules"] = {
148148
};
149149
```
150150

151+
If you want types for `import` statements, you can automatically generate them based off of the exports with a declaration file:
152+
153+
```ts title="env.d.ts"
154+
declare module "@moonlight-mod/wp/sampleExtension_someLibrary" {
155+
export * from "sampleExtension/webpackModules/someLibrary";
156+
}
157+
```
158+
151159
:::info
152160
When using `export default` or `export something` in a ESM Webpack module, you will need to do `require().default` or `require().something` to access it. You can also use `module.exports` from inside of the Webpack module, but it is not recommended.
153161
:::

0 commit comments

Comments
 (0)