Export for usage outside of svelte
milafrerichs opened this issue · 4 comments
Hey @tanhauhau
thanks for this! Really neat, would you consider adding the ability to export this component to be used outside of svelte?
something like this:
new JsonTree({
target: document.querySelector('#main'),
props: {
value: {
array: [1, 2, 3],
bool: true,
object: {
foo: 'bar'
}
}
}
});
Would love to use it in my project.
I have already forked it and would have one way of implementing it ready and could provide a PR.
master...milafrerichs:feat/add-package-export
Have a great day and a great Christmas holiday (if you celebrate that :) )
awesome, thanks!
merry Christmas! :)
@tanhauhau thanks for that
Happy New Year!!
I just tried it out and it unfortunately did not work.
I think it's because you published it only as cjs
and this does not work in the browser.
would it be possible to publish as umd
as well and give it a name (like JsonTree)
{ file: 'dist/index.js' , 'format': 'umd', name: 'JsonTree' }
similar to what I did in my fork:
master...milafrerichs:feat/add-package-export#diff-ff6e5f22a9c7e66987b19c0199636480R15
Thanks a lot.
Have a great day.
Sorry for getting back this later, i've published a umd version in 1.0.0
.
You can use it in the browser directly like:
<html>
<script src="https://unpkg.com/svelte-json-tree@1.0.0/dist/standalone/umd/index.js"></script>
<script>
new SvelteJsonTree({
target: document.body,
props: { value: [20, 21] },
});
</script>
</html>