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

[WIP] convert to ES Module format #475

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e46aa82
initial conversion of files to ES Module format
trusktr Sep 12, 2021
2dc1db6
finish initial ESM format in source files, built ESM, CJS, and UMD ou…
trusktr Sep 14, 2021
8e71261
Merge branch 'develop' into convert-to-esm
trusktr Sep 14, 2021
20385ad
remove comment to hopefully trigger build
trusktr Sep 14, 2021
a6ca753
make sure to call grunt with Gruntfile.cjs
trusktr Sep 15, 2021
17d73e5
switch to eslint, get lint and build passing (output not yet tested)
trusktr Sep 16, 2021
31224af
get mocha tests passing
trusktr Sep 17, 2021
dcc10f5
set karma back to single run for CI
trusktr Sep 17, 2021
aee7a57
get base karma tests passing (the ones ran by `npm test`)
trusktr Sep 17, 2021
1a7b720
remove comments from Gruntfile
trusktr Sep 17, 2021
fbd53bc
Merge branch 'develop' into convert-to-esm
trusktr Sep 17, 2021
7db2591
run `npm test` before other tests
trusktr Sep 17, 2021
180e1e7
install before testing
trusktr Sep 21, 2021
675ca49
delete package-lock.json to fix the fsevents error on CI. Plus packag…
trusktr Sep 21, 2021
d3799a5
initial conversion of test/examples to ESM
trusktr Sep 21, 2021
54c6316
add @babel/core that CI says was missing
trusktr Sep 27, 2021
ada3edf
Merge branch 'develop' into convert-to-esm
trusktr Sep 27, 2021
17f9e7c
update npm version in CI
trusktr Sep 27, 2021
793c940
delete package-lock.json again (restored on accident from last merge)
trusktr Sep 27, 2021
bdc7f68
install dependencies with --legacy-peer-deps, for now
trusktr Sep 27, 2021
30fd409
update workersocket test code to ESM
trusktr Sep 27, 2021
98edbfe
update eslint to 8.0.0-rc.0
trusktr Sep 27, 2021
42d6590
use nvm in Dockerfile to set the latest npm version
trusktr Sep 27, 2021
bd5ed0c
install chromium-browser for CI
trusktr Sep 27, 2021
42b3004
build before testing
trusktr Sep 27, 2021
1d428a1
the --no-sandbox flag for Chrome is needed when running in CI
trusktr Sep 27, 2021
f3c43db
add comment about DOckerfile CHROME_BIN env var
trusktr Sep 27, 2021
c8dda47
run non-ROS tests before doing anything with ROS
trusktr Sep 27, 2021
ee2d985
make the repo friendly to npm install
trusktr Sep 28, 2021
893751a
add a tet that ensures the code follows Node ESM spec
trusktr Sep 28, 2021
2ce4ddc
ignore build output, libraries don't need lock files
trusktr Oct 3, 2021
278f847
simpify .npmignore
trusktr Oct 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"env": {
"browser": true,
"es2021": true,
"mocha": true
},
"globals": {
// TODO: These globals are namely for test files. We don't want to have these listed as globals for source files like currently.
"require": true,
"process": true,
"module": true,
"ROSLIB": true,
"cborTypedArrayTagger": true,
"CBOR": true,
"EventEmitter2": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"requireConfigFile": false
},
"rules": {
"semi": ["warn", "always"],
"curly": "error",
"eqeqeq": "error",
"wrap-iife": ["error", "any"],
"no-use-before-define": "off",
"new-cap": "error",
"no-caller": "error",
"dot-notation": "off",
"no-undef": "error",
"no-cond-assign": "off",
"no-eq-null": "off",
"no-proto": "off",
"no-console": "off",
"no-unused-vars": "off",
"strict": "off",
"quotes": ["error", "single"],
"linebreak-style": "error"
}
}
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ doc
node_modules
*.out
*.log
*.tar.gz
*.tar.gz

# libs don't need lock files, only apps do
*lock.json
*.lock

# ignore build output
build/
27 changes: 0 additions & 27 deletions .jshintrc

This file was deleted.

13 changes: 6 additions & 7 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
test
examples
Gruntfile.js
.gitignore
.github
bower.json
*.md
# Ignore everything,
/**/*

# but include these folders
!/build/**/*
!/src/**/*
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ ARG CI=true
ENV CI=$CI

# Dependencies for rosbridge
RUN apt update && apt-get install -y firefox git wget ros-$ROS_DISTRO-rosbridge-server ros-$ROS_DISTRO-tf2-web-republisher ros-$ROS_DISTRO-common-tutorials ros-$ROS_DISTRO-rospy-tutorials ros-$ROS_DISTRO-actionlib-tutorials
RUN apt update && apt-get install -y firefox chromium-browser git wget ros-$ROS_DISTRO-rosbridge-server ros-$ROS_DISTRO-tf2-web-republisher ros-$ROS_DISTRO-common-tutorials ros-$ROS_DISTRO-rospy-tutorials ros-$ROS_DISTRO-actionlib-tutorials

# Install nvm, Node.js and node-gyp
ARG NODE_VERSION=14
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash \
&& . $HOME/.nvm/nvm.sh \
&& nvm install $NODE_VERSION && nvm alias default $NODE_VERSION \
&& nvm install $NODE_VERSION --latest-npm && nvm alias default $NODE_VERSION \
&& npm install -g node-gyp

RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> $HOME/.bashrc
ENV PATH=/bin/versions/node/$NODE_VERSION/bin:$PATH

# Needed for Karma testing
ENV CHROME_BIN=chromium-browser
128 changes: 128 additions & 0 deletions Gruntfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* global module, require, process */

'use strict';

module.exports = function(grunt) {

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
build: {
command: 'rollup -c'
},
'test-esm': {
command: 'webpack --config esm-test.webpack.config.js'
},
lint: {
command: 'eslint Gruntfile.cjs ./src/*.js ./src/**/*.js ./test/*.js'
},
'lint-fix': {
command: 'eslint --fix Gruntfile.cjs ./src/*.js ./src/**/*.js ./test/*.js'
},
'mocha-test': {
command: 'mocha ./test/*.test.js'
},
'mocha-examples': {
command: 'mocha ./test/examples/*.js'
},
'mocha-tcp': {
command: 'mocha ./test/tcp/*.js'
},
},
karma: {
options: {
singleRun: true,
browsers: process.env.CI ? ['ChromeHeadlessNoSandbox'] : ['Chrome']
},
test: {
configFile: './test/karma.conf.cjs',
},
examples: {
configFile: './test/examples/karma.conf.cjs',
},
workersocket: {
configFile: './test/workersocket/karma.conf.cjs',
},
},
// mochaTest: {
// options: {
// reporter: 'spec',
// timeout: 5000
// },
// test: {
// src: ['./test/*.test.js']
// },
// examples: {
// src: ['./test/examples/*.js']
// },
// tcp: {
// src: ['./test/tcp/*.js']
// }
// },
uglify: {
options: {
report: 'min'
},
build: {
src: './build/roslib.js',
dest: './build/roslib.min.js'
}
},
watch: {
dev: {
options: {
interrupt: true
},
files: [
'./src/**/*.js'
],
tasks: ['shell:build']
},
build_and_watch: {
options: {
interrupt: true
},
files: [
'Gruntfile.cjs',
'.jshintrc',
'./src/**/*.js'
],
tasks: ['build']
}
},
clean: {
options: {
force: true
},
doc: ['./doc']
},
jsdoc: {
doc: {
src: [
'./src/**/*.js'
],
options: {
destination: './doc',
private: false
}
}
}
});

grunt.registerTask('dev', ['shell:build', 'watch']);
grunt.registerTask('test', ['lint', 'shell:test-esm', 'shell:mocha-test', 'karma:test']);
grunt.registerTask('test-examples', ['shell:mocha-examples', 'karma:examples']);
grunt.registerTask('test-tcp', ['shell:mocha-tcp']);
grunt.registerTask('test-workersocket', ['karma:workersocket']);
grunt.registerTask('build', ['lint', 'shell:build']);
grunt.registerTask('build_and_watch', ['watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
grunt.registerTask('lint', ['shell:lint']);
grunt.registerTask('lint-fix', ['shell:lint-fix',]);
};
116 changes: 0 additions & 116 deletions Gruntfile.js

This file was deleted.

Loading