veslx 0.0.18 → 0.0.21

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/serve.ts CHANGED
@@ -1,7 +1,28 @@
1
1
 
2
- import { createServer } from 'vite'
2
+ import { createServer, preview } 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,19 +37,27 @@ 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
- const server = await createServer({
42
+ const server = await preview({
21
43
  root: veslxRoot,
22
44
  configFile: new URL('../../vite.config.ts', import.meta.url).pathname,
23
45
  plugins: [
24
46
  veslxPlugin(config.dir)
25
47
  ],
26
- optimizeDeps: {
27
- force: true,
28
- },
48
+ // resolve: {
49
+ // // Tell Vite to look for modules in the found node_modules directory
50
+ // modules: [nodeModulesDir, 'node_modules'],
51
+ // },
52
+ // server: {
53
+ // fs: {
54
+ // // Allow serving from the parent node_modules
55
+ // allow: [veslxRoot, nodeModulesDir, cwd],
56
+ // },
57
+ // },
29
58
  })
30
59
 
31
- await server.listen()
60
+ // await server.listen()
32
61
 
33
62
  server.printUrls()
34
63
  server.bindCLIShortcuts({ print: true })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.0.18",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "veslx": "bin/veslx.ts"
package/vite.config.ts CHANGED
@@ -50,6 +50,12 @@ export default defineConfig({
50
50
  allowedHosts: true,
51
51
  },
52
52
  preview: {
53
+ host: '0.0.0.0',
54
+ port: process.env.PORT ? parseInt(process.env.PORT, 10) : 3000,
55
+ strictPort: true,
56
+ fs: {
57
+ allow: ['..', '../..'],
58
+ },
53
59
  allowedHosts: true,
54
60
  },
55
61
  build: {
@@ -82,6 +88,8 @@ export default defineConfig({
82
88
  'bail',
83
89
  'trough',
84
90
  'vfile',
91
+ 'format',
92
+ 'fault',
85
93
  ],
86
94
  },
87
95
  })