or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-generators.mdclass-system.mddecorators.mddestructuring.mdindex.mdmodule-interop.mdprivate-fields.mdtype-system.mdutilities.md

module-interop.mddocs/

0

# Module Interoperability Helpers

1

2

Helpers for handling different module systems and import/export patterns between CommonJS and ES modules.

3

4

## Capabilities

5

6

### Import Helpers

7

8

#### _interop_require_default

9

10

Handles default imports from CommonJS modules.

11

12

```javascript { .api }

13

/**

14

* Handles default imports from CommonJS modules

15

* @param {any} obj - Module object to check

16

* @returns {any} Object with __esModule handling

17

*/

18

function _interop_require_default(obj): any;

19

```

20

21

**Usage Example:**

22

23

```javascript

24

// For: import defaultExport from "commonjs-module";

25

const defaultExport = _interop_require_default(require("commonjs-module")).default;

26

```

27

28

#### _interop_require_wildcard

29

30

Handles namespace imports from CommonJS modules.

31

32

```javascript { .api }

33

/**

34

* Handles namespace imports from CommonJS modules

35

* @param {any} obj - Module object to convert

36

* @param {boolean} nodeInterop - Node.js interop mode

37

* @returns {any} Namespace object

38

*/

39

function _interop_require_wildcard(obj, nodeInterop): any;

40

```

41

42

**Usage Example:**

43

44

```javascript

45

// For: import * as namespace from "commonjs-module";

46

const namespace = _interop_require_wildcard(require("commonjs-module"));

47

```

48

49

### Export Helpers

50

51

#### _export_star

52

53

Handles export * statements.

54

55

```javascript { .api }

56

/**

57

* Handles export * statements

58

* @param {Object} from - Source module object

59

* @param {Object} to - Target module object

60

* @param {Set} excludes - Properties to exclude from export

61

*/

62

function _export_star(from, to, excludes): void;

63

```

64

65

**Usage Example:**

66

67

```javascript

68

// For: export * from "./other-module";

69

_export_star(require("./other-module"), exports);

70

```