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 9 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"
}
}
27 changes: 0 additions & 27 deletions .jshintrc

This file was deleted.

62 changes: 38 additions & 24 deletions Gruntfile.js → Gruntfile.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global module, require, process */

'use strict';

module.exports = function(grunt) {
Expand All @@ -10,34 +12,39 @@ module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
dist: {
src: ['./src/RosLibBrowser.js'],
dest: './build/roslib.js'
}
},
jshint: {
options: {
jshintrc: true
shell: {
build: {
command: 'rollup -c'
},
lint: {
command: 'eslint Gruntfile.cjs ./src/*.js ./src/**/*.js ./test/*.js'
},
'lint-fix': {
command: 'eslint --fix Gruntfile.cjs ./src/*.js ./src/**/*.js ./test/*.js'
},
mochaTest: {
command: 'mocha ./test/*.test.js'
},
mochaExamples: {
command: 'mocha ./test/examples/*.js'
},
mochaTcp: {
command: 'mocha ./test/tcp/*.js'
},
files: [
'./Gruntfile.js',
'./src/**/*.js'
]
},
karma: {
options: {
singleRun: true,
browsers: process.env.CI ? ['FirefoxHeadless'] : ['Firefox']
browsers: process.env.CI ? ['ChromeHeadless'] : ['Chrome']
Copy link
Author

Choose a reason for hiding this comment

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

I switched to Chrome because I was having issues getting the importmap polyfill working in Firefox:

I decided to just get this all working natively first, then we can polyfill importmap in Firefox later if we still want to. But MS Edge is now built on Chromium, so at least the tests currently cover a large user base.

},
test: {
configFile: './test/karma.conf.js',
configFile: './test/karma.conf.cjs',
},
examples: {
configFile: './test/examples/karma.conf.js',
configFile: './test/examples/karma.conf.cjs',
},
workersocket: {
configFile: './test/workersocket/karma.conf.js',
configFile: './test/workersocket/karma.conf.cjs',
},
},
mochaTest: {
Expand Down Expand Up @@ -72,14 +79,14 @@ module.exports = function(grunt) {
files: [
'./src/**/*.js'
],
tasks: ['browserify']
tasks: ['shell:build']
},
build_and_watch: {
options: {
interrupt: true
},
files: [
'Gruntfile.js',
'Gruntfile.cjs',
'.jshintrc',
'./src/**/*.js'
],
Expand All @@ -105,12 +112,19 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('dev', ['browserify', 'watch']);
grunt.registerTask('test', ['jshint', 'mochaTest:test', 'karma:test']);
grunt.registerTask('test-examples', ['mochaTest:examples', 'karma:examples']);
grunt.registerTask('test-tcp', ['mochaTest:tcp']);
grunt.registerTask('dev', ['shell:build', 'watch']);

// grunt.registerTask('test', ['lint', 'mochaTest:test', 'karma:test']);
// grunt.registerTask('test-examples', ['mochaTest:examples', 'karma:examples']);
// grunt.registerTask('test-tcp', ['mochaTest:tcp']);
grunt.registerTask('test', ['lint', 'shell:mochaTest', 'karma:test']);
grunt.registerTask('test-examples', ['shell:mochaExamples', 'karma:examples']);
grunt.registerTask('test-tcp', ['shell:mochaTcp']);

grunt.registerTask('test-workersocket', ['karma:workersocket']);
grunt.registerTask('build', ['browserify', 'uglify']);
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',]);
};
Loading