Skip to content

Commit

Permalink
fix: #488 types JsonEditor and CreateJSONEditorProps not exported…
Browse files Browse the repository at this point in the history
… in `vanilla-jsoneditor`
  • Loading branch information
josdejong committed Oct 9, 2024
1 parent 45a7b74 commit 337c33b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion rollup.config.vanilla-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 337c33b

Please sign in to comment.