veslx 0.0.18 → 0.0.19

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/bin/lib/serve.ts +32 -0
  2. package/package.json +1 -1
package/bin/lib/serve.ts CHANGED
@@ -2,6 +2,27 @@
2
2
  import { createServer } from 'vite'
3
3
  import importConfig from "./import-config";
4
4
  import veslxPlugin from '../../plugin/src/plugin'
5
+ import path from 'path'
6
+ import fs from 'fs'
7
+
8
+ // Find the node_modules directory that contains actual dependencies
9
+ // This handles both local dev (node_modules in project root) and
10
+ // bunx execution (node_modules in temp dir parent)
11
+ function findNodeModulesDir(startDir: string): string {
12
+ let dir = startDir
13
+ while (dir !== '/' && dir !== '.') {
14
+ const nm = path.join(dir, 'node_modules')
15
+ // Check if node_modules exists and has real packages (not just .vite cache)
16
+ if (fs.existsSync(nm)) {
17
+ const contents = fs.readdirSync(nm)
18
+ if (contents.some(f => !f.startsWith('.') && f !== 'veslx')) {
19
+ return nm
20
+ }
21
+ }
22
+ dir = path.dirname(dir)
23
+ }
24
+ return path.join(startDir, 'node_modules')
25
+ }
5
26
 
6
27
  export default async function start() {
7
28
  const cwd = process.cwd()
@@ -16,6 +37,7 @@ export default async function start() {
16
37
  }
17
38
 
18
39
  const veslxRoot = new URL('../..', import.meta.url).pathname;
40
+ const nodeModulesDir = findNodeModulesDir(veslxRoot)
19
41
 
20
42
  const server = await createServer({
21
43
  root: veslxRoot,
@@ -26,6 +48,16 @@ export default async function start() {
26
48
  optimizeDeps: {
27
49
  force: true,
28
50
  },
51
+ resolve: {
52
+ // Tell Vite to look for modules in the found node_modules directory
53
+ modules: [nodeModulesDir, 'node_modules'],
54
+ },
55
+ server: {
56
+ fs: {
57
+ // Allow serving from the parent node_modules
58
+ allow: [veslxRoot, nodeModulesDir, cwd],
59
+ },
60
+ },
29
61
  })
30
62
 
31
63
  await server.listen()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "veslx": "bin/veslx.ts"