veslx 0.1.1 → 0.1.3

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/bin/lib/build.ts CHANGED
@@ -52,6 +52,8 @@ export default async function buildApp() {
52
52
  root: veslxRoot,
53
53
  configFile,
54
54
  mode: 'production',
55
+ // Cache in user's project so it persists across bunx runs
56
+ cacheDir: path.join(cwd, 'node_modules/.vite'),
55
57
  build: {
56
58
  outDir: tempOutDir,
57
59
  emptyOutDir: true,
package/bin/lib/serve.ts CHANGED
@@ -26,6 +26,8 @@ export default async function start() {
26
26
  const server = await createServer({
27
27
  root: veslxRoot,
28
28
  configFile,
29
+ // Cache in user's project so it persists across bunx runs
30
+ cacheDir: path.join(cwd, 'node_modules/.vite'),
29
31
  plugins: [
30
32
  veslxPlugin(contentDir)
31
33
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "veslx": "bin/veslx.ts"
@@ -101,7 +101,7 @@ export default function contentPlugin(contentDir: string): Plugin {
101
101
  },
102
102
  },
103
103
  optimizeDeps: {
104
- exclude: ['virtual:content-modules', 'veslx'],
104
+ exclude: ['virtual:content-modules'],
105
105
  },
106
106
  }
107
107
  },
@@ -1,5 +1,4 @@
1
1
  import { useState, useEffect } from 'react'
2
- import { modules, slides } from 'virtual:content-modules'
3
2
  import type { ComponentType } from 'react'
4
3
 
5
4
  interface MDXModule {
@@ -13,6 +12,7 @@ interface MDXModule {
13
12
  }
14
13
 
15
14
  type ModuleLoader = () => Promise<MDXModule>
15
+ type ModuleMap = Record<string, ModuleLoader>
16
16
 
17
17
  export function useMDXContent(path: string) {
18
18
  const [Content, setContent] = useState<MDXModule['default'] | null>(null)
@@ -25,20 +25,20 @@ export function useMDXContent(path: string) {
25
25
  setLoading(true)
26
26
  setError(null)
27
27
 
28
- // Find the matching module - keys are like "/content-dir/path/README.mdx"
29
- // We need to match against the path segment
30
- const matchingKey = Object.keys(modules).find(key =>
31
- key.endsWith(`/${path}/README.mdx`)
32
- )
33
- const loader = matchingKey ? (modules as Record<string, ModuleLoader>)[matchingKey] : null
34
-
35
- if (!loader) {
36
- setError(new Error(`MDX module not found for path: ${path}`))
37
- setLoading(false)
38
- return
39
- }
28
+ // Dynamic import to avoid pre-bundling issues
29
+ import('virtual:content-modules')
30
+ .then(({ modules }) => {
31
+ const matchingKey = Object.keys(modules).find(key =>
32
+ key.endsWith(`/${path}/README.mdx`)
33
+ )
34
+ const loader = matchingKey ? (modules as ModuleMap)[matchingKey] : null
35
+
36
+ if (!loader) {
37
+ throw new Error(`MDX module not found for path: ${path}`)
38
+ }
40
39
 
41
- loader()
40
+ return loader()
41
+ })
42
42
  .then((mod) => {
43
43
  if (!cancelled) {
44
44
  setContent(() => mod.default)
@@ -72,19 +72,20 @@ export function useMDXSlides(path: string) {
72
72
  setLoading(true)
73
73
  setError(null)
74
74
 
75
- // Find the matching module - keys are like "/content-dir/path/SLIDES.mdx"
76
- const matchingKey = Object.keys(slides).find(key =>
77
- key.endsWith(`/${path}/SLIDES.mdx`)
78
- )
79
- const loader = matchingKey ? (slides as Record<string, ModuleLoader>)[matchingKey] : null
75
+ // Dynamic import to avoid pre-bundling issues
76
+ import('virtual:content-modules')
77
+ .then(({ slides }) => {
78
+ const matchingKey = Object.keys(slides).find(key =>
79
+ key.endsWith(`/${path}/SLIDES.mdx`)
80
+ )
81
+ const loader = matchingKey ? (slides as ModuleMap)[matchingKey] : null
80
82
 
81
- if (!loader) {
82
- setError(new Error(`Slides module not found for path: ${path}`))
83
- setLoading(false)
84
- return
85
- }
83
+ if (!loader) {
84
+ throw new Error(`Slides module not found for path: ${path}`)
85
+ }
86
86
 
87
- loader()
87
+ return loader()
88
+ })
88
89
  .then((mod) => {
89
90
  if (!cancelled) {
90
91
  setContent(() => mod.default)