Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making adminjs work on Deno #1632

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Conversation

brickpop
Copy link
Contributor

@brickpop brickpop commented Feb 25, 2024

Thank you for such an amazing piece of software.

This PR fixes two small issues that prevent AdminJS from working on Deno.

The problem:

AdminJS assumes that the environment is either a browser or NodeJS, only.

user@host ~/d/b/adminjs-deno (main)> deno task dev                                          (base) 
Task dev deno run --watch -A src/app.ts
Watcher Process started.
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'isOnServer')
    at Function.getBaseUrl (file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/[email protected]/node_modules/adminjs/lib/frontend/utils/api-client.js:104:19)
    at new ApiClient (file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/[email protected]/node_modules/adminjs/lib/frontend/utils/api-client.js:98:30)
    at file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/[email protected]/node_modules/adminjs/lib/frontend/hooks/use-record/use-record.js:11:13

The solution

Adding a check to ensure that globalAny is treated as in a server.

Working example

AdminJS app running on Deno:
https://github.com/brickpop/adminjs-deno

You need to run the deno task setup to apply the workaround that fixes the issue. See scripts/setup.ts

@brickpop brickpop changed the title Make adminjs work on Deno Makeing adminjs work on Deno Feb 25, 2024
@brickpop brickpop changed the title Makeing adminjs work on Deno Making adminjs work on Deno Feb 25, 2024
@dziraf dziraf merged commit 3c019b2 into SoftwareBrothers:master Mar 7, 2024
4 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

🎉 This PR is included in version 7.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants