Skip to content

Commit 1bb5580

Browse files
committed
Make core dependency of CLI
1 parent 3a4ea85 commit 1bb5580

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

client/packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"instant-cli": "bin/index.js"
2222
},
2323
"dependencies": {
24+
"@instantdb/core": "workspace:*",
2425
"@instantdb/platform": "workspace:*",
2526
"@instantdb/version": "workspace:*",
2627
"ansi-escapes": "4.3.2",

client/packages/cli/src/util/loadConfig.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ import { findProjectDir } from './projectDir.js';
1515
function getInstantAliases(): Record<string, string> | null {
1616
try {
1717
const require = createRequire(import.meta.url);
18-
const platformPath = require.resolve('@instantdb/platform');
19-
const platformRequire = createRequire(platformPath);
20-
// Resolve the package.json to get the actual package root
21-
const corePackageJson = platformRequire.resolve(
22-
'@instantdb/core/package.json',
23-
);
18+
// Resolve @instantdb/core directly from CLI's dependencies
19+
const corePackageJson = require.resolve('@instantdb/core/package.json');
2420
const coreDir = path.dirname(corePackageJson);
2521
// All @instantdb packages re-export schema types from core,
2622
// so we can alias them all to core for schema loading purposes
@@ -38,14 +34,16 @@ function getInstantAliases(): Record<string, string> | null {
3834
export async function loadConfig<T>(
3935
opts: LoadConfigOptions<T>,
4036
): Promise<LoadConfigResult<T>> {
41-
// Only use alias for Deno projects (Node projects use their own node_modules)
4237
const projectInfo = await findProjectDir();
4338
const isDeno = projectInfo?.type === 'deno';
44-
const alias = isDeno ? getInstantAliases() : null;
4539

46-
const res = await _loadConfig({
47-
...opts,
48-
...(alias && {
40+
// Deno projects don't have node_modules, so we need to alias @instantdb/*
41+
// packages to resolve from the CLI's own dependencies
42+
let res;
43+
if (isDeno) {
44+
const alias = getInstantAliases();
45+
res = await _loadConfig({
46+
...opts,
4947
importx: {
5048
...opts.importx,
5149
loaderOptions: {
@@ -56,8 +54,10 @@ export async function loadConfig<T>(
5654
},
5755
},
5856
},
59-
}),
60-
});
57+
});
58+
} else {
59+
res = await _loadConfig(opts);
60+
}
6161

6262
// Unconfig seems to add an __esModule property to the config object
6363
// Removing it.

client/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)