Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mime package is getting esm only #60

Open
2 tasks done
Uzlopak opened this issue Nov 30, 2023 · 14 comments
Open
2 tasks done

mime package is getting esm only #60

Uzlopak opened this issue Nov 30, 2023 · 14 comments

Comments

@Uzlopak
Copy link
Contributor

Uzlopak commented Nov 30, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

We depend on mime. Some people would like to see the world break. Maybe we should avoid that...

@climba03003
Copy link
Member

It still fine by using dynamic import.
lazy load inside the place where using it.

@mcollina
Copy link
Member

We can stay on the old version for as long as we want.

@thelinuxlich
Copy link

Mime 3.0 is broken right now, package managers are complaining about it, should update to 4.0

@gurgunday
Copy link
Member

What are they complaining about?

All is fine on my end

@thelinuxlich
Copy link

With TS:
image

You have to override @types/mime to version 3.0.4 to stop this error

@mcollina
Copy link
Member

mcollina commented Apr 1, 2024

I guess it sounds a good idea for a fork and embed the types 🫠😅

@gurgunday
Copy link
Member

I can do this, but after Wednesday

So someone else who is willing can do it before

@climba03003
Copy link
Member

climba03003 commented Apr 2, 2024

I don't understand the problem here.
We do not use @types/mime inside this codebase or not even reference the @types/mime.

@thelinuxlich
Where is the problem of @types/mime linked to us?
What is the package manager complain on this repo?

@thelinuxlich
Copy link

You don't but TS checks for it when interacting with the mime sub dependency

@climba03003

This comment was marked as outdated.

@climba03003
Copy link
Member

climba03003 commented Apr 2, 2024

Here is the minimal check to see if missing @types/mime causing problem.
No complain of the problem you shown, and no need to install @types/mime.

Can you provide the usage showing the error you mention?

index.ts

import { send } from '@fastify/send'
import { createServer } from 'node:http'

createServer(function onRequest(req, res) {
  send(req, './index.ts')
    .pipe(res)
}).listen(3000)

package.json

{
  "name": "repo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "ts-node index.ts",
    "build": "tsc index.ts"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@fastify/send": "^2.1.0"
  },
  "devDependencies": {
    "@types/node": "^20.12.2",
    "ts-node": "^10.9.2",
    "typescript": "^5.4.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "strict": true
  }
}

@thelinuxlich
Copy link

Here's another package using the same version and impacted by mime 3.0 on TS : googleapis/nodejs-storage#2434

@thelinuxlich
Copy link

Another one: firebase/firebase-admin-node#2512

@climba03003
Copy link
Member

climba03003 commented Apr 2, 2024

I don't see googleapis/nodejs-storage impacted, it is using the correct types @types/mime@3.
You need to figure out which exact package linked the faulty version of @types/mime@4.

For firebase/firebase-admin-node, it is not the issue of the package either.
The wrong version comes from @types/serve-static and that is the package need to be updated.
I see how the proper fix is provided.
DefinitelyTyped/DefinitelyTyped#69231

None of your issue show the issue exist inside this repository.
I do think that adding a friendly reminder for TypeScript user is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants