Skip to content

Weird interaction between CJS and ESM for JSON modules, when using yarn #797

Description

@A5rocks

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

I provided the exact source below; I don't have a StackBlitz to upload it there.

Problem & expected behavior (under 200 words)

Make sure to use yarn.

package.lock:

{
  "name": "example",
  "version": "1.0.0",
  "type": "module",
  "packageManager": "yarn@4.14.1",
  "dependencies": {
    "http-errors": "^2.0.1"
  },
  "devDependencies": {
    "@types/http-errors": "^2",
    "tsx": "^4.22.3"
  }
}

src/index.ts:

import { errors } from "./errors.js";

errors;

src/errors.ts:

import { isHttpError } from "http-errors";

export const errors = () => {
  isHttpError;
};

Run:

  • yarn install
  • yarn tsx src/index.ts

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions