Azure / Azure/azure-functions-nodejs-extensions

Support ESM module export for @azure/functions-extensions-servicebus

Open
#61 3 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
2
Forks
8
PR merge metrics
No merged PRs in 30d

Description

## Summary

The package `@azure/functions-extensions-servicebus` does not export an ESM module, which forces consumers using ESM (`"type": "module"` in `package.json`) to set `verbatimModuleSyntax: false` in their `tsconfig.json`. This is not ideal for modern TypeScript projects.

## Current Behavior

- `package.json` exports both `import` and `require` pointing to the same CommonJS file:
```json
"exports": {
".": {
"import": "./dist/azure-functions-extensions-servicebus.js",
"require": "./dist/azure-functions-extensions-servicebus.js"
}
}
```
- The bundle is built with `libraryTarget: 'commonjs2'` (webpack)
- No `"type": "module"` in `package.json`
- No separate ESM output exists

## Expected Behavior

The package should provide a proper ESM export (e.g., separate `.mjs` or dual-package build) so that consumers can use it with `verbatimModuleSyntax: true` and ESM-native setups without workarounds.

## Customer Report

> The package does not export an ESM module, which forces us to set `verbatimModuleSyntax` to `false`. This isn't ideal for our setup. Are there any plans to support ESM modules properly?

## Workaround

Set `verbatimModuleSyntax: false` in `tsconfig.json`.

## Related Issues

- Azure/azure-functions-nodejs-worker#104 — Add ES6 Style Exports (OPEN, P1)
- Azure/azure-functions-nodejs-library#287 — Provide package as ESM alongside CommonJS module (OPEN, P1)
- Azure/azure-functions-nodejs-library#396 — Type error when using `verbatimModuleSyntax: true` (CLOSED)
- Azure/azure-functions-nodejs-library#397 — `.d.ts` files should not import `.ts` files (related)
- #26 — esbuild bundler compatibility issue (related but different)

## Context

The Azure Functions Node.js worker itself is CJS-based, and `@azure/functions-extensions-base` is also CJS-only. Full ESM support for this extension likely depends on the upstream worker and library ecosystem supporting ESM first.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.