Skip to content

[Storage] @azure/storage-common daily alpha builds ship ESM export default inside CJS file (dist/commonjs/crc64.js) — breaks every CJS consumer #38839

@kashish2508

Description

@kashish2508
  • Package Name: @azure/storage-common
  • Package Version: 12.4.0-alpha.20260603.3 (and every 12.4.0-alpha.* daily since at least 12.4.0-alpha.20260312.1 — ~3 months of broken dailies)
  • Operating system: Windows 11 (also reproducible on macOS/Linux — pure Node module-loading issue)
  • nodejs
    • version: v20.x / v22.x (any Node CJS consumer)
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug

Every 12.4.0-alpha.* daily build of @azure/storage-common ships a dist/commonjs/crc64.js whose final line is:

export default NativeCRC64;

That file lives under dist/commonjs/ and the package's nearest package.json does not set "type": "module", so Node loads it as CommonJS. ESM export syntax in a CJS file throws at parse time:

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1740:18)
    ...
    at Object.<anonymous> (.../node_modules/@azure/storage-common/dist/commonjs/StorageCRC64Calculator.js:33:28)

The crash cascades up through StorageCRC64Calculator.jsStructuredMessageEncoding.jsStructuredMessageEncodingStream.jsindex.js, and then through every package that depends on @azure/storage-common (including @azure/storage-blob, and transitively @azure/playwright alphas). Result: nothing depending on alpha storage-common can be loaded under Node CJS.

This is a build-pipeline regression — StorageCRC64Calculator.js consumes it as CJS:

var import_crc64 = __toESM(require("./crc64.js"));

so the file must export with module.exports = NativeCRC64;. The script that copies crc64.js into dist/commonjs/ (looks like copyJSFiles.cjs from the package's build scripts) is leaving the original ESM export default statement in place instead of rewriting it.

Also worth flagging: the latest dist-tag on the Azure SDK internal feed currently points at an alpha (latest: 12.4.0-alpha.20260312.1) rather than the real stable 12.3.0. Public npm correctly tags latest: 12.3.0, so end customers are unaffected — but anyone consuming the internal feed gets a broken "latest".

To Reproduce

Steps to reproduce the behavior:

  1. In a clean folder:

    mkdir repro && cd repro
    npm init -y
    npm install @azure/storage-common@12.4.0-alpha.20260603.3 \
      --registry=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/
  2. Try to load the package:

    node -e "require('@azure/storage-common')"
  3. Observe the SyntaxError: Unexpected token 'export' originating from node_modules/@azure/storage-common/dist/commonjs/crc64.js:2928.

  4. Same failure repros via any consumer — e.g. installing alpha @azure/playwright@1.1.6-alpha.20260604.3 and running npx playwright test crashes during reporter load with the same stack.

Inspect the file directly to confirm the malformed export:

tail -n 6 node_modules/@azure/storage-common/dist/commonjs/crc64.js

Output ends with export default NativeCRC64;.

Expected behavior

dist/commonjs/crc64.js should be a valid CommonJS module — its last line should be module.exports = NativeCRC64; (matching what StorageCRC64Calculator.js requires via __toESM(require("./crc64.js"))).

The corresponding ESM copy at dist/esm/crc64.js (or wherever the ESM build emits) can keep export default NativeCRC64;.

Additionally, the internal feed's latest dist-tag for @azure/storage-common should track stable 12.3.0, not an alpha.

Screenshots / Additional context

Local workaround until the daily build is fixed — patch the one line in dist/commonjs/crc64.js:

- export default NativeCRC64;
+ module.exports = NativeCRC64;

(Easily automated with patch-package.)

Metadata

Metadata

Assignees

Labels

StorageStorage Service (Queues, Blobs, Files)bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions