Skip to content

Commit

Permalink
fix: drop viteOptimizeDeps (in src/config.js) and remove it from …
Browse files Browse the repository at this point in the history
…the docs: not needed anymore
  • Loading branch information
josdejong committed Mar 7, 2022
1 parent 763e4f2 commit 1c64009
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
44 changes: 0 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,6 @@ npm install svelte-jsoneditor
- Plain JavaScript examples: [/examples/browser](/examples/browser)
- React example: [https://codesandbox.io/s/svelte-jsoneditor-react-59wxz](https://codesandbox.io/s/svelte-jsoneditor-react-59wxz)

### SvelteKit setup

There is currently an issue in SvelteKit with processing some dependencies (more precisely: Vite used by SvelteKit). `svelte-jsoneditor` depends on some libraries that hit this issue. To work around it, each of these dependencies needs to be listed in the configuration. Without the workaround, you'll see errors like "ReferenceError: module is not defined" (for `debug`, `ajv`, `ace-builds`, etc.).

In your SvelteKit configuration file `svelte.config.js`, add the list with dependencies `viteOptimizeDeps`, available in the `svelte-jsoneditor/config.js`, and use that in the configuration of vite (`config.kit.vite.optimizeDeps.include`):

```js
// svelte.config.js

// ...
import { viteOptimizeDeps } from 'svelte-jsoneditor/config'

const config = {
// ...
kit: {
// ...
vite: {
optimizeDeps: {
include: [...viteOptimizeDeps]
}
}
}
}

// ...
```

Alternatively, it's possible to set `experimental.prebundleSvelteLibraries` to `true` in your `svelte.config.js` file:

```js
// svelte.config.js

const config = {
// ...
experimental: {
prebundleSvelteLibraries: true
}
}

// ...
```

For more information, see https://kit.svelte.dev/faq#packages

### Svelte usage

Create a JSONEditor with two-way binding `bind:json`:
Expand Down
13 changes: 0 additions & 13 deletions src/lib/config.js

This file was deleted.

0 comments on commit 1c64009

Please sign in to comment.