orga-build 0.3.0 → 0.3.2
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/README.org +31 -0
- package/lib/vite.js +11 -11
- package/package.json +2 -2
package/README.org
CHANGED
|
@@ -8,6 +8,37 @@ A simple tool that builds org-mode files into a website.
|
|
|
8
8
|
npm install orga-build
|
|
9
9
|
#+end_src
|
|
10
10
|
|
|
11
|
+
* TypeScript Setup
|
|
12
|
+
|
|
13
|
+
If you're using TypeScript and want type support for the =orga-build:content= virtual module, you need to add a reference to the type definitions.
|
|
14
|
+
|
|
15
|
+
** Minimal Setup
|
|
16
|
+
|
|
17
|
+
1. Create a =types.d.ts= file in your project root (or any location):
|
|
18
|
+
|
|
19
|
+
#+begin_src typescript
|
|
20
|
+
/// <reference types="orga-build/client" />
|
|
21
|
+
#+end_src
|
|
22
|
+
|
|
23
|
+
2. Ensure your =tsconfig.json= includes this file:
|
|
24
|
+
|
|
25
|
+
#+begin_src json
|
|
26
|
+
{
|
|
27
|
+
"compilerOptions": {
|
|
28
|
+
"module": "esnext",
|
|
29
|
+
"moduleResolution": "bundler",
|
|
30
|
+
"jsx": "react-jsx"
|
|
31
|
+
},
|
|
32
|
+
"include": ["types.d.ts", "**/*"]
|
|
33
|
+
}
|
|
34
|
+
#+end_src
|
|
35
|
+
|
|
36
|
+
That's it! TypeScript will now recognize imports from =orga-build:content=.
|
|
37
|
+
|
|
38
|
+
** Why This is Needed
|
|
39
|
+
|
|
40
|
+
The =orga-build:content= module is a "virtual module" - it doesn't exist as a physical file but is generated at build time by Vite. The =/// <reference types="orga-build/client" />= directive tells TypeScript to load the type definitions for this virtual module.
|
|
41
|
+
|
|
11
42
|
* Content Query API
|
|
12
43
|
|
|
13
44
|
orga-build provides an Astro-inspired content query API via the =orga-build:content= virtual module. This allows you to safely query content entries from any page or layout without circular imports.
|
package/lib/vite.js
CHANGED
|
@@ -31,20 +31,20 @@ export function pluginFactory({ dir }) {
|
|
|
31
31
|
}
|
|
32
32
|
}),
|
|
33
33
|
|
|
34
|
-
configureServer(
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
configureServer(server) {
|
|
35
|
+
const { watcher, moduleGraph, ws } = server
|
|
36
|
+
|
|
37
|
+
// Invalidate content module on file changes
|
|
38
|
+
watcher.on('change', (filePath) => {
|
|
39
|
+
const module = moduleGraph.getModuleById(contentModuleIdResolved)
|
|
37
40
|
if (module) {
|
|
38
41
|
moduleGraph.invalidateModule(module)
|
|
39
|
-
|
|
42
|
+
// Send HMR update to client
|
|
43
|
+
ws.send({
|
|
44
|
+
type: 'full-reload',
|
|
45
|
+
path: '*'
|
|
46
|
+
})
|
|
40
47
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
reloadVirtualModule('/')
|
|
44
|
-
|
|
45
|
-
// Invalidate content module on file changes
|
|
46
|
-
watcher.on('change', () => {
|
|
47
|
-
reloadVirtualModule(contentModuleIdResolved)
|
|
48
48
|
})
|
|
49
49
|
},
|
|
50
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orga-build",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A simple tool that builds org-mode files into a website",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"./csr": "./lib/csr.jsx",
|
|
23
23
|
"./components": "./lib/components.js",
|
|
24
|
-
"./
|
|
24
|
+
"./client": {
|
|
25
25
|
"types": "./lib/content.d.ts"
|
|
26
26
|
}
|
|
27
27
|
},
|