Skip to content

[Dove] Drop reliance on legacy runtime compatibility settings #2748

@FossPrime

Description

@FossPrime

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:

  1. Use tsup to automatically wrap the typescript modules for cjs and esm import.
  2. Drop support for CommonJs projects in new versions and only build for ES modules

Workarounds

  1. Using esno
  2. manually pick and hunt for dependencies within the CJS package

Additional Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions