8000 Support for Deno & Bun (5 line change) by jeff-hykin · Pull Request #874 · RobotWebTools/roslibjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Support for Deno & Bun (5 line change) #874

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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

jeff-hykin
Copy link

Public API Changes
None

Description
The only functional change is a conditional check for Deno (created by the author of NodeJS). Roslibjs effectively already supports Deno, because Deno very very closely implements web standards. The only thing causing it to fail is that Roslibjs assumes NodeJS when there's no window object.

The only other change (appending .ts) is because Deno natively supports typescript, so long as the full file path is specified.

E.g. the following now works:

cd roslibjs
deno
>import * as ros from "./src/RosLib.js"

@MatthijsBurgh
Copy link
Contributor

The CI is failing, so review is on hold till CI is fixed

@jeff-hykin jeff-hykin changed the title Support for Deno (only 5 lines changed) Support for Deno & Bun (only 5 lines changed) May 6, 2025
@jeff-hykin
Copy link
Author
jeff-hykin commented May 6, 2025

@MatthijsBurgh thanks for specifying. It should pass the linter now.

While an exception to the linter's globals check was maybe justified, it made me realize a more generalized approach for this PR. The revised version is smaller and adds support for Bun, Deno, and possibly other runtimes.

I should talk to you directly about the other check that now passes (.ts extension). If I could avoid the change I would. Its in this PR because it's a functional difference on runtimes that follow the JS (ECMA Script) spec. Deno implements the browser (ECMA Script) specification with support for typescript. If the import statement is not an exact file path, it fails.

@jeff-hykin jeff-hykin changed the title Support for Deno & Bun (only 5 lines changed) Support for Deno & Bun (5 line change) May 6, 2025
Copy link
Contributor
@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Some minor comments.

deno.lock Outdated
Copy link
Contributor
@EzraBrooks EzraBrooks May 7, 2025

Choose a reason for hiding this comment

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

I don't think you need to commit the Deno lockfile, since roslibjs is not shipping via Deno, right?

@@ -5,7 +5,7 @@

import { EventEmitter } from 'eventemitter3';
import Ros from '../core/Ros.js';
import { GoalStatus } from '../core/GoalStatus';
import { GoalStatus } from '../core/GoalStatus.ts';
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me but could you double-check the resulting bundled code from Vite to make sure that this resolves okay for runtimes that don't support TypeScript natively like Deno and ts-node do? I assume Vite will handle this, but I'm not 100% certain since I use extensionless paths on my projects.

src/core/Ros.js Outdated
// Detect if in browser vs in NodeJS
if (typeof window !== 'undefined') {
// browsers, Deno, and Bun support WebSockets natively
if (typeof WebSocket == "function") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the failing checks on this line to adhere to the project's style guidelines

@jeff-hykin
Copy link
Author
jeff-hykin commented Jun 4, 2025

I came to bump this, only to realize it was waiting on me! Sorry for the delay.

Linter passes locally, its now up to date with the latest master, and I confirmed vite does bundle it correctly (screenshot)

Screen Shot 2025-06-04 at 2 32 36 PM

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
0