Skip to content

[node-core-library] Replace static classes with exported module namespace objects #5434

@dmichon-msft

Description

@dmichon-msft

Summary

While preserving the implementations and outward-facing API shape (All consumers of the refactored APIs should not need any code changes to compile and test successfully), replace static classes like:

./FileSystem.ts

export class FileSystem {
  public static someApi(...): TResult { ... }
}

with a reexported module namespace object that forwards individual exports for single files:

./FileSystem.ts

import * as FileSystem from './fileSystem/index';

./fileSystem/index.ts

export { someApi } from './someApi';

./fileSystem/someApi.ts

export function someApi(...): TResult { ... }

The Disposables and Objects APIs are existing examples of the new pattern. FileSystem and Text are examples of the old pattern to be replaced.

The reason for this conversion is that module namespace objects can be tree-shaken by modern bundlers, but static members on classes cannot.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Low priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions