@jkwd/inbase 0.1.16 → 0.1.18
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/apps/explorer/vite.config.ts +24 -4
- package/bin/inbase.mjs +6 -5
- package/bin/project.mjs +39 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
7
7
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
8
8
|
import { emptyIntent } from './scripts/patch-lib.mjs'
|
|
9
9
|
import { readBranchChanges } from './scripts/branch-changes.mjs'
|
|
10
|
-
import { writeRunningInstance } from '../../bin/project.mjs'
|
|
10
|
+
import { writeRunningInstance, isolatedViteConfig, packageDirFromPackage } from '../../bin/project.mjs'
|
|
11
11
|
import { dataDir, targetRoot } from './scripts/target-config.mjs'
|
|
12
12
|
import { editorFileUri, openInEditor } from './scripts/open-editor.mjs'
|
|
13
13
|
import {
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
} from './scripts/session-store.mjs'
|
|
36
36
|
|
|
37
37
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
38
|
+
const isolation = isolatedViteConfig(dataDir)
|
|
38
39
|
const userContextFile = path.join(dataDir, 'user-context.json')
|
|
39
40
|
const codebaseFile = path.join(dataDir, 'codebase.json')
|
|
40
41
|
const scanScript = path.resolve(here, 'scripts/scan-target.mjs')
|
|
@@ -478,16 +479,35 @@ function isDataDirPath(filePath: string) {
|
|
|
478
479
|
}
|
|
479
480
|
|
|
480
481
|
export default defineConfig({
|
|
482
|
+
...isolation,
|
|
481
483
|
plugins: [react(), jsonFilePlugin()],
|
|
484
|
+
resolve: {
|
|
485
|
+
alias: {
|
|
486
|
+
react: packageDirFromPackage('react'),
|
|
487
|
+
'react-dom': packageDirFromPackage('react-dom'),
|
|
488
|
+
three: packageDirFromPackage('three'),
|
|
489
|
+
'@react-three/fiber': packageDirFromPackage('@react-three/fiber'),
|
|
490
|
+
'@react-three/drei': packageDirFromPackage('@react-three/drei'),
|
|
491
|
+
},
|
|
492
|
+
dedupe: ['react', 'react-dom', 'three', '@react-three/fiber', '@react-three/drei'],
|
|
493
|
+
},
|
|
494
|
+
optimizeDeps: {
|
|
495
|
+
...isolation.optimizeDeps,
|
|
496
|
+
include: [
|
|
497
|
+
'react',
|
|
498
|
+
'react-dom',
|
|
499
|
+
'three',
|
|
500
|
+
'@react-three/fiber',
|
|
501
|
+
'@react-three/drei',
|
|
502
|
+
],
|
|
503
|
+
},
|
|
482
504
|
server: {
|
|
505
|
+
...isolation.server,
|
|
483
506
|
port: 5173,
|
|
484
507
|
watch: {
|
|
485
508
|
// Session snapshots copy target source into the data dir. If Vite
|
|
486
509
|
// watches those writes, Create proposal full-reloads the visualizer.
|
|
487
510
|
ignored: ['**/src/data/**', isDataDirPath],
|
|
488
511
|
},
|
|
489
|
-
fs: {
|
|
490
|
-
allow: [here, dataDir],
|
|
491
|
-
},
|
|
492
512
|
},
|
|
493
513
|
})
|
package/bin/inbase.mjs
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
ensureDataDir,
|
|
10
10
|
ensureGitignoreEntry,
|
|
11
11
|
explorerRoot,
|
|
12
|
+
isolatedViteConfig,
|
|
13
|
+
resolveFromPackage,
|
|
12
14
|
skillTemplateDir,
|
|
13
15
|
commandTemplateDir,
|
|
14
16
|
takeFlagValue,
|
|
@@ -95,16 +97,15 @@ async function runServer(args) {
|
|
|
95
97
|
dest: path.join(dataDir, 'codebase.json'),
|
|
96
98
|
})
|
|
97
99
|
|
|
98
|
-
const { createServer } = await import('vite')
|
|
100
|
+
const { createServer } = await import(pathToFileURL(resolveFromPackage('vite')).href)
|
|
101
|
+
const isolation = isolatedViteConfig(dataDir)
|
|
99
102
|
const server = await createServer({
|
|
100
103
|
configFile: path.join(explorerRoot, 'vite.config.ts'),
|
|
101
|
-
|
|
104
|
+
...isolation,
|
|
102
105
|
server: {
|
|
106
|
+
...isolation.server,
|
|
103
107
|
port,
|
|
104
108
|
host: '127.0.0.1',
|
|
105
|
-
fs: {
|
|
106
|
-
allow: [explorerRoot, targetRoot, dataDir],
|
|
107
|
-
},
|
|
108
109
|
},
|
|
109
110
|
})
|
|
110
111
|
await server.listen()
|
package/bin/project.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
3
4
|
import { fileURLToPath } from 'node:url'
|
|
4
5
|
|
|
5
6
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
@@ -8,6 +9,44 @@ export const explorerRoot = path.join(packageRoot, 'apps/explorer')
|
|
|
8
9
|
export const skillTemplateDir = path.join(packageRoot, 'skill/inbase')
|
|
9
10
|
export const commandTemplateDir = path.join(packageRoot, 'skill/commands')
|
|
10
11
|
|
|
12
|
+
const requireFromPackage = createRequire(path.join(packageRoot, 'package.json'))
|
|
13
|
+
|
|
14
|
+
export function resolveFromPackage(specifier) {
|
|
15
|
+
return requireFromPackage.resolve(specifier)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function packageDirFromPackage(name) {
|
|
19
|
+
let dir = path.dirname(resolveFromPackage(name))
|
|
20
|
+
while (dir !== path.dirname(dir)) {
|
|
21
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) return dir
|
|
22
|
+
dir = path.dirname(dir)
|
|
23
|
+
}
|
|
24
|
+
return dir
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Vite config that never uses the host project's cache, deps, or browser targets. */
|
|
28
|
+
export function isolatedViteConfig(dataDir) {
|
|
29
|
+
return {
|
|
30
|
+
root: explorerRoot,
|
|
31
|
+
envDir: explorerRoot,
|
|
32
|
+
cacheDir: path.join(dataDir, 'vite'),
|
|
33
|
+
publicDir: false,
|
|
34
|
+
appType: 'spa',
|
|
35
|
+
build: { target: 'esnext' },
|
|
36
|
+
esbuild: { target: 'esnext' },
|
|
37
|
+
optimizeDeps: {
|
|
38
|
+
entries: [path.join(explorerRoot, 'index.html')],
|
|
39
|
+
esbuildOptions: { target: 'esnext' },
|
|
40
|
+
},
|
|
41
|
+
server: {
|
|
42
|
+
fs: {
|
|
43
|
+
strict: true,
|
|
44
|
+
allow: [explorerRoot, packageRoot, dataDir],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
11
50
|
export function resolveOptionalPath(value, fallback) {
|
|
12
51
|
const raw = value?.trim()
|
|
13
52
|
if (!raw) return fallback
|