@@ -15,12 +15,8 @@ import { findProjectDir } from './projectDir.js';
1515function 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 {
3834export 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.
0 commit comments