RobotWebTools / roslibjs

The Standard ROS JavaScript Library
https://robotwebtools.github.io/roslibjs
Other
659 stars 372 forks source link

Modernize import syntax to ESModules #665

Closed EzraBrooks closed 4 months ago

EzraBrooks commented 5 months ago

Public API Changes

This is definitely a breaking change. Code requiring CommonJS modules may no longer work the same way or at all.

Description

This removes usage of the old CommonJS module require syntax in favor of ECMAScript Module import syntax, to ease the adoption of a newer bundler like Rollup. This code works in my Vite-based codebase, so it should work in Rollup.

The bulk of this PR is a change to package-lock.json from shuffling dependencies around.

Related to desire for a better/newer bundler in #647.

EzraBrooks commented 5 months ago

Had to upgrade from eventemitter2 to eventemitter3 to get this PR to work at all because of broken TypeScript declarations in eventemitter2. Extracted that change to #668.

EzraBrooks commented 4 months ago

Sorry for the delay here, it's actually a good sign, because this branch has been working in such a bulletproof manner on my project that I've been forgetting to come back and finish this..

EzraBrooks commented 4 months ago

See #687 for why we're doing this! The existing library layout didn't work with Rollup and Vite, but after this PR it does!