hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
116 stars 30 forks source link

Dependencies: Move Dependencies to PeerDependencies #15

Closed meck93 closed 2 years ago

meck93 commented 2 years ago

Hi @cvolant

Thanks a lot for the work on this project! I have a question/suggestion since this is a library can we move the dependencies to dependencies and peerDependencies. As I understand it the library currently requires the exact version of the specified packages or higher, correct?

I would be happy to provide a PR.

old

  "dependencies": {
    "next": "^12.0.4",
    "path-to-regexp": "^6.2.0",
    "querystring": "^0.2.1",
    "react": "^17.0.2",
    "yamljs": "^0.3.0"
  },

new

  "peerDependencies": {
    "next": "^12.x",
    "path-to-regexp": "^6.x",
    "querystring": "^0.2.x",
    "react": "^17.x",
    "yamljs": "^0.3.x"
  },
  "devDependencies": {
    ...existingDevDependencies,
    "next": "12.0.4",
    "react": "17.0.4",
    "path-to-regexp": "6.2.0",
    "querystring": "0.2.1",
    "yamljs": "0.3.0"
  },
cvolant commented 2 years ago

Yes you are right. I even started to do it some days ago. I am not sure about path-to-regexp and yamljs thought, because users of next-translate-routes are supposed to use next and react, but not path-to-regexp and yamljs. What do you think?

And I think this would allow using next 11 and react 16.8:

  "next": ">=11.x",
  "react": ">=16.8"
meck93 commented 2 years ago

I guess it depends. Are the dependencies "path-to-regexp": "6.2.0", "querystring": "0.2.1", "yamljs": "0.3.0" bundled into your library?

cvolant commented 2 years ago

Are the dependencies "path-to-regexp": "6.2.0", "querystring": "0.2.1", "yamljs": "0.3.0" bundled into your library?

I am not sure what you mean by "bundled into the library"... What is the difference between bundled and unbundled dependencies? Anyway, if you want to make a PR, you are welcome.

meck93 commented 2 years ago

I am not sure what you mean by "bundled into the library"... What is the difference between bundled and unbundled dependencies? Anyway, if you want to make a PR, you are welcome.

As a library author you can decide to list the dependencies your library needs as peer dependencies by this you tell the users of your library that you require them to install the dependencies when they want to use the library. For example, you can say that you support Next 11 and above using "next": ">=11.x".

On the other hand, it is possible to bundle dependencies into your library. This means that the dependencies of your library are provided/delivered with the library. They are packaged into the same NPM package. Often that doesn't make a lot of sense as you might end up with a lot of versions of the same dependencies (e.g., image if everyone bundled their version of react for a react library). But I think there exist use cases where this is helpful and desired...

I'm happy to make a PR 👍

cvolant commented 2 years ago

@meck93 In the new 1.7.1 version, I moved next and react to peerDependencies. Would you give it a look and tell me if it could be better ?

meck93 commented 2 years ago

@cvolant I think it looks good and makes sense this way. The library can anyway only be used together with Next and, therefore, React/Preact.