Skip to content

Commit

Permalink
fix: use nested optimizeDeps to resolve properly
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 10, 2024
1 parent 3e810a1 commit 1dab8e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 33 deletions.
8 changes: 0 additions & 8 deletions docs/content/1.getting-started/4.visual-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
Installing `@sanity/client` is required for visual editing. The `minimal` client must not be enabled.
::

::alert{type=warning}
If you are using `pnpm` with `shamefully-hoist=false` (which is enabled by default for pnpm), you will also need to install the following dependencies:

```bash
pnpm i -D async-cache-dedupe debug parse-headers react react-dom react-is
```
::

## Configuration

You can configure visual editing via the `sanity.visualEditing` key in your Nuxt config. The following options are available:
Expand Down
6 changes: 0 additions & 6 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
"dependencies": {
"@nuxtjs/sanity": "latest",
"@sanity/client": "latest",
"async-cache-dedupe": "latest",
"debug": "latest",
"nuxt": "3.10.3",
"parse-headers": "latest",
"react": "latest",
"react-dom": "latest",
"react-is": "latest",
"vue": "latest",
"vue-router": "latest"
}
Expand Down
18 changes: 0 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,22 @@ export default defineNuxtModule<SanityModuleOptions>({

if (options.visualEditing) {
// Optimise dependencies of visual editing
nuxt.options.build.transpile.push('async-cache-dedupe')
nuxt.options.vite.resolve = defu(nuxt.options.vite.resolve, {
dedupe: ['@sanity/client'],
})
nuxt.options.vite.optimizeDeps = defu(nuxt.options.vite.optimizeDeps, {
include: ['async-cache-dedupe', 'react/jsx-runtime', 'parse-headers', 'debug', 'react-dom/client', 'react-is', 'react', 'react-dom'],
include: [
'@nuxtjs/sanity > @sanity/core-loader > async-cache-dedupe',
'@nuxtjs/sanity > @sanity/visual-editing > @sanity/visual-editing > react-is',
'@nuxtjs/sanity > @sanity/visual-editing > react',
'@nuxtjs/sanity > @sanity/visual-editing > react/jsx-runtime',
'@nuxtjs/sanity > @sanity/visual-editing > react-dom',
'@nuxtjs/sanity > @sanity/visual-editing > react-dom/client',
'@sanity/client > get-it > debug',
'@sanity/client > get-it > parse-headers',
'@sanity/client',
],
})
// Add auto-imports for visual editing
if (isNuxt3()) {
Expand Down

0 comments on commit 1dab8e4

Please sign in to comment.