veslx 0.1.16 → 0.1.17

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vite.config.ts +42 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
package/vite.config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'vite'
1
+ import { defineConfig, Plugin } from 'vite'
2
2
  import react from '@vitejs/plugin-react'
3
3
  import tailwindcss from '@tailwindcss/vite'
4
4
  import mdx from '@mdx-js/rollup'
@@ -9,10 +9,43 @@ import remarkGfm from 'remark-gfm'
9
9
  import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
10
10
  import { remarkSlides } from './plugin/src/remark-slides'
11
11
  import { fileURLToPath } from 'url'
12
+ import { createRequire } from 'module'
12
13
  import path from 'path'
13
14
  import fs from 'fs'
14
15
 
15
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
17
+ const require = createRequire(import.meta.url)
18
+
19
+ // Resolve React packages from veslx's node_modules for MDX files in user content
20
+ // This is needed when veslx runs via bunx from a temp directory
21
+ function reactResolverPlugin(): Plugin {
22
+ const reactPackages = [
23
+ 'react',
24
+ 'react/jsx-runtime',
25
+ 'react/jsx-dev-runtime',
26
+ 'react-dom',
27
+ 'react-dom/client',
28
+ '@mdx-js/react',
29
+ ]
30
+
31
+ const resolved = new Map<string, string>()
32
+ for (const pkg of reactPackages) {
33
+ try {
34
+ resolved.set(pkg, require.resolve(pkg))
35
+ } catch {}
36
+ }
37
+
38
+ return {
39
+ name: 'veslx-react-resolver',
40
+ enforce: 'pre',
41
+ resolveId(id) {
42
+ if (resolved.has(id)) {
43
+ return resolved.get(id)
44
+ }
45
+ return null
46
+ },
47
+ }
48
+ }
16
49
 
17
50
  const distClientPath = path.join(__dirname, 'dist/client')
18
51
  const srcPath = path.join(__dirname, 'src')
@@ -38,6 +71,8 @@ export default defineConfig(({ command }) => {
38
71
  cacheDir: path.join(__dirname, 'node_modules/.vite'),
39
72
  publicDir: path.join(__dirname, 'public'),
40
73
  plugins: [
74
+ // Resolve React from veslx's dependencies for user MDX content (handles bunx installs)
75
+ reactResolverPlugin(),
41
76
  tailwindcss(),
42
77
  // MDX for slides - splits at --- into <Slide> components
43
78
  {
@@ -67,13 +102,13 @@ export default defineConfig(({ command }) => {
67
102
  resolve: {
68
103
  alias: {
69
104
  '@': clientPath,
70
- // Ensure React resolves from veslx's node_modules for MDX files in user content
71
- 'react': path.join(__dirname, 'node_modules/react'),
72
- 'react-dom': path.join(__dirname, 'node_modules/react-dom'),
73
- 'react/jsx-runtime': path.join(__dirname, 'node_modules/react/jsx-runtime'),
74
- 'react/jsx-dev-runtime': path.join(__dirname, 'node_modules/react/jsx-dev-runtime'),
75
- '@mdx-js/react': path.join(__dirname, 'node_modules/@mdx-js/react'),
76
105
  },
106
+ // Ensure single copies of React packages are used
107
+ dedupe: ['react', 'react-dom', '@mdx-js/react'],
108
+ },
109
+ build: {
110
+ chunkSizeWarningLimit: 1500,
111
+ reportCompressedSize: false,
77
112
  },
78
113
  server: {
79
114
  host: '0.0.0.0',
@@ -90,10 +125,6 @@ export default defineConfig(({ command }) => {
90
125
  strictPort: true,
91
126
  allowedHosts: true,
92
127
  },
93
- build: {
94
- chunkSizeWarningLimit: 1500,
95
- reportCompressedSize: false,
96
- },
97
128
  optimizeDeps: {
98
129
  entries: [path.join(clientPath, usePrebuilt ? 'main.js' : 'main.tsx')],
99
130
  include: [