1

Hi everyone hope you all doing good,

I am trying to add a plugin to sanity and the plugin is sanity-plugin-order-documents .
I have followed all the steps shown in the documentation step by step.

I added "plugins": [ "order-documents" ], to sanity.json
And add this field :
{ name: "order", title: "Order", type: "number", hidden: true, },
to sanity\schemas\projects.js

.
And this is how I used the plugin in my code:

useEffect(() => {
    sanityClient.fetch(
      `
        *[_type == "projects"] | order(order asc){
        ...,
        }
      `
    ).then((data) => {
      setProjectsData(data)
    })
    
  }, [])

But whenever I try to do sanity start or sanity deploy I got this error :

Error: Errors while building:
./node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
Module parse failed: Unexpected token (307:11)
You may need an appropriate loader to handle this file type.
|   }
| 
|   return { ...rect,
|     x: rect.x - scroll.scrollLeft + offsets.x,
|     y: rect.y - scroll.scrollTop + offsets.y
 @ ./node_modules/react-select/dist/react-select.esm.js 24:0-26
 @ ./node_modules/sanity-plugin-order-documents/build/components/organisms/TypeSection.js
 @ ./node_modules/sanity-plugin-order-documents/build/components/OrderDocuments.js
 @ ./node_modules/sanity-plugin-order-documents/build/index.js
 @ ./node_modules/sanity-plugin-order-documents/build?sanityPart=all%3Apart%3A%40sanity%2Fbase%2Ftool
 @ ./node_modules/@sanity/default-layout/lib/util/getRegisteredTools.js
 @ ./node_modules/@sanity/default-layout/lib/router.js
 @ ./node_modules/@sanity/default-layout/lib/Root.js?sanityPart=part%3A%40sanity%2Fbase%2Froot
 @ ./node_modules/@sanity/base/lib/components/SanityRoot.js?sanityPart=part%3A%40sanity%2Fbase%2Fsanity-root
 @ ./node_modules/@sanity/server/lib/browser/entry.js
 @ multi ./node_modules/@sanity/server/lib/browser/entry.js
    at buildStaticAssets (C:/Users/Slima/Desktop/abdellah-slimani-portfolio/sanity/node_modules/@sanity/core/lib/actions/build/buildStaticAssets.js:103:13)
    at async _default (C:/Users/Slima/Desktop/abdellah-slimani-portfolio/sanity/node_modules/@sanity/core/lib/actions/deploy/deployAction.js:78:9)

I have done some research to solve this problem, and I see many people suggest to edit the webpack file but I have no idea about what to add to that file.

please send help, SOS.

3 Answers3

4

If you are using the sanity-plugin-media package, then you should update it to the newest version. This should resolve your issue!

larovski
  • 41
  • 2
  • I don't use that package at all, should I install it? – Abdellah Slimani Nov 29 '22 at 08:27
  • 1
    What packages are you using at the package.json of the sanity project. Maybe its another one. You can also check here if that solution works for you: https://github.com/ndimatteo/HULL/issues/110 – larovski Nov 29 '22 at 09:19
3

I ran into this issue just now and after doing some digging, it seems like Sanity v2 doesn't play well with react-select@^5. I had a look at some Sanity plugins that have upgraded react-select@^5 recently and all packages trigger this error message. You should bind the following packages to the latest version that has react-select smaller than 5.

yarn add or npm install

  • sanity-plugin-autocomplete-tags@1.0.0
  • sanity-plugin-media@1.4.13
  • sanity-plugin-order-documents@0.0.19
Aidan Marshall
  • 521
  • 6
  • 16
2

sanity-plugin-media@1.4.13 use >5. 1.4.10 works

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 03 '22 at 11:19