@macroforge/mcp-server 0.1.40 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/docs/BOOK.md +165 -0
- package/docs/api/api-overview.md +65 -46
- package/docs/api/expand-sync.md +88 -53
- package/docs/api/native-plugin.md +121 -71
- package/docs/api/position-mapper.md +114 -54
- package/docs/api/transform-sync.md +85 -59
- package/docs/builtin-macros/clone.md +0 -20
- package/docs/builtin-macros/debug.md +0 -23
- package/docs/builtin-macros/default.md +1 -40
- package/docs/builtin-macros/deserialize/example.md +8 -1416
- package/docs/builtin-macros/deserialize.md +8 -1416
- package/docs/builtin-macros/hash.md +0 -42
- package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
- package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
- package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
- package/docs/builtin-macros/macros-overview/overview.md +36 -0
- package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
- package/docs/builtin-macros/macros-overview.md +171 -130
- package/docs/builtin-macros/ord.md +0 -25
- package/docs/builtin-macros/partial-eq.md +0 -84
- package/docs/builtin-macros/partial-ord.md +11 -43
- package/docs/builtin-macros/serialize.md +2 -62
- package/docs/concepts/architecture.md +125 -48
- package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
- package/docs/concepts/derive-system/overview.md +200 -0
- package/docs/concepts/derive-system.md +171 -97
- package/docs/concepts/how-macros-work.md +89 -37
- package/docs/custom-macros/custom-overview.md +79 -57
- package/docs/custom-macros/rust-setup.md +138 -99
- package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
- package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
- package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
- package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
- package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
- package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
- package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
- package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
- package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
- package/docs/custom-macros/ts-macro-derive.md +322 -228
- package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
- package/docs/custom-macros/ts-quote/comments-and.md +56 -22
- package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
- package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
- package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
- package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
- package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
- package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
- package/docs/custom-macros/ts-quote/overview.md +5 -10
- package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
- package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
- package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
- package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
- package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
- package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
- package/docs/custom-macros/ts-quote.md +799 -519
- package/docs/getting-started/first-macro.md +61 -32
- package/docs/getting-started/installation.md +109 -66
- package/docs/integration/cli.md +212 -103
- package/docs/integration/configuration.md +114 -71
- package/docs/integration/integration-overview.md +54 -17
- package/docs/integration/mcp-server.md +83 -42
- package/docs/integration/svelte-preprocessor.md +183 -126
- package/docs/integration/typescript-plugin.md +101 -54
- package/docs/integration/vite-plugin.md +116 -76
- package/docs/language-servers/ls-overview.md +37 -21
- package/docs/language-servers/svelte.md +69 -39
- package/docs/language-servers/zed.md +81 -45
- package/docs/roadmap/roadmap.md +75 -53
- package/docs/sections.json +333 -44
- package/package.json +27 -28
|
@@ -1,128 +1,185 @@
|
|
|
1
1
|
# Svelte Preprocessor
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
2
|
+
|
|
3
|
+
The Svelte preprocessor expands Macroforge macros in `<script>` blocks before Svelte compilation, enabling seamless macro usage in Svelte components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Bash
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install -D @macroforge/svelte-preprocessor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Add the preprocessor to your `svelte.config.js`:
|
|
16
|
+
|
|
17
|
+
svelte.config.js
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
import adapter from '@sveltejs/adapter-auto';
|
|
21
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
22
|
+
import { macroforgePreprocess } from '@macroforge/svelte-preprocessor';
|
|
23
|
+
|
|
24
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
25
|
+
const config = {
|
|
26
|
+
preprocess: [
|
|
27
|
+
macroforgePreprocess(), // Expand macros FIRST
|
|
28
|
+
vitePreprocess() // Then handle TypeScript/CSS
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
kit: {
|
|
32
|
+
adapter: adapter()
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default config;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Warning
|
|
40
|
+
|
|
41
|
+
Always place `macroforgePreprocess()` **before** other preprocessors like `vitePreprocess()`. This ensures macros are expanded before TypeScript compilation.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Use `@derive` decorators directly in your Svelte component scripts:
|
|
46
|
+
|
|
47
|
+
UserCard.svelte
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
<script lang="ts">
|
|
51
|
+
/** @derive(Debug, Clone) */
|
|
52
|
+
class User {
|
|
53
|
+
name: string;
|
|
54
|
+
email: string;
|
|
55
|
+
|
|
56
|
+
constructor(name: string, email: string) {
|
|
57
|
+
this.name = name;
|
|
58
|
+
this.email = email;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let user = new User("Alice", "alice@example.com");
|
|
63
|
+
console.log(user.toString()); // Generated by Debug macro
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<p>User: {user.name}</p>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Options
|
|
70
|
+
|
|
71
|
+
TypeScript
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
macroforgePreprocess({
|
|
75
|
+
// Keep @derive decorators in output (for debugging)
|
|
76
|
+
keepDecorators: false,
|
|
77
|
+
|
|
78
|
+
// Process JavaScript files (not just TypeScript)
|
|
79
|
+
processJavaScript: false
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Option Reference
|
|
84
|
+
|
|
85
|
+
| Option | Type | Default | Description |
|
|
86
|
+
| ------------------- | --------- | ------- | --------------------------------------------- |
|
|
87
|
+
| `keepDecorators` | `boolean` | `false` | Keep decorators in output |
|
|
59
88
|
| `processJavaScript` | `boolean` | `false` | Process `<script>` blocks without `lang="ts"` |
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
import
|
|
83
|
-
import
|
|
84
|
-
|
|
85
|
-
export
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
import
|
|
98
|
-
import
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
89
|
+
|
|
90
|
+
## How It Works
|
|
91
|
+
|
|
92
|
+
The preprocessor:
|
|
93
|
+
|
|
94
|
+
1. Intercepts `<script lang="ts">` blocks in `.svelte` files
|
|
95
|
+
2. Checks for `@derive` decorators (skips files without them)
|
|
96
|
+
3. Expands macros using the native Macroforge binary
|
|
97
|
+
4. Returns the transformed code for Svelte compilation
|
|
98
|
+
|
|
99
|
+
Tip
|
|
100
|
+
|
|
101
|
+
Files without `@derive` decorators are passed through unchanged with zero overhead.
|
|
102
|
+
|
|
103
|
+
## SvelteKit Integration
|
|
104
|
+
|
|
105
|
+
For SvelteKit projects, you can use both the preprocessor (for `.svelte` files) and the Vite plugin (for standalone `.ts` files):
|
|
106
|
+
|
|
107
|
+
svelte.config.js
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
// svelte.config.js
|
|
111
|
+
import { macroforgePreprocess } from '@macroforge/svelte-preprocessor';
|
|
112
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
preprocess: [
|
|
116
|
+
macroforgePreprocess(),
|
|
117
|
+
vitePreprocess()
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
vite.config.ts
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
// vite.config.ts
|
|
126
|
+
import macroforge from '@macroforge/vite-plugin';
|
|
127
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
128
|
+
import { defineConfig } from 'vite';
|
|
129
|
+
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
plugins: [
|
|
132
|
+
macroforge(), // For .ts files
|
|
133
|
+
sveltekit()
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Using with Vitest
|
|
139
|
+
|
|
140
|
+
The preprocessor works seamlessly with Vitest for testing Svelte components:
|
|
141
|
+
|
|
142
|
+
vitest.config.ts
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
// vitest.config.ts
|
|
146
|
+
import { defineConfig } from 'vitest/config';
|
|
147
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
148
|
+
import { svelteTesting } from '@testing-library/svelte/vite';
|
|
149
|
+
import macroforge from '@macroforge/vite-plugin';
|
|
150
|
+
|
|
151
|
+
export default defineConfig({
|
|
152
|
+
plugins: [
|
|
153
|
+
macroforge(),
|
|
154
|
+
sveltekit(),
|
|
155
|
+
svelteTesting()
|
|
156
|
+
],
|
|
157
|
+
test: {
|
|
158
|
+
environment: 'jsdom',
|
|
159
|
+
include: ['src/**/*.{test,spec}.{js,ts}']
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Svelte 5 Runes Compatibility
|
|
165
|
+
|
|
166
|
+
The preprocessor is fully compatible with Svelte 5 runes (`$state`, `$derived`, `$props`, etc.). Files using runes but without `@derive` decorators are skipped entirely.
|
|
167
|
+
|
|
168
|
+
Svelte
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
<script lang="ts">
|
|
172
|
+
// Runes work normally
|
|
173
|
+
let count = $state(0);
|
|
174
|
+
let doubled = $derived(count * 2);
|
|
175
|
+
|
|
176
|
+
// Macros expand correctly
|
|
177
|
+
/** @derive(Debug) */
|
|
178
|
+
class Counter {
|
|
179
|
+
value: number;
|
|
180
|
+
constructor(value: number) {
|
|
181
|
+
this.value = value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
</script>
|
|
185
|
+
```
|
|
@@ -1,55 +1,102 @@
|
|
|
1
1
|
# TypeScript Plugin
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
2
|
+
|
|
3
|
+
The TypeScript plugin provides IDE integration for Macroforge, including error reporting, completions, and type checking for generated code.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Bash
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install -D @macroforge/typescript-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Add the plugin to your `tsconfig.json`:
|
|
16
|
+
|
|
17
|
+
tsconfig.json
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
{
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
"plugins": [
|
|
23
|
+
{
|
|
24
|
+
"name": "@macroforge/typescript-plugin"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## VS Code Setup
|
|
32
|
+
|
|
33
|
+
VS Code uses its own TypeScript version by default. To use the workspace version (which includes plugins):
|
|
34
|
+
|
|
35
|
+
1. Open the Command Palette (`Cmd/Ctrl + Shift + P`)
|
|
36
|
+
2. Search for "TypeScript: Select TypeScript Version"
|
|
37
|
+
3. Choose "Use Workspace Version"
|
|
38
|
+
|
|
39
|
+
Tip
|
|
40
|
+
|
|
41
|
+
Add this setting to your `.vscode/settings.json` to make it permanent:
|
|
42
|
+
|
|
43
|
+
.vscode/settings.json
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
{
|
|
47
|
+
"typescript.tsdk": "node_modules/typescript/lib"
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
### Error Reporting
|
|
54
|
+
|
|
55
|
+
Errors in macro-generated code are reported at the `@derive` decorator position:
|
|
56
|
+
|
|
57
|
+
TypeScript
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
/** @derive(Debug) */ // <- Errors appear here
|
|
61
|
+
class User {
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Completions
|
|
67
|
+
|
|
68
|
+
The plugin provides completions for generated methods:
|
|
69
|
+
|
|
70
|
+
TypeScript
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
const user = new User("Alice");
|
|
74
|
+
user.to // Suggests: toString(), toJSON(), etc.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Type Information
|
|
78
|
+
|
|
79
|
+
Hover over generated methods to see their types:
|
|
80
|
+
|
|
81
|
+
TypeScript
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
// Hover over 'clone' shows:
|
|
85
|
+
// (method) User.clone(): User
|
|
86
|
+
const copy = user.clone();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Troubleshooting
|
|
90
|
+
|
|
91
|
+
### Plugin Not Loading
|
|
92
|
+
|
|
93
|
+
1. Ensure you're using the workspace TypeScript version
|
|
94
|
+
2. Restart the TypeScript server (Command Palette → "TypeScript: Restart TS Server")
|
|
95
|
+
3. Check that the plugin is listed in `tsconfig.json`
|
|
96
|
+
|
|
97
|
+
### Errors Not Showing
|
|
98
|
+
|
|
99
|
+
If errors from macros aren't appearing:
|
|
100
|
+
|
|
101
|
+
1. Make sure the Vite plugin is also installed (for source file watching)
|
|
102
|
+
2. Check that your file is saved (plugins process on save)
|
|
@@ -1,77 +1,117 @@
|
|
|
1
1
|
# Vite Plugin
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
2
|
+
|
|
3
|
+
The Vite plugin provides build-time macro expansion, transforming your code during development and production builds.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Bash
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install -D @macroforge/vite-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Add the plugin to your `vite.config.ts`:
|
|
16
|
+
|
|
17
|
+
vite.config.ts
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
import macroforge from "@macroforge/vite-plugin";
|
|
21
|
+
import { defineConfig } from "vite";
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
plugins: [
|
|
25
|
+
macroforge()
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Options
|
|
31
|
+
|
|
32
|
+
TypeScript
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
macroforge({
|
|
36
|
+
// Generate .d.ts files for expanded code
|
|
37
|
+
generateTypes: true,
|
|
38
|
+
|
|
39
|
+
// Output directory for generated types
|
|
40
|
+
typesOutputDir: ".macroforge/types",
|
|
41
|
+
|
|
42
|
+
// Emit metadata files for debugging
|
|
43
|
+
emitMetadata: false,
|
|
44
|
+
|
|
45
|
+
// Keep @derive decorators in output (for debugging)
|
|
46
|
+
keepDecorators: false,
|
|
47
|
+
|
|
48
|
+
// File patterns to process
|
|
49
|
+
include: ["**/*.ts", "**/*.tsx"],
|
|
50
|
+
exclude: ["node_modules/**"]
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Option Reference
|
|
55
|
+
|
|
56
|
+
| Option | Type | Default | Description |
|
|
57
|
+
| ---------------- | --------- | ------------------- | ------------------------- |
|
|
58
|
+
| `generateTypes` | `boolean` | `true` | Generate .d.ts files |
|
|
59
|
+
| `typesOutputDir` | `string` | `.macroforge/types` | Where to write type files |
|
|
60
|
+
| `emitMetadata` | `boolean` | `false` | Emit macro metadata files |
|
|
61
|
+
| `keepDecorators` | `boolean` | `false` | Keep decorators in output |
|
|
62
|
+
|
|
63
|
+
## Framework Integration
|
|
64
|
+
|
|
65
|
+
### React (Vite)
|
|
66
|
+
|
|
67
|
+
vite.config.ts
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
import macroforge from "@macroforge/vite-plugin";
|
|
71
|
+
import react from "@vitejs/plugin-react";
|
|
72
|
+
import { defineConfig } from "vite";
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
macroforge(), // Before React plugin
|
|
77
|
+
react()
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### SvelteKit
|
|
83
|
+
|
|
84
|
+
vite.config.ts
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
import macroforge from "@macroforge/vite-plugin";
|
|
88
|
+
import { sveltekit } from "@sveltejs/kit/vite";
|
|
89
|
+
import { defineConfig } from "vite";
|
|
90
|
+
|
|
91
|
+
export default defineConfig({
|
|
92
|
+
plugins: [
|
|
93
|
+
macroforge(), // Before SvelteKit
|
|
94
|
+
sveltekit()
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Note
|
|
100
|
+
|
|
101
|
+
Always place the Macroforge plugin before other framework plugins to ensure macros are expanded first.
|
|
102
|
+
|
|
103
|
+
## Development Server
|
|
104
|
+
|
|
105
|
+
During development, the plugin:
|
|
106
|
+
|
|
107
|
+
* Watches for file changes
|
|
108
|
+
* Expands macros on save
|
|
109
|
+
* Provides HMR support for expanded code
|
|
110
|
+
|
|
111
|
+
## Production Build
|
|
112
|
+
|
|
113
|
+
During production builds, the plugin:
|
|
114
|
+
|
|
115
|
+
* Expands all macros in the source files
|
|
116
|
+
* Generates type declaration files
|
|
117
|
+
* Strips `@derive` decorators from output
|