Jens-G opened a new pull request, #3903:
URL: https://github.com/apache/thrift/pull/3903

   Every file the JavaScript generator emits carried a `uuid` import:
   
   ```js
   if (typeof uuid === 'undefined' && typeof require === 'function') {
     var uuid = require('uuid').v4;
   }
   ```
   
   ```ts
   import { v4 as uuid } from 'uuid';
   type uuid = string;
   ```
   
   Nothing uses it. All five `TYPE_UUID` paths in `t_js_generator.cc` emit 
something else: reads
   become `readUuid()`, writes become `writeUuid(...)`, the type enum is 
`Thrift.Type.UUID`, and a
   `uuid` constant is rendered as a quoted string literal. Generating a program 
that does use `uuid`
   confirms it — the v4 function is never called there either. In the `.d.ts` 
the import is also
   shadowed for typing purposes by the `type uuid = string` alias on the very 
next line.
   
   The dead import is what drags `uuid` into the browser bundle, and browserify 
cannot parse it:
   
   ```
   Error: Parsing file node_modules/uuid/dist/cjs-browser/v1.js: Unexpected 
token (28:18)
   ```
   
   uuid 11 uses `??` and `?.`; the acorn that module-deps bundles is older than 
that. Upgrading
   browserify is not a way out — **17.0.1 fails identically**, verified against 
uuid 11.1.1.
   
   So the import is removed and the `type uuid = string` alias kept, since the 
generated field
   declarations resolve against it.
   
   Verified:
   
   - A program using `uuid` still declares `id: uuid`, `export declare var 
FIXED: uuid` and keeps
     the alias; its `.js` no longer mentions uuid at all.
   - `js:node,ts` output is unaffected apart from the same removal.
   - `shell:BrowserifyCompiledTS` in `make -C lib/ts check` completes instead 
of failing on the
     parse error above.
   
   A browser program that really uses `uuid` values is unaffected by this 
change either way: the
   values are plain strings, and nothing generated ever needed the generator 
function.
   
   This is the second of the blockers in front of the lib/ts test; THRIFT-6317 
is the first, and
   THRIFT-6319 tracks that nothing in the build or in CI runs that test at all.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to