Hampus Adolfsson created THRIFT-6368:
----------------------------------------
Summary: js:node,esm generates require() for the parent of an
extended service
Key: THRIFT-6368
URL: https://issues.apache.org/jira/browse/THRIFT-6368
Project: Thrift
Issue Type: Bug
Components: Node.js - Compiler
Affects Versions: 0.24.0
Reporter: Hampus Adolfsson
With `--gen js:node,esm`, a service that `extends` another service is generated
with a CommonJS
`require()` for the parent service, while the rest of the file uses ESM
`import`s:
{code:js}
import
{ Thrift }
from 'thrift';
...
const Base = require('./Base.mjs');
const BaseClient = Base.Client;
const BaseProcessor = Base.Processor;
import * as ttypes from './derived_types.mjs';
{code}
Loading the file in Node fails:
{code}
ReferenceError: require is not defined in ES module scope, you can use import
instead
{code}
Reproduction:
{code}
service Base { string ping() }
service Derived extends Base { string hello() }
{code}
`thrift --gen js:node,esm test.thrift`, then `node -e
"import('./gen-nodejs/Derived.mjs')"`
--
This message was sent by Atlassian Jira
(v8.20.10#820010)