Skip to content

Conversation

@nezaj
Copy link
Contributor

@nezaj nezaj commented Dec 4, 2025

Problem

The Instant CLI assumes a Node.js project structure:

  1. Project detection (pkg-dir) only looks for package.json
  2. Schema loading (unconfig/jiti) uses Node.js module resolution, requiring node_modules/@instantdb/core

Deno users can't use the CLI because they have deno.json instead of package.json, and no node_modules.

Solution

Two changes:

  1. Project detection: Also look for deno.json / deno.jsonc
  2. Schema loading: For Deno projects, configure jiti to resolve @instantdb/core from the CLI's own dependencies

--

As an aside I also included watching the cli in make dev -- found myself needing to add this config in everytime I work on the cli and it feels like it's been frequent enough to warrant it

pkg-dir also was renamed to package-directory recently so updated that and also included find-up (which is a dependency of package-directory) to traverse find deno

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

View Vercel preview at instant-www-js-enable-deno-cli-jsv.vercel.app.

function getInstantCoreAlias(): Record<string, string> | null {
try {
const require = createRequire(import.meta.url);
const platformPath = require.resolve('@instantdb/platform');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make cli require core too? imo it should be fine as they are all the same versions.

Reasoning: it will make this a bit less error prone

Copy link
Contributor

@stopachka stopachka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

const res = await _loadConfig(opts);
// Only use alias for Deno projects (Node projects use their own node_modules)
const projectInfo = await findProjectDir();
const isDeno = projectInfo?.type === 'deno';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if can write this as:

let res;
If (isDeno) {
res = await _loadConfig(...)
} else {
res = await _loadConfig
}

Reasoning: it will make clearer that importx and friends are really for isDeno

export async function findProjectDir(
cwd?: string,
): Promise<ProjectInfo | null> {
// Check for Deno first (more specific - if they have deno.json, they want Deno)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really true? Can they have a package directory on deno?

};

async function detectEnvType({ pkgDir }) {
// Check if Deno project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code necc? Wouldn't we just hit L99 in the deno case?

if (!authToken) {
return;
}
return { pkgDir, instantModuleName: '@instantdb/core', authToken };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe projectInfo should be returned in this map?

I feel like it will be useful for all the children

@nezaj nezaj merged commit b8f2d9a into main Dec 15, 2025
32 checks passed
@nezaj nezaj deleted the enable-deno-cli branch December 15, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants