-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle CommonJS module #912
Conversation
Can you bump the vite dependency in this pull request and make sure that all the examples and storybook still work? |
I'll give it a go on Monday. Enjoy your weekend! |
Hey, I checked the examples/storybook as you asked and found they didn't work. I needed to change it to this |
I haven't added the |
Yes. We should make the ci fail if the lock file is not up to date. |
Apparently |
Yeah, I expected that to error out. Weird. |
My bad - thanks for catching this. Turns out Storybook, Samples, and my project work now (for me). |
474108b
to
f168487
Compare
Hmm, why doesn't vite pull in the module file automatically? We already specify module in the package.json. Maybe we need to add an explicit export map? |
Hmm, looks like vite prefers browser over module: https://vitejs.dev/config/shared-options#resolve-mainfields. Not sure why, though. |
Adding explicit exports for embed seems to work (vega/vega-embed#1301) but now vite doesn't like fast-json-patch which again to me doesn't make sense since the package is esm as well.
|
@@ -1,5 +1,5 @@ | |||
import type { View, SignalListeners } from './types'; | |||
import { vega } from 'vega-embed'; | |||
import { vega } from 'vega-embed/build/vega-embed.module.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't feel right as it requires a specific file in a specific place.
The right fix seems to add import maps.
Yeah, I'm getting the same error as you for sveltekit. Svelte works, which suggests that vite is resolving it correctly, but node isn't. Storybook was still broken, but I got it to work by setting this I wonder if node expects I had a go at getting vite to resolve the path to In summary, its getting messy. I'm going to revisit this in a day. |
I'm happy to change embed to use |
Marking as draft since it doesn't work yet. |
Sorry the stalled progress. I've got a carbon-copy of the svelte-vega package working with the initial commit of this PR. While I can appreciate the structure of this repo, I can't justify working on Storybook when we only need a svelte-friendly wrapper for vegalite. |
Makes sense. I think storybook isn't the issue big here but svelte kit doesn't work either. I'll close the pull request for now but it's still something we should address since many people use vite 5. |
Fixes #868
The
vega-embed
package is not of"type": "module"
, so it has to be imported this way.It seems to work for me in a stripped-down version of this package using Vite 5.