prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

`slice-machine-ui` relies on `node-fetch` but doesn't declare it as a dependency, causing dependencies mismatch #216

Closed lihbr closed 1 year ago

lihbr commented 2 years ago

Versions

What is going on

Currently slice-machine-ui doesn't declare node-fetch as a dependency but relies on it.

node-fetch being a very common dependency, it's likely there. However because it's common npm tries to duplicate it when installing dependencies.

Slice Machine expects version 2 of node-fetch to be available, however the latest version of node-fetch is now an ESM package only. This causes when npm prefers to dedupe node-fetch@3 instead of node-fatch@2, causing slice-machine-ui to fail.

node-fetch@3 being deduped:
![image](https://user-images.githubusercontent.com/25330882/140501183-c8f48380-57f5-438e-8d57-5bc4e3853bd2.png)
slice-machine-ui failing because of it:
![image](https://user-images.githubusercontent.com/25330882/140501300-dcf46e35-1d0d-46c1-b076-b76b15ee0eaf.png)

How to fix

Install node-fetch@2 as a dependency of slice-machine-ui

lihbr commented 2 years ago

It appears node-fetch is now being used by sm-commons (https://github.com/prismicio/slice-machine/blob/master/packages/sm-commons/methods/communication.js#L1) without being declared as a dependency of said package: https://github.com/prismicio/slice-machine/blob/master/packages/sm-commons/package.json#L27-L36

I don't know if this code is still in use, if yes, the issue remains.

mdeclercq commented 1 year ago

Hi @lihbr, This has been fixed in the release 1.0.0. Feel free to re-open the issue if needed. Thanks,