-
Notifications
You must be signed in to change notification settings - Fork 215
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
[WIP] Convert to ESM and ES classes #438
Conversation
…o ES2015 classes, and replace `src/` with them.
…rt class field syntax so it won't fail on it
* develop: Update Build Export OcTree (RobotWebTools#417)
89f0bb6
to
cd8afba
Compare
@MatthijsBurgh Merged develop, updated eslint (no errors on class fields or for-of), tests passing, build updated. |
My longer-term plan is
|
@@ -3,16 +3,15 @@ const rollup = require('rollup'); | |||
// plugin that transpiles output into commonjs format | |||
const commonjs = require('@rollup/plugin-commonjs'); | |||
// plugin that transpiles es6 to es5 for legacy platforms | |||
const buble = require('@rollup/plugin-buble'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code output is cleaner without Buble, and all browser nowadays support all the syntax being used (I've been using these ES module output at NASA with no issues). This eliminated errors Buble was having on newer syntax that I didn't want to spend time configuring (by wasting time adding plugins to acorn) when all browsers already support the syntax out of the box.
…tEmitter2 into the repo shims/ folder and convert it to an ES Module). It would be better to use something else other than EventEmitter2, which is 1600 lines of needless code just for an event pattern. @lume/eventful is only 100 lines of documented code.
I updated the code to be compatible with native ES Modules (and it now requires a very minimal The
So, by placing
|
Still need to run examples to make sure I didn't break something. |
Added a TODO for |
|
WIP PR in roslib: RobotWebTools/roslibjs#475 It is possible we can complete this PR without the roslib PR (it just won't have browser-ESM compatible source files, but the built .esm.js bundle will work). |
…that global addons will be able to modify ROSLIB
… which caught a few errors
…llation from git (see RobotWebTools/roslibjs@ee2d985 for more info)
…pare script (see previous commit) will ensure that the library is built during install, or users can use an unpkg.com URL like https://unpkg.com/browse/roslib@1.1.0/build/roslib.js for the global var script approach
What are your thoughts on that last commit (ignore build output)? Please let me know if that's ok or if I should keep build output (the reasoning is in the commit message). |
…asses * upstream/fix_440: Fix RobotWebTools#440, correctly delete old grid Add missing semi-colon Update Build Bump rollup from 2.56.3 to 2.57.0 (RobotWebTools#443) Bump mocha from 9.1.1 to 9.1.2 (RobotWebTools#442) Bump @rollup/plugin-node-resolve from 13.0.4 to 13.0.5 (RobotWebTools#441)
I think that is OK. I think a repo should never contain compiled files. But these were already there, when I joined. So I kept them. Might be good that the build files are added as artifacts to releases. |
That's true. For that, I think we can automate it.
|
options = options || {}; | ||
var path = options.path || '/'; | ||
var resource = options.resource; | ||
var material = options.material || null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not being used anywhere. I noticed as I was looking at build output that Rollup strips the var material
so it becomes a floating expression (not used for anything, but the expression remains because there could be an unknown side effect from reading the property).
…, or they end up installing a second version of Three.js which can lead to issues where singletons are expected, or they'll copy and fork a local ros3d lib, etc.
…not work inside of them
|
||
function onTouchEnd(event3D) { | ||
const onTouchEnd = (event3D) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug: the function
s were passed unbound as event handlers further below, so this
would not work inside of them.
We need unit tests! ros3d is hardly covered.
// (I've seen this problem happen in real-world ROS3D projects, especially with | ||
// roboticists or data scientists that are inexperienced with web | ||
// development). | ||
globalThis.THREE = THREE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it, this solves issues like #314 by allowing people to use ROS3D's THREE, rather than them trying to import an external THREE instance and causing issues. In a following update, this should be improved to allow more use cases such as supplying THREE from outside or as a peer dependency via npm.
Tests are passing in Node 16. There appears to be some difference between ESM in NOde 14 and 16 that makes tests fail in Node 14. We can try to fix it, or we can also move forward with Node 16 (this whole change will be a major version bump anyway). https://github.com/trusktr/ros3djs/runs/3809448165?check_suite_focus=true |
* Widen package requirements As suggested in RobotWebTools/roslibjs#437 (comment) * Fix wrong socket.io version
Any updates regarding this PR? Thanks |
Stale |
roslib
. Converted to ESM in the roslib PR.fixes #314