Open
Description
Description
I'm using Vite to build a React SPA, hosted through a Node Express server.
Importing roslib in dev mode works, but after building the application I have an error in the browser saying Cannot read properties of undefined (reading 'ROSLIB')
.
The error seems to come from the RosLib.js file, specifically this code:
var ROSLIB = this.ROSLIB || { // <-- Error here
REVISION : '1.4.1'
};
It seems that 'this' is undefined.
Am I missing something here or is this module not compatible with Vite?
- Library Version: 1.4.1
- ROS Version: ?
- Platform / OS: OSX
Steps To Reproduce
- Create a new Vite project
- Install roslib
- import roslib, e.g.
import * as ROS from "roslib"
- Build the application for production and run it
Expected Behavior
Application running as expected
Actual Behavior
Application crashes with the follwing error:
Uncaught TypeError: Cannot read properties of undefined (reading 'ROSLIB')