Running the Quick Start with typescript defaults returns the following error when executed with tsc app.ts unless a tsconfig file is made and a handful of legacy compatibility features are turned on.
SyntaxError: The requested module '@feathersjs/koa' does not provide an export named 'bodyParser'
Reproduction: https://stackblitz.com/edit/node-lzf6x8?file=package.json,app.ts
Upon some debugging, body parser is not exported at top level... but in a property called default:
❯ tsx
Welcome to tsx v3.9.0 (Node.js v16.14.2).
Type ".help" for more information.
> import('@feathersjs/koa').then(console.log)
Promise { <unknown> }
> [Module: null prototype] {
default: {
Koa: [Getter],
bodyParser: [Getter],
koa: [Function: koa],
parseAuthentication: [Getter],
authenticate: [Getter],
errorHandler: [Getter],
formatter: [Getter],
rest: [Getter]
},
__esModule: true,
koa: [Function: koa],
authenticate: [Function: authenticate],
parseAuthentication: [Function: parseAuthentication],
errorHandler: [Function: errorHandler],
rest: [Function: rest],
formatter: [Function: formatter]
}
Proposed Solutions:
- Use tsup to automatically wrap the typescript modules for cjs and esm import.
- Drop support for CommonJs projects in new versions and only build for ES modules
Workarounds
- Using esno
- manually pick and hunt for dependencies within the CJS package
Additional Notes
Reactions are currently unavailable
Running the Quick Start with typescript defaults returns the following error when executed with tsc app.ts unless a tsconfig file is made and a handful of legacy compatibility features are turned on.
SyntaxError: The requested module '@feathersjs/koa' does not provide an export named 'bodyParser'
Reproduction: https://stackblitz.com/edit/node-lzf6x8?file=package.json,app.ts
Upon some debugging, body parser is not exported at top level... but in a property called default:
❯ tsx Welcome to tsx v3.9.0 (Node.js v16.14.2). Type ".help" for more information. > import('@feathersjs/koa').then(console.log) Promise { <unknown> } > [Module: null prototype] { default: { Koa: [Getter], bodyParser: [Getter], koa: [Function: koa], parseAuthentication: [Getter], authenticate: [Getter], errorHandler: [Getter], formatter: [Getter], rest: [Getter] }, __esModule: true, koa: [Function: koa], authenticate: [Function: authenticate], parseAuthentication: [Function: parseAuthentication], errorHandler: [Function: errorHandler], rest: [Function: rest], formatter: [Function: formatter] }Proposed Solutions:
Workarounds
Additional Notes