Skip to content

Commit

Permalink
convert to type:module in package.json, add an esm test using Webpack…
Browse files Browse the repository at this point in the history
… which caught a few errors
  • Loading branch information
trusktr committed Oct 1, 2021
1 parent a47c609 commit f1eff92
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
12 changes: 8 additions & 4 deletions Gruntfile.js → Gruntfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ module.exports = function(grunt) {
shell: {
build: {
command: 'rollup -c'
}
},
'test-esm': {
command: 'webpack --config esm-test.webpack.config.js'
},
},
karma: {
build: {
configFile: './test/karma.conf.js',
configFile: './test/karma.conf.cjs',
singleRun: true,
browsers: process.env.CI ? ['FirefoxHeadless'] : ['Firefox'] // eslint-disable-line
}
Expand Down Expand Up @@ -77,10 +80,11 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('gruntify-eslint');

grunt.registerTask('build', ['eslint:lint', 'shell']);
grunt.registerTask('build', ['eslint:lint', 'shell:build']);
grunt.registerTask('build_and_watch', ['build', 'watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
grunt.registerTask('lint', ['eslint:lint',]);
grunt.registerTask('lint-fix', ['eslint:fix',]);
grunt.registerTask('test', ['karma',]);
grunt.registerTask('test', ['test-esm', 'karma',]);
grunt.registerTask('test-esm', ['shell:test-esm']);
};
12 changes: 12 additions & 0 deletions esm-test.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// We run a simple Webpack build to ensure that the code base follows Node ESM
// standards. Any error from Webpack will indicate a problem. This will catch
// cases like missing `.js` etensions in import specifiers, etc.

export default {
entry: './src/index.js',
output: {
filename: 'ros3djs-esm-test.js',
path: '/tmp'
},
mode: 'development',
};
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "BSD-3-Clause",
"main": "./build/ros3d.cjs.js",
"module": "./build/ros3d.esm.js",
"type": "module",
"dependencies": {
"roslib": "^1.0.0",
"three": "^0.89.0"
Expand All @@ -32,17 +33,20 @@
"mocha": "^9.0.1",
"rollup": "^2.47.0",
"rollup-plugin-filesize": "^9.1.0",
"rollup-plugin-terser": "^7.0.0"
"rollup-plugin-terser": "^7.0.0",
"webpack": "^5.54.0",
"webpack-cli": "^4.8.0"
},
"repository": {
"type": "git",
"url": "https://github.com/RobotWebTools/ros3djs/releases"
},
"scripts": {
"build": "grunt build",
"lint": "grunt lint",
"lint-fix": "grunt lint-fix",
"test": "grunt test"
"build": "npm run grunt -- build",
"lint": "npm run grunt -- lint",
"lint-fix": "npm run grunt -- lint-fix",
"test": "npm run grunt -- test",
"grunt": "grunt --gruntfile Gruntfile.cjs"
},
"keywords": [
"ROS",
Expand Down
4 changes: 2 additions & 2 deletions src/interactivemarkers/InteractiveMarkerControl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import THREE from '../../shims/three/core.js';
import ROSLIB from '../../shims/roslib/ROSLIB.js';

import { INTERACTIVE_MARKER_MOVE_ROTATE_3D, INTERACTIVE_MARKER_MOVE_3D, INTERACTIVE_MARKER_MOVE_AXIS, INTERACTIVE_MARKER_ROTATE_AXIS, INTERACTIVE_MARKER_MOVE_PLANE, INTERACTIVE_MARKER_BUTTON, INTERACTIVE_MARKER_NONE, INTERACTIVE_MARKER_INHERIT, INTERACTIVE_MARKER_FIXED, INTERACTIVE_MARKER_VIEW_FACING } from '../Ros3D';
import { Marker } from '../markers/Marker';
import { INTERACTIVE_MARKER_MOVE_ROTATE_3D, INTERACTIVE_MARKER_MOVE_3D, INTERACTIVE_MARKER_MOVE_AXIS, INTERACTIVE_MARKER_ROTATE_AXIS, INTERACTIVE_MARKER_MOVE_PLANE, INTERACTIVE_MARKER_BUTTON, INTERACTIVE_MARKER_NONE, INTERACTIVE_MARKER_INHERIT, INTERACTIVE_MARKER_FIXED, INTERACTIVE_MARKER_VIEW_FACING } from '../Ros3D.js';
import { Marker } from '../markers/Marker.js';

/**
* @author David Gossow - dgossow@willowgarage.com
Expand Down
2 changes: 1 addition & 1 deletion src/interactivemarkers/InteractiveMarkerHandle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ROSLIB from '../../shims/roslib/ROSLIB.js';
import { EventEmitter2 } from '../../shims/eventemitter2/EventEmitter2.js';

import { INTERACTIVE_MARKER_POSE_UPDATE, INTERACTIVE_MARKER_BUTTON_CLICK, INTERACTIVE_MARKER_MOUSE_DOWN, INTERACTIVE_MARKER_MOUSE_UP, INTERACTIVE_MARKER_MENU_SELECT } from '../Ros3D';
import { INTERACTIVE_MARKER_POSE_UPDATE, INTERACTIVE_MARKER_BUTTON_CLICK, INTERACTIVE_MARKER_MOUSE_DOWN, INTERACTIVE_MARKER_MOUSE_UP, INTERACTIVE_MARKER_MENU_SELECT } from '../Ros3D.js';

/**
* @author David Gossow - dgossow@willowgarage.com
Expand Down
4 changes: 2 additions & 2 deletions src/markers/MarkerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import THREE from '../../shims/three/core.js';
import { EventEmitter2 } from '../../shims/eventemitter2/EventEmitter2.js';
import ROSLIB from '../../shims/roslib/ROSLIB.js';

import { Marker } from './Marker';
import { SceneNode } from '../visualization/SceneNode';
import { Marker } from './Marker.js';
import { SceneNode } from '../visualization/SceneNode.js';

/**
* @author Russell Toris - rctoris@wpi.edu
Expand Down
File renamed without changes.

0 comments on commit f1eff92

Please sign in to comment.