You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: export one bundle with and one without external dependencies in vanilla-jsoneditor (#353)
BREAKING CHANGE:
When using `vanilla-jsoneditor` directly in the browser, you now have to `import { JSONEditor } from 'vanilla-jsoneditor/standalone.js'` instead of `import { JSONEditor } from 'vanilla-jsoneditor'`. For projects with a build setup (React, Vue, Angular) it should be a drop-in replacement.
The standalone bundle contains all dependencies of `vanilla-jsoneditor`, for example `lodash-es` and `Ajv`. If you use some of these dependencies in your project too, it means that they will be bundled twice in your web application, leading to a needlessly large application size. In general, it is preferable to use the default `import { JSONEditor } from 'vanilla-jsoneditor'` so dependencies can be reused.
34
52
35
53
## Use (Browser example loading the ES module):
36
54
@@ -44,7 +62,7 @@ Remark: for usage in a Svelte project, install `svelte-jsoneditor` instead.
@@ -172,7 +190,7 @@ If you are using NextJS, you will need to use a dynamic import to only render th
172
190
173
191
If you are using React in an conventional non-NextJS browser app, you can import the component using a standard import statement like `import JSONEditorReact from '../JSONEditorReact'`
174
192
175
-
```typescript
193
+
```tsx
176
194
//
177
195
// demo.tsx for use with NextJS
178
196
//
@@ -228,7 +246,7 @@ export default function Demo() {
The library provides a standalone bundle of the editor via the npm library `vanilla-jsoneditor` (instead of `svelte-jsoneditor`) which can be used in any browser environment and framework. In a framework like React, Vue, or Angular, you'll need to write some wrapper code around the class interface.
106
+
The library provides a vanilla bundle of the editor via the npm library `vanilla-jsoneditor` (instead of `svelte-jsoneditor`) which can be used in any browser environment and framework. In a framework like React, Vue, or Angular, you'll need to write some wrapper code around the class interface.
107
107
108
-
Note that the `vanilla-jsoneditor` package contains all dependencies. These are purely needed for the TypeScript types that they export.
108
+
If you have a setup for your project with a bundler (like Vite, Rollup, or Webpack), it is best to use the default ES import:
109
109
110
-
Browser example loading the ES module:
110
+
```ts
111
+
// for use in a React, Vue, or Angular project
112
+
import { JSONEditor } from'vanilla-jsoneditor'
113
+
```
114
+
115
+
If you want to use the library straight in the browser, use the provided standalone ES bundle:
The standalone bundle contains all dependencies of `vanilla-jsoneditor`, for example `lodash-es` and `Ajv`. If you use some of these dependencies in your project too, it means that they will be bundled twice in your web application, leading to a needlessly large application size. In general, it is preferable to use the default `import { JSONEditor } from 'vanilla-jsoneditor'` so dependencies can be reused.
123
+
124
+
Browser example loading the standalone ES module:
111
125
112
126
```html
113
127
<!doctype html>
@@ -119,11 +133,11 @@ Browser example loading the ES module:
0 commit comments