Closed tommywalkie closed 3 years ago
Thanks for reporting! Sorry for the inconvenience. Okay, I need to look for some other solutions that work with esm too. 🤔
import { subscribe as subscribeB } from 'https://cdn.skypack.dev/valtio@0.8.1/vanilla'
This seems to work. just FYI.
https://github.com/pmndrs/valtio/blob/a396bfdfde33a1ce93c1e9c24e387b068df3d50e/src/index.ts#L1
This doesn't seem to work with pika? snowpack?
@dai-shi That's possible. Looking at https://github.com/snowpackjs/snowpack/issues/2774, the zarr
package seems to run with similar issues.
It turns out #112 didn't fix this issue at all. https://jsfiddle.net/gpLesnzu/
Does anyone know how to work around this?
I wanted to try this library since it seems simple and flexible, while allowing writing to state outside React compared to Jotai. However, using Snowpack for development, I have a problem importing just following the examples posted. With
import { proxy } from 'valtio';
export const test = proxy({ hello: 'world' });
I get Uncaught SyntaxError: The requested module '../../../../_snowpack/pkg/valtio.js' does not provide an export named 'proxy'
. Some workarounds seems to be import { proxy } from 'valtio/vanilla'
but that results in Uncaught Error: Please use proxy object
. The only thing working for me is
import v from 'valtio';
export const test = v.proxy({ hello: 'world' });
If I do import * as v from 'valtio';
then the structure is
if that helps.
Just curious if it's related to this issue?
Oh, no. We would definitely like to fix the issue with snowpack. The issue seems related to this one, but not 100% as the workaround is different. I will investigate it when I have a chance to learn snowpack, but if someone can help on this, it'd be very appreciated.
@dai-shi This should be fixed now in 1.0.7 (logged module object is from Skypack, Valtio 1.0.7)
import * as valtio from 'https://cdn.skypack.dev/valtio';
console.log(valtio);
Cool. Thanks for confirming.
Tried using the newly released
0.8.1
version (via ES Modules) today and couldn't import any of Valtio methods.JSFiddle