• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RobotWebTools / rclnodejs / 27193208698

09 Jun 2026 08:17AM UTC coverage: 91.22% (+5.7%) from 85.523%
27193208698

push

github

web-flow
Phase 2: convert lib/, index.js and tests to native ES modules (#1530)

**Overview:** 189 files changed, +957 / −1162. Converts `lib/`, `index.js`, `bin/`, `rosocket/` and the full test suite to native ES modules; keeps build/codegen tooling as `.cjs`; updates CI to ROS 2 Lyrical (Ubuntu 26.04); and fixes a native-addon debug-build compile error.

### Core ESM conversion
- **`index.js`** — converted to ESM entrypoint (`import`/`export`), module wiring reworked.
- **`lib/**`** — all library modules converted from `require`/`module.exports` to `import`/`export` (node, client, service, publisher, subscription, action/*, clock*, parameter*, logging*, runtime/*, serialization, time*, timer, qos*, utils, validator, native_loader, etc.).
- **`bin/rclnodejs-web.js`**, **`rosocket/index.js`**, **`rosocket/cli.js`** — converted to ESM.

### ESM/CJS boundary fixes (from Copilot review)
- **`lib/native_loader.js`** — load the CommonJS `bindings` helper via `createRequire`'s `require('bindings')` instead of `import bindings from 'bindings'`, preserving CJS caller context for addon resolution.
- **`lib/type_description_service.js`** — corrected sibling import from `'../lib/parameter.js'` to `'./parameter.js'`.

### CommonJS files kept as `.cjs`
- **`rosidl_gen/*.cjs`** (deallocator, idl_generator, index, primitive_types, templates/message-template), **`rostsd_gen/index.cjs`**, **`scripts/ros_distro.cjs`**, **`scripts/run_test.cjs`** — build/codegen tooling stays CJS (loads ESM helpers via supported `require(esm)` / `.default`).
- **`third_party/ref-napi/`** — `lib/ref.js` and `package.json` tweaks for module resolution.

### Tooling / config
- **`package.json`** — `"type": "module"` and script adjustments.
- **`eslint.config.mjs`** — ESM lint rules.
- **`.c8rc.json`** added, **`.nycrc.yml`** removed — switch coverage from nyc to c8.

### CI
- **`.github/workflows/linux-x64-asan-test.yml`**, **`.github/workflows/linux-x64-build-and-test.yml`** — migrated from ROS 2 ... (continued)

2044 of 2402 branches covered (85.1%)

Branch coverage included in aggregate %.

369 of 370 new or added lines in 65 files covered. (99.73%)

942 existing lines in 47 files now uncovered.

16688 of 18133 relevant lines covered (92.03%)

228.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.07
/lib/node_options.js
1
//
27✔
2
// Licensed under the Apache License, Version 2.0 (the "License");
27✔
3
// you may not use this file except in compliance with the License.
27✔
4
// You may obtain a copy of the License at
27✔
5
//
27✔
6
//     http://www.apache.org/licenses/LICENSE-2.0
27✔
7
//
27✔
8
// Unless required by applicable law or agreed to in writing, software
27✔
9
// distributed under the License is distributed on an "AS IS" BASIS,
27✔
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27✔
11
// See the License for the specific language governing permissions and
27✔
12
// limitations under the License.
27✔
13

27✔
14
import { Parameter } from './parameter.js';
27✔
15
/**
27✔
16
 * NodeOptions specify configuration choices during the
27✔
17
 * node instantiation process.
27✔
18
 * @class
27✔
19
 */
27✔
20
class NodeOptions {
27✔
21
  /**
27✔
22
   * Create a new instance with default property values.
27✔
23
   * @constructor
27✔
24
   * @param {boolean} [startParameterServices=true]
27✔
25
   * @param {array} [parameterOverrides=[]]
27✔
26
   * @param {boolean} [automaticallyDeclareParametersFromOverrides=false]
27✔
27
   * @param {boolean} [startTypeDescriptionService=true]
27✔
28
   * @param {boolean} [enableRosout=true]
27✔
29
   * @param {QoS} [rosoutQos=QoS.profileDefault]
27✔
30
   * @param {boolean} [enableLoggerService=false]
27✔
31
   */
27✔
32
  constructor(
27✔
33
    startParameterServices = true,
969✔
34
    parameterOverrides = [],
969✔
35
    automaticallyDeclareParametersFromOverrides = false,
969✔
36
    startTypeDescriptionService = true,
969✔
37
    enableRosout = true,
969✔
38
    rosoutQos = null,
969✔
39
    enableLoggerService = false
969✔
40
  ) {
969✔
41
    this._startParameterServices = startParameterServices;
969✔
42
    this._parameterOverrides = parameterOverrides;
969✔
43
    this._automaticallyDeclareParametersFromOverrides =
969✔
44
      automaticallyDeclareParametersFromOverrides;
969✔
45
    this._startTypeDescriptionService = startTypeDescriptionService;
969✔
46
    this._enableRosout = enableRosout;
969✔
47
    this._rosoutQos = rosoutQos;
969✔
48
    this._enableLoggerService = enableLoggerService;
969✔
49
  }
969✔
50

27✔
51
  /**
27✔
52
   * Get the startParameterServices option.
27✔
53
   * Default value = true;
27✔
54
   * @returns {boolean} -
27✔
55
   */
27✔
56
  get startParameterServices() {
27✔
57
    return this._startParameterServices;
936✔
58
  }
936✔
59

27✔
60
  /**
27✔
61
   * Set startParameterServices.
27✔
62
   * @param {boolean} startFlag - True indicates for a node to start it's parameter_service.
27✔
63
   */
27✔
64
  set startParameterServices(startFlag) {
27✔
65
    this._startParameterServices = startFlag;
6✔
66
  }
6✔
67

27✔
68
  /**
27✔
69
   * Get the parameterOverrides.
27✔
70
   * @return {Parameter[]} - An array of Parameters that serve as overrides for a node's default
27✔
71
   *   parameters. Default = empty array [].
27✔
72
   */
27✔
73
  get parameterOverrides() {
27✔
74
    return this._parameterOverrides;
959✔
75
  }
959✔
76

27✔
77
  /**
27✔
78
   * Set the Parameters that will serve to override a node's default parameter settings.
27✔
79
   * Setting to null, reinitializes the parameterOverrides to an empty array.
27✔
80
   * @param {Parameter|Parameter[]} parameters - A single parameter or parameter[].
27✔
81
   *    Default is an empty array.
27✔
82
   */
27✔
83
  set parameterOverrides(parameters = []) {
27✔
84
    let povalue = parameters;
11✔
85

11✔
86
    if (!povalue) {
11✔
87
      povalue = [];
1✔
88
    } else if (povalue instanceof Parameter) {
11✔
89
      // a single parameter
1✔
90
      povalue = [povalue];
1✔
91
    } else if (!Array.isArray(parameters)) {
10✔
92
      throw TypeError('Expected Parameter[]');
1✔
93
    }
1✔
94

10✔
95
    this._parameterOverrides = povalue;
10✔
96
  }
11✔
97

27✔
98
  /**
27✔
99
   * Get the automaticallyDeclareParametersFromOverrides.
27✔
100
   *
27✔
101
   * @returns {boolean} - True indicates that a node should declare parameters from
27✔
102
   *    it's parameter-overrides
27✔
103
   */
27✔
104
  get automaticallyDeclareParametersFromOverrides() {
27✔
105
    return this._automaticallyDeclareParametersFromOverrides;
937✔
106
  }
937✔
107

27✔
108
  /**
27✔
109
   * Set automaticallyDeclareParametersFromOverrides.
27✔
110
   *
27✔
111
   * @param {boolean} declareParamsFlag - When true, a node will declare parameters from all
27✔
112
   * parameter-overrides.
27✔
113
   */
27✔
114
  set automaticallyDeclareParametersFromOverrides(declareParamsFlag) {
27✔
115
    this._automaticallyDeclareParametersFromOverrides = declareParamsFlag;
6✔
116
  }
6✔
117

27✔
118
  /**
27✔
119
   * Get the startTypeDescriptionService option, only available for ROS2 > Humble.
27✔
120
   * Default value = true;
27✔
121
   * @returns {boolean} - true if the type description service is enabled.
27✔
122
   */
27✔
123
  get startTypeDescriptionService() {
27✔
124
    return this._startTypeDescriptionService;
934✔
125
  }
934✔
126

27✔
127
  /**
27✔
128
   * Set startTypeDescriptionService, only available for ROS2 > Humble
27✔
129
   * @param {boolean} willStartTypeDescriptionService
27✔
130
   */
27✔
131
  set startTypeDescriptionService(willStartTypeDescriptionService) {
27✔
132
    this._startTypeDescriptionService = willStartTypeDescriptionService;
×
UNCOV
133
  }
×
134

27✔
135
  /**
27✔
136
   * Get the enableRosout option.
27✔
137
   * Default value = true;
27✔
138
   * @returns {boolean} - true if the rosout logging is enabled.
27✔
139
   */
27✔
140
  get enableRosout() {
27✔
141
    return this._enableRosout;
934✔
142
  }
934✔
143

27✔
144
  /**
27✔
145
   * Set enableRosout.
27✔
146
   * @param {boolean} enableRosout
27✔
147
   */
27✔
148
  set enableRosout(enableRosout) {
27✔
149
    this._enableRosout = enableRosout;
3✔
150
  }
3✔
151

27✔
152
  /**
27✔
153
   * Get the rosoutQos option.
27✔
154
   * @returns {QoS} - The QoS profile for rosout.
27✔
155
   */
27✔
156
  get rosoutQos() {
27✔
157
    return this._rosoutQos;
945✔
158
  }
945✔
159

27✔
160
  /**
27✔
161
   * Set rosoutQos.
27✔
162
   * @param {QoS} rosoutQos
27✔
163
   */
27✔
164
  set rosoutQos(rosoutQos) {
27✔
165
    this._rosoutQos = rosoutQos;
1✔
166
  }
1✔
167

27✔
168
  /**
27✔
169
   * Get the enableLoggerService option.
27✔
170
   * Default value = false;
27✔
171
   * @returns {boolean} - true if logger services are enabled.
27✔
172
   */
27✔
173
  get enableLoggerService() {
27✔
174
    return this._enableLoggerService;
937✔
175
  }
937✔
176

27✔
177
  /**
27✔
178
   * Set enableLoggerService.
27✔
179
   * @param {boolean} enableLoggerService
27✔
180
   */
27✔
181
  set enableLoggerService(enableLoggerService) {
27✔
182
    this._enableLoggerService = enableLoggerService;
1✔
183
  }
1✔
184

27✔
185
  /**
27✔
186
   * Return an instance configured with default options.
27✔
187
   * @returns {NodeOptions} - An instance with default values.
27✔
188
   */
27✔
189
  static get defaultOptions() {
27✔
190
    return new NodeOptions();
953✔
191
  }
953✔
192
}
27✔
193

27✔
194
export default NodeOptions;
27✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc