Should optional chaining operator get transpiled in `@babylonjs/materials` package?

Hello,

Optional chaining operator is used in all @babylonjs packages, for example in core at Babylon.js/packages/dev/core/src/scene.ts at master · BabylonJS/Babylon.js · GitHub

engine.currentRenderPassId = this.activeCamera?.renderPassId ?? currentRenderPassId;

When published as a .js file it is converted to something like:

engine.currentRenderPassId = (_b = (_a = this.activeCamera) === null || _a === void 0 ? void 0 : _a.renderPassId) !== null && _b !== void 0 ? _b : currentRenderPassId;

BUT for @babylonjs/materials package it doesn’t seem to be the case. For example, source code at Babylon.js/packages/dev/materials/src/custom/customMaterial.ts at 439e356a7928d7d2817c73b18ff99b6d1a0a04d9 · Popov72/Babylon.js · GitHub

CUSTOM_VERTEX_DEFINITIONS: (this._customUniform?.join("\n") || "") + (this.CustomParts.Vertex_Definitions || ""),

is then published without changes:

CUSTOM_VERTEX_DEFINITIONS: (this._customUniform?.join("\n") || "") + (this.CustomParts.Vertex_Definitions || ""),

Is this an expected behaviour?

I’m asking to know if I need to transpile @babylonjs/materials package myself to satisfy an older build target.

I’m using version 6.41.0.

Thank you!

We have switched to es2020 in our latest packages, so optional chaining should stay as-is (i.e. - no changes). If it is not it’s an error on our end and we will fix it :slight_smile:

Got it, thank you!

1 Like