diff --git a/rollup.config.vanilla-types.js b/rollup.config.vanilla-types.js index 84ec4817..5d1c8141 100644 --- a/rollup.config.vanilla-types.js +++ b/rollup.config.vanilla-types.js @@ -12,5 +12,23 @@ export default { format: 'es' } ], - plugins: [dts()] + plugins: [dts(), exportJsonEditorClass()] +} + +// The DTS plugin doesn't export the JsonEditor class that is generated by Svelte whilst compiling, +// so we append an export for it manually. Similarly, the CreateJSONEditorProps interface is not +// exported by DTS, so we add an export for it too. +function exportJsonEditorClass() { + return { + name: 'export-json-editor', + transform: (code, id) => { + if (id.endsWith('index-vanilla.d.ts')) { + const customExports = 'export type { JsonEditor, CreateJSONEditorProps }' + + return `${code}\n${customExports}\n` + } + + return code + } + } }