[ 
https://issues.apache.org/jira/browse/THRIFT-6130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6130.
--------------------------------
    Fix Version/s: 0.25.0
       Resolution: Fixed

> Node.js library cannot load in CommonJS environments with ESM-only uuid 
> dependency
> ----------------------------------------------------------------------------------
>
>                 Key: THRIFT-6130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6130
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Library
>    Affects Versions: 0.23.0, 0.24.0
>            Reporter: Vikrant Puppala
>            Priority: Major
>             Fix For: 0.25.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> h3. Problem
> The Node.js runtime package is CommonJS, but thrift 0.23.0 and 0.24.0 load 
> uuid synchronously from binary_protocol.js and compact_protocol.js:
> {code:javascript}
> const { parse: uuidParse, stringify: uuidStringify } = require("uuid");
> {code}
> The published dependency ranges resolve to uuid 13.x or 14.x. uuid removed 
> CommonJS support in version 12, so CommonJS consumers and tools that do not 
> transform ESM inside node_modules cannot load thrift.
> h3. Reproduction
> {code:bash}
> mkdir thrift-commonjs-repro
> cd thrift-commonjs-repro
> npm init -y
> npm install [email protected] [email protected]
> {code}
> Create index.test.js:
> {code:javascript}
> const thrift = require("thrift");
> test("loads from CommonJS", () => {
>   expect(thrift).toBeDefined();
> });
> {code}
> Then run:
> {code:bash}
> npx jest --runInBand
> {code}
> The suite fails before executing any test:
> {code}
> node_modules/uuid/dist-node/index.js:1
> export { default as MAX } from './max.js';
> ^^^^^^
> SyntaxError: Unexpected token 'export'
> {code}
> The same failure occurs through @databricks/[email protected]. A complete downstream 
> report is available at 
> https://github.com/databricks/databricks-sql-nodejs/issues/461.
> h3. Expected behavior
> A CommonJS consumer should be able to load the CommonJS thrift package 
> without custom ESM transforms or root-level dependency overrides.
> h3. Proposed fix
> Remove the runtime uuid dependency from the Node.js library and provide the 
> UUID parse/stringify operations internally. Add direct tests for UUID 
> validation and binary/compact protocol round trips, plus a CommonJS 
> package-load regression test.
> This avoids coupling the CommonJS runtime to uuid's module format and 
> prevents the same regression on future uuid major releases.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to