Skip to content

Angular 20 widget extensions: ReferenceError: ngDevMode is not defined when using Angular CDK components #128

Description

@codeion

Description

After updating to the latest thingsboard-extensions (Angular 20), widget extensions build successfully but fail at runtime when using Angular CDK components (for example @angular/cdk/scrolling).

The browser console reports:

ReferenceError: ngDevMode is not defined

The error occurs while ThingsBoard is instantiating the widget extension.

Environment

  • Latest thingsboard-extensions from master
  • Angular 20
  • Latest ThingsBoard PE (tested with widget extensions)

Steps to reproduce

  1. Clone the latest thingsboard-extensions repository.
  2. Create or use a widget extension that uses Angular CDK (for example cdk-virtual-scroll-viewport).
  3. Build the extension.
  4. Upload the generated widget extension to ThingsBoard.
  5. Open the widget.

Actual result

The widget fails during initialization with:

ReferenceError: ngDevMode is not defined

Expected result

The widget should initialize normally.

Temporary workaround

Adding the following line at the beginning of the extension entry point fixes the issue:

(globalThis as any).ngDevMode ??= false;

This suggests the extension bundle is executed before the global ngDevMode variable is available.

It would be great if the extension build or loader could initialize this automatically so extension developers do not need to add the workaround manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions